<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:wfw="http://wellformedweb.org/CommentAPI/">
<channel>
<title>dwt&#039;s life - 深度学习</title>
<link>https://dwt.life/category/deep-learning/</link>
<atom:link href="https://dwt.life/feed/category/deep-learning/" rel="self" type="application/rss+xml" />
<language>zh-CN</language>
<description>深度学习</description>
<lastBuildDate>Thu, 10 Oct 2024 23:04:19 +0800</lastBuildDate>
<pubDate>Thu, 10 Oct 2024 23:04:19 +0800</pubDate>
<item>
<title>golang 7zip dll</title>
<link>https://dwt.life/archives/345/</link>
<guid>https://dwt.life/archives/345/</guid>
<pubDate>Thu, 10 Oct 2024 23:04:19 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[创建目录 zipdll代码：unzip.gopackage main/*#include &lt;stdlib.h&gt;// 定义回调类型typedef void (*Callback)(co...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>创建目录 zipdll</p><p>代码：<br>unzip.go</p><pre><code class="lang-go">package main

/*
#include &lt;stdlib.h&gt;

// 定义回调类型
typedef void (*Callback)(const char*);
// 将 call_callback 声明为 static
static void call_callback(void (*cb)(const char*), const char* message) {
    if (cb != NULL) {
        cb(message);
    }
}

*/
import &quot;C&quot;
import (
    &quot;fmt&quot;
    &quot;io&quot;
    &quot;os&quot;
    &quot;path/filepath&quot;
    &quot;github.com/bodgit/sevenzip&quot;
)

// 计算 7z 文件的总大小
func calculate7zTotalSize(reader *sevenzip.Reader) int64 {
    var totalSize int64
    for _, file := range reader.File {
        totalSize += int64(file.UncompressedSize)
    }
    return totalSize
}

// 解压 7z 文件并调用回调
//export Unzip7zWithCallback
func Unzip7zWithCallback(archivePath *C.char, destDir *C.char, cb C.Callback) {
    goArchivePath := C.GoString(archivePath)
    goDestDir := C.GoString(destDir)

    // 打开 7z 文件
    file, err := os.Open(goArchivePath)
    if err != nil {
        C.call_callback(cb, C.CString(&quot;Failed to open 7z file&quot;))
        return
    }
    defer file.Close()

    // 获取文件信息
    fileInfo, err := file.Stat()
    if err != nil {
        C.call_callback(cb, C.CString(&quot;Failed to get file info&quot;))
        return
    }

    // 创建 7z 读取器
    reader, err := sevenzip.NewReader(file, fileInfo.Size())
    if err != nil {
        C.call_callback(cb, C.CString(&quot;Failed to create 7z reader&quot;))
        return
    }

    // 计算总大小以跟踪进度
    totalSize := calculate7zTotalSize(reader)
    if totalSize == 0 {
        C.call_callback(cb, C.CString(&quot;Empty 7z file&quot;))
        return
    }

    var processedSize int64
    progressStep := totalSize / 200 // 0.5% 对应的字节数
    nextProgressTrigger := progressStep

    // 解压文件
    for _, file := range reader.File {
        path := filepath.Join(goDestDir, file.Name)

        // 检查是否是目录
        if file.FileHeader.FileInfo().IsDir() {
            os.MkdirAll(path, 0755)
            continue
        }

        // 创建解压目标文件
        if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
            C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Failed to create directory: %s&quot;, err.Error())))
            return
        }

        destFile, err := os.Create(path)
        if err != nil {
            C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Failed to create file: %s&quot;, err.Error())))
            return
        }
        defer destFile.Close()

        // 打开 7z 内部文件
        rc, err := file.Open()
        if err != nil {
            C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Failed to open entry in 7z: %s&quot;, err.Error())))
            return
        }
        defer rc.Close()

        // 复制文件并更新进度
        buffer := make([]byte, 1024*64) // 每次读取 64KB
        for {
            n, err := rc.Read(buffer)
            if err != nil &amp;&amp; err != io.EOF {
                C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Failed to read file: %s&quot;, err.Error())))
                return
            }
            if n == 0 {
                break
            }

            if _, err := destFile.Write(buffer[:n]); err != nil {
                C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Failed to write file: %s&quot;, err.Error())))
                return
            }

            // 更新处理的字节数
            processedSize += int64(n)

            // 每 0.5% 调用一次回调
            if processedSize &gt;= nextProgressTrigger {
                progress := float64(processedSize) / float64(totalSize) * 100
                C.call_callback(cb, C.CString(fmt.Sprintf(&quot;Progress: %.2f%%&quot;, progress)))
                nextProgressTrigger += progressStep
            }
        }
    }

    C.call_callback(cb, C.CString(&quot;7z extraction completed successfully&quot;))
}

func main() {}</code></pre><p>目录下执行 <code>go mod init</code><br><code>go mod tidy</code></p><p>编译：<code>GOOS=windows GOARCH=amd64 go build -o unzip7z_64.dll -buildmode=c-shared unzip.go</code><br><code>GOOS=windows GOARCH=386 go build -o unzip7z_32.dll -buildmode=c-shared unzip.go</code></p>
]]></content:encoded>
<slash:comments>2</slash:comments>
<comments>https://dwt.life/archives/345/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/category/deep-learning/</wfw:commentRss>
</item>
<item>
<title>armbian/debian/linux 硬盘休眠 </title>
<link>https://dwt.life/archives/338/</link>
<guid>https://dwt.life/archives/338/</guid>
<pubDate>Sun, 03 Mar 2024 01:40:11 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[该篇教程主要讲解设置hdparm让硬盘自动休眠，如果你打算用arm设备作为Linux备份机Tip：该教程只适用相关系统硬盘不能自动休眠或无休眠设置项，设置需要按实际情况设置。查看是否已安装hdp...]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p>该篇教程主要讲解设置hdparm让硬盘自动休眠，如果你打算用arm设备作为Linux备份机</p><p>Tip：该教程只适用相关系统硬盘不能自动休眠或无休眠设置项，设置需要按实际情况设置。</p><p>查看是否已安装hdparm#<br>hdparm</p><p><img src="https://pic.peo.pw/a/2024/03/03/65e3552b44bd0.png" alt="1935144006.png" title="1935144006.png"></p><pre><code>安装hdparm#
sudo apt-get install hdparm
查看硬盘是否支持写入缓存，有* (星号)，表示支持#
sudo hdparm -I /dev/sda | grep &#039;Write cache&#039;
让硬盘进入待机模式#
hdparm -y /dev/sda1
让硬盘进入睡眠模式#
hdparm -Y /dev/sda1
设置定时休眠#
5分钟无操作休眠（参数是5的倍数，比如60*5是300秒也就是5分钟）

hdparm -S 60 /dev/sda1
修改hdparm配置#
ls /dev/disk/by-id</code></pre><p>查看你的硬盘ID</p><pre><code>sudo vim /etc/hdparm.conf
/dev/disk/by-id/ata-TOSHIBA_MD04ABA400V_2818KRSKFMYB {
    apm  = 127
    spindown_time = 60
    write_cache = on
}</code></pre><p>然后执行<br>sudo /usr/lib/pm-utils/power.d/95hdparm-apm resume<br>或者重启</p><p>在5分没使用硬盘的情况下, 硬盘会自动休眠了</p><p>ps :</p><p>/dev/disk/by-id/* 自己去看下这个目录下自己的文件名<br>spindown_time 60 计算参考</p><pre><code>
0 = disabled
1..240 = multiples of 5 seconds (5 seconds to 20 minutes)
241..251 = 1..11 x 30 mins
252 = 21 mins
253 = vendor defined (8..12 hours)
254 = reserved
255 = 21 mins + 15 secs
write_cache 写缓存自己决定是否要开启,可以使用off</code></pre><p>不支持apm的需要设置 force_spindown_time 看文档说的是除了spindown以外参数都正常</p><p><a href="https://blog.csdn.net/lovefengchenlove/article/details/129468283">https://blog.csdn.net/lovefengchenlove/article/details/129468283</a><br><a href="https://www.cnblogs.com/HGNET/p/17077365.html">https://www.cnblogs.com/HGNET/p/17077365.html</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/338/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/category/deep-learning/</wfw:commentRss>
</item>
<item>
<title>todo list</title>
<link>https://dwt.life/archives/128/</link>
<guid>https://dwt.life/archives/128/</guid>
<pubDate>Sun, 22 Aug 2021 13:55:00 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[[ ] a[x] a]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<ul><li>[ ] a</li><li>[x] a</li></ul>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/128/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/category/deep-learning/</wfw:commentRss>
</item>
<item>
<title>CDN文献</title>
<link>https://dwt.life/archives/120/</link>
<guid>https://dwt.life/archives/120/</guid>
<pubDate>Wed, 11 Aug 2021 10:37:07 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[基于P2P与CDN融合之DHT算法研究.pdf]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p><a href="http://ai.application.pub/usr/uploads/2021/08/1567610630.pdf">基于P2P与CDN融合之DHT算法研究.pdf</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/120/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/category/deep-learning/</wfw:commentRss>
</item>
<item>
<title>SSL 爬虫识别</title>
<link>https://dwt.life/archives/109/</link>
<guid>https://dwt.life/archives/109/</guid>
<pubDate>Wed, 11 Aug 2021 10:35:00 +0800</pubDate>
<dc:creator>Ricky</dc:creator>
<description><![CDATA[1002-137X-2020-3-287.pdf]]></description>
<content:encoded xml:lang="zh-CN"><![CDATA[
<p><a href="http://ai.application.pub/usr/uploads/2021/08/343778915.pdf">1002-137X-2020-3-287.pdf</a></p>
]]></content:encoded>
<slash:comments>0</slash:comments>
<comments>https://dwt.life/archives/109/#comments</comments>
<wfw:commentRss>https://dwt.life/feed/category/deep-learning/</wfw:commentRss>
</item>
</channel>
</rss>