订阅
#1354 | 2024-07-02 00:55:57

pipe.js:

process.stdout.write(require('fs').readFileSync(0, 'utf-8'))
// or process.stdin.pipe(process.stdout)
script -q /dev/null node -p  "Boolean(0)" | node pipe.js
# will print yellow false

#1353 | 2024-06-30 02:11:36

https://stablediffusion3.net/zh-CN

#1351 | 2024-05-07 18:28:34

啥叫递归啊

#1348 | 2024-04-21 12:39:03

url to text(for llm

#1345 | 2024-04-10 09:20:39
#1339 | 2024-04-02 20:02:22

我才知道娜塔丽波特曼是犹太人……还有她今年离婚了。。😅

=== update ===

才注意到原来费曼也是犹太人😭

#1337 | 2024-03-25 19:53:31
let a = await (Promise.reject('msg')).catch(e => e)
a === 'msg' // true

(但如果把await放到括号里面就catch不住了🙅‍♀️

#1335 | 2024-03-20 15:18:56

node从v18起就支持把JS代码打包成二进制了:https://nodejs.org/api/single-executable-applications.html

(我记得好像记录过这个,但是找不到了...😅😅

#1334 | 2024-03-20 13:10:46

成功用workerd把gdshare在vps上跑起来了

docker pull dcard/workerd

docker run -d -p 8081:8081 -v .:/app dcard/workerd serve /app/workerd.capnp

第二条命令执行的时候要确保当前目录有两个文件,一个是workerd.capnp:

using Workerd = import "/workerd/workerd.capnp";

const helloWorldExample :Workerd.Config = (
  services = [ (name = "main", worker = .helloWorld) ],
    sockets = [ ( name = "http", address = "*:8081", http = (), service = "main" ) ]
);

const helloWorld :Workerd.Worker = (
  serviceWorkerScript = embed "worker.js",
  compatibilityDate = "2023-02-28",
);

另一个是worker.js

addEventListener('fetch', event => {
  event.respondWith(handle(event.request));
});

async function handle(request) {
  return new Response("Hello World\n");
}

(实际上我是用了gdshare

其实不一定要用docker,我本地迷你主机就成功用官方发布的二进制的workerd跑起来了,但是我的vps ubuntu版本比较老,直接跑二进制会报错……

具体命令则是 ./workerd serve workerd.capnp

#1330 | 2024-03-18 17:45:04

老版本的node(比如8)在请求用let's encrypt的https证书加密的网站时会报错certificate has expired

有几种解决办法,最正确的是升级node版本,我试了下14就不报错了。。
最省事的是在env里加一句NODE_TLS_REJECT_UNAUTHORIZED=0

更灵活点可以在具体的请求里忽略tls报错

const https = require("https");

const agent = new https.Agent({
  rejectUnauthorized: false,
});

最硬核的就是改node源码自己编译了。。

#1327 | 2024-03-12 15:30:34

HTTP 418 I'm a teapot

#1311 | 2024-02-02 12:11:42

辣鸡google把搜索结果里的cache链接给去掉了,真不知道怎么想的……

不过目前还可以通过构造链接的方式查看缓存,比如 https://webcache.googleusercontent.com/search?q=cache:https://bb.viegg.com/