让你的IPFS站点持久在线:接入Filebase的Names(IPNS)服务

本文会介绍如何接入filebase的Names(IPNS)服务,使你的IPFS站点持久在线。 背景 周末更新博客时,发现workflow的上传IPFS任务执行失败了。 ...

2024-09-04 · 3 min · 1246 words · Liudon

一次简短的青岛之行

刚放暑假的时候,就答应了娃带她去一趟青岛。 8月份要回老家,所以定在了7月中下旬出发。 车票/酒店都订好了,结果来了个台风格美。 出发前一周一直在查天气,就怕去了一直下雨。 ...

2024-08-31 · 2 min · 998 words · Liudon

解决 "undeclared name: any (requires version go1.18 or later)" 编译错误

$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest $ $ protoc-gen-go --version protoc-gen-go v1.34.2 $ $ sh make.sh user.pb.go:123:45: undeclared name: any (requires version go1.18 or later) $ 流水线编译报错,其中make.sh文件代码: ... protoc -I=./ --proto_path=./ --go_out=./ --go_opt=paths=source_relative user.proto ... go build 同样的代码在本机编译就没问题,但是放到流水线里编译就报上面的错误。 ...

2024-06-14 · 1 min · 473 words · Liudon

搭建自托管IPFS Gateway服务,替代Cloudflare的IPFS Gateway

背景 4月底的时候,Livid大佬提醒,Cloudflare应该是调整了IPFS Gateway网关策略,我的IPFS镜像博客无法访问了。 没查到Cloudflare的调整说明,不过还好IPFS官方也提供了公共网关gateway.ipfs.io,将域名解析改到官网网关。 ...

2024-05-22 · 3 min · 1262 words · Liudon

302跳转的跨域问题(CORS)

302跳转的跨域问题 场景一:302不返回跨域头 请求 GET /302 HTTP/1.1 Host: liudon.xyz Origin: https://www.baidu.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 返回 HTTP/1.1 200 OK Cache-Control: private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Cf-Ray: 88535773eaf5107e-HKG Content-Length: 143 Content-Type: text/html Date: Fri, 17 May 2024 11:42:00 GMT Expires: Thu, 01 Jan 1970 00:00:01 GMT Location: https://liudon.org Server: cloudflare Vary: Accept-Encoding 浏览器报错 ...

2024-05-17 · 2 min · 721 words · Liudon

GORM增加sqlcommenter特性

什么是sqlcommenter? sqlcommenter is a suite of middlewares/plugins that enable your ORMs to augment SQL statements before execution, with comments containing information about the code that caused its execution. This helps in easily correlating slow performance with source code and giving insights into backend database performance. In short it provides some observability into the state of your client-side applications and their impact on the database’s server-side. ...

2024-04-18 · 2 min · 742 words · Liudon

源码分析:GORM是如何生成sql的

在gorm下实现sqlcommenter过程中,遇到一些问题,顺便把gorm整个流程梳理了一遍,整理记录一下。 gorm使用示例 package main import ( "gorm.io/driver/mysql" "gorm.io/gorm" ) type Product struct { gorm.Model Code string Price uint } func main() { // 参考 https://github.com/go-sql-driver/mysql#dsn-data-source-name 获取详情 dsn := "user:pass@tcp(127.0.0.1:3306)/dbname?charset=utf8mb4&parseTime=True&loc=Local" db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) var product Product db.First(&product, 1) // 根据整型主键查找 } 我们以First查询为例,看一下是怎么转成具体sql的。 ...

2024-04-18 · 6 min · 2737 words · Liudon

工银亚洲网银密码重置

18年的时候办了张工银亚洲的银行卡,好几年没有用过了。 今年想起来了,发现网银登不上了,密码忘了。 最悲剧的是,试了超过10次,账户冻结了。 打95588咨询了一下,说是可以内地见证方式修改密码,只需要带上港澳通行证和身份证即可。 ...

2024-03-16 · 1 min · 481 words · Liudon

加速Cloudflare访问

背景 这是当前的博客架构,文件保存在Github仓库,通过Cloudflare Page提供访问。 众所周知,在国内,Cloudflare的CDN属于反向加速,平均耗时在1.5s左右。 ...

2024-02-21 · 3 min · 1128 words · Liudon

2023年终总结

2023年过完了,是时候来个总结了。 博客 2023年一共更新了15篇内容,共计12000字。 访问Top3的文章: ...

2024-01-04 · 2 min · 748 words · Liudon

2023年12月北京暴雪记录

记录暴雪下普通打工人的生活。 12月14日 周四 北京的雪已经连着下了两天了。 12月11日,也是因为下雪,晚上打车打到10点半才叫到车。 所以这次下雪后,晚上就早走了。 ...

2023-12-16 · 2 min · 599 words · Liudon

使用Hugo实现响应式和优化的图片

继续我们的博客优化之旅,本篇内容我们将介绍如何使用Hugo实现响应式和优化的图片。 问题 在之前文章里,通过腾讯云数据万象实现了图片优化能力,具体的可参考文章累计布局偏移修复方案改进 —— 自动生成图片宽高。 经过一段运行后,发现这里有一个弊端。 Run hugo --gc --minify --cleanDestinationDir Start building sites … hugo v0.119.0-b84644c008e0dc2c4b67bd69cccf87a41a03937e linux/amd64 BuildDate=2023-09-24T15:20:17Z VendorInfo=gohugoio ERROR Failed to get JSON resource "https://static.***.com/64412246-9050f100-d0c1-11e9-893a-f9b0766533ad.png?imageInfo&t=1698674110": Get "https://static.***.com/64412246-9050f100-d0c1-11e9-893a-f9b0766533ad.png?imageInfo&t=1698674110": stream error: stream ID 1; STREAM_CLOSED; received from peer ERROR Failed to get JSON resource "https://static.***.com/SkRx5uFwQ8Cliyq.jpg?imageInfo&t=1698674110": Get "https://static.***.com/SkRx5uFwQ8Cliyq.jpg?imageInfo&t=1698674110": stream error: stream ID 3; STREAM_CLOSED; received from peer 随着图片数量增多,因为需要调接口查询图片信息,这里构建耗时变长,同时也特别容易出现超时导致构建失败。 ...

2023-12-10 · 5 min · 2021 words · Liudon

加速Google Analytics

起因 Google Analytics是一款优秀的流量分析服务,集成方便,使用简单。 最近在优化页面访问速度,发现Google Analytics是一个优化点。 优化 1. 访问加速 国内访问Google Analytics很慢,同时还面临着各种广告屏蔽插件拦截。 ...

2023-12-02 · 2 min · 870 words · Liudon

使用Google Indexing API加速博客收录

对于一个新站点来说,总是想着能让搜索引擎快点收录网站内容。 今天,我们就来介绍一种利用Google Indexing API接口,通过Github Actions实现部署时通知Google抓取页面内容。 ...

2023-10-27 · 2 min · 635 words · Liudon

在Netlify上部署Twikoo评论系统

在本篇文章里,我会介绍如何在Netlify上部署Twikoo评论系统,如何接入到静态博客Hugo,以及如何实现Twikoo系统版本自动更新。 2024年7月30日更新:因为Github接口策略调整,原有的匿名通过接口获取版本号方法失效,已更改为带token方式请求接口获取版本号,详见workflow里Get twikoo version步骤配置。 ...

2023-10-19 · 5 min · 2232 words · Liudon

利用Github Actions定时抓取微博

背景 在微博上关注了一些用户,比如tk教主,月风。 但是有些内容过段时间不可见了,所以希望可以定时抓取微博归档备份下来。 实现方案 整体思路:利用Github Actions的Scheduled任务,定时执行抓取shell脚本,将内容保存到文件,提交到Github仓库。 ...

2023-10-07 · 2 min · 823 words · Liudon

北大口腔牙周刮治记录

病情 上次洗完牙后,还是不时有出血的情况。 前段时间更是出现牙龈劈开一块肉,特别容易塞东西的情况。 于是,又跑到医院来看牙了。 医生检查后,说是牙周病,需要牙周刮治,要约到8月份了。 ...

2023-09-17 · 2 min · 716 words · Liudon

故乡回忆之旅

赶在8月底,趁着娃暑假的尾声,回了趟老家。 老家有条俗语,“永福庄的街,三里长”。 这天吃完午饭,临时起意,带媳妇溜溜大街,见识下我们的大街。 小时候,整天在这条街上跑来跑去。 ...

2023-09-09 · 1 min · 292 words · Liudon

解决Golang使用go get安装包后找不到可执行文件的问题

背景 编译流水线代码 go get google.golang.org/protobuf/cmd/protoc-gen-go@latest protoc -I=./zzz --proto_path=./xx --go_out=./abc --go_opt=paths=xx.proto ... go build -o xxx 在go升级到1.20.1版本后,执行报错。 protoc-gen-go: program not found or is not executable 解决 Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead. In a future Go release, go get will no longer build packages; it will only be used to add, update, or remove dependencies in go.mod. Specifically, go get will act as if the -d flag were enabled. ...

2023-08-17 · 1 min · 195 words · Liudon

修正Hugo的JSON Feed格式

问题背景 前几天在Planet里follow自己的web3博客,遇到下面的错误。 经过Livid大佬提醒,说是网站的JSON Feed不是标准格式导致的。 因为我的已经修正没法截图,这里以dvel的博客举例,格式类似如下。 [ { "content": "用 ChatGPT 写一些小脚本真是太方便了。\nGPT-4 发布后试了试,还是蛮不错的,代码是 ChatGPT 生成的。\n几个来回就可以编写一个能正常使用的油猴脚本:\n(略,HTML 代码) 在 https://chdbits.co/bakatest.php 有如上内容。 我要为这个网页编写一个油猴脚本。 通过自动获取 ChatGPT 的 API 来解析此问题的答案,供用户参考。 将内容输出到 `#outer > h1` 的下面,同时输出你提取到的问题内容和答案,以便我看看你是否提取正确。 获取错啦。 问题的获取路径是 `#outer > form > table > tbody > tr:nth-child(1) > td` 选项的获取路径是 `#outer > form > table > tbody > tr:nth-child(2) > td` 使用这个 API: ``` curl https://api.openai.com/v1/chat/completions \\ -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer YOUR_API_KEY' \\ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!"}], "temperature": 0.7 }' ``` 响应格式为: ``` { "id":"chatcmpl-abc123", "object":"chat.completion", "created":1677858242, "model":"gpt-3.5-turbo-0301", "usage":{ "prompt_tokens":13, "completion_tokens":7, "total_tokens":20 }, "choices":[ { "message":{ "role":"assistant", "content":"\\n\\nThis is a test!" }, "finish_reason":"stop", "index":0 } ] } ``` 它没有最近的互联网数据,所以还是需要把 API 的使用方式发给它。\n然后它就帮我写好了,我不用复习 JavaScript,不用看油猴脚本的教程和文档,也不用查 @grant 等等标记是干嘛的。\n可以再继续要求它改进一些,比如换个输出位置,优化 prompt,自动选中正确回答,支持单选题和多选题等等。\n效果展示:\n安装: https://greasyfork.org/zh-CN/scripts/461944-chd-quiz-answer\n", "permalink": "https://dvel.me/posts/chd-quiz-answer/", "summary": "用 ChatGPT 写一些小脚本真是太方便了。\nGPT-4 发布后试了试,还是蛮不错的,代码是 ChatGPT 生成的。\n几个来回就可以编写一个能正常使用的油猴脚本:\n(略,HTML 代码) 在 https://chdbits.co/bakatest.php 有如上内容。 我要为这个网页编写一个油猴脚本。 通过自动获取 ChatGPT 的 API 来解析此问题的答案,供用户参考。 将内容输出到 `#outer > h1` 的下面,同时输出你提取到的问题内容和答案,以便我看看你是否提取正确。 获取错啦。 问题的获取路径是 `#outer > form > table > tbody > tr:nth-child(1) > td` 选项的获取路径是 `#outer > form > table > tbody > tr:nth-child(2) > td` 使用这个 API: ``` curl https://api.openai.com/v1/chat/completions \\ -H 'Content-Type: application/json' \\ -H 'Authorization: Bearer YOUR_API_KEY' \\ -d '{ "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Say this is a test!", "title": "CHD 油猴脚本:每日签到自动答题" }, ... ] 下面是一个JSON Feed的示例,详细规范见jsonfeed.org。 ...

2023-03-25 · 3 min · 1451 words · Liudon