<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://purl.org/rss/1.0/"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel rdf:about="https://dwt.life/feed/rss/category/deep-learning/">
<title>dwt&#039;s life - 深度学习</title>
<link>https://dwt.life/category/deep-learning/</link>
<description>深度学习</description>
<items>
<rdf:Seq>
<rdf:li resource="https://dwt.life/archives/345/"/>
<rdf:li resource="https://dwt.life/archives/338/"/>
<rdf:li resource="https://dwt.life/archives/128/"/>
<rdf:li resource="https://dwt.life/archives/120/"/>
<rdf:li resource="https://dwt.life/archives/109/"/>
</rdf:Seq>
</items>
</channel>
<item rdf:about="https://dwt.life/archives/345/">
<title>golang 7zip dll</title>
<link>https://dwt.life/archives/345/</link>
<dc:date>2024-10-10T23:04:19+08:00</dc:date>
<description>创建目录 zipdll代码：unzip.gopackage 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() {}目录下执行 go mod initgo mod tidy编译：GOOS=windows GOARCH=amd64 go build -o unzip7z_64.dll -buildmode=c-shared unzip.goGOOS=windows GOARCH=386 go build -o unzip7z_32.dll -buildmode=c-shared unzip.go</description>
</item>
<item rdf:about="https://dwt.life/archives/338/">
<title>armbian/debian/linux 硬盘休眠 </title>
<link>https://dwt.life/archives/338/</link>
<dc:date>2024-03-03T01:40:11+08:00</dc:date>
<description>该篇教程主要讲解设置hdparm让硬盘自动休眠，如果你打算用arm设备作为Linux备份机Tip：该教程只适用相关系统硬盘不能自动休眠或无休眠设置项，设置需要按实际情况设置。查看是否已安装hdparm#hdparm安装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查看你的硬盘IDsudo vim /etc/hdparm.conf
/dev/disk/by-id/ata-TOSHIBA_MD04ABA400V_2818KRSKFMYB {
    apm  = 127
    spindown_time = 60
    write_cache = on
}然后执行sudo /usr/lib/pm-utils/power.d/95hdparm-apm resume或者重启在5分没使用硬盘的情况下, 硬盘会自动休眠了ps :/dev/disk/by-id/* 自己去看下这个目录下自己的文件名spindown_time 60 计算参考
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不支持apm的需要设置 force_spindown_time 看文档说的是除了spindown以外参数都正常https://blog.csdn.net/lovefengchenlove/article/details/129468283https://www.cnblogs.com/HGNET/p/17077365.html</description>
</item>
<item rdf:about="https://dwt.life/archives/128/">
<title>todo list</title>
<link>https://dwt.life/archives/128/</link>
<dc:date>2021-08-22T13:55:00+08:00</dc:date>
<description>[ ] a[x] a</description>
</item>
<item rdf:about="https://dwt.life/archives/120/">
<title>CDN文献</title>
<link>https://dwt.life/archives/120/</link>
<dc:date>2021-08-11T10:37:07+08:00</dc:date>
<description>基于P2P与CDN融合之DHT算法研究.pdf</description>
</item>
<item rdf:about="https://dwt.life/archives/109/">
<title>SSL 爬虫识别</title>
<link>https://dwt.life/archives/109/</link>
<dc:date>2021-08-11T10:35:00+08:00</dc:date>
<description>1002-137X-2020-3-287.pdf</description>
</item>
</rdf:RDF>