跳到主要内容

· 阅读需 28 分钟

0x00 了解其定义、应用与影响

YouTube 视频

  • 📺 生成式 AI 入门教程,介绍生成式 AI 的定义、应用和影响。
  • 💼 生成式 AI 被认为可能为全球经济每年贡献 2.6 至 4.4 万亿美元。
  • 🌐 生成式 AI 有望在未来十年内提高全球 GDP 7%。
  • 🤖 生成式 AI 可以生成高质量的文本、图像和音频。
  • 📈 生成式 AI 使许多 AI 应用更容易构建,可能帮助企业降低成本并创造更多价值。
  • 📣 课程将介绍生成式 AI 的工作原理,讨论常见用例,以及如何负责任地应用 AI。

· 阅读需 18 分钟

0x00 初印象

从 2022 年底 ChatGPT 的发布,当时未感觉到有什么特别的,直到大概二三月份,在网络上看到铺天盖地的都在发与 ChatGPT 的对话截图,有一些是感叹它的强大,有一些是对它进行调戏,试图找出它的不足。

这时我才开始关注它,于是在推上时间线刷到的注册流程指引帮助下,短信验证码外加程序员必备的科学上网技能,挺容易就注册成功了。不过我相信一般普通人可能大部分在这一步就卡住放弃了。之后也看到说在某宝上购买的账号,在之后阶段被封号,总之在上半年期间,OpenAI 花了不少功夫与大家斗智斗勇,就不展开了。

· 阅读需 10 分钟

十个 Node.js 的设计错误

Node.js 最初设计者 Ryan Dahl 2018 年在 JS Conf Berlin 的分享

沒有坚持使用 Promise

  • 在 2009 年六月在 Node 中开始引入 JavaScript 的 Promises,但又在 2010年二月就移除掉了。

    结果,随着日子久远,Node 里面就遍布着 async/await 和 promise 的不同 async API 设计,直至现时都极难整合

看轻了安全性(Security)

· 阅读需 1 分钟
const puppeteer = require('puppeteer');
const pageUrl = 'https://some-url.com';

(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setRequestInterception(true);

page.on('request', (interceptedRequest) => {
// Don't intercept main document request
if (interceptedRequest.url === pageUrl) {
interceptedRequest.continue();
return;
}

// Intercept if request url starts with https
if (interceptedRequest.url.startsWith('https://')) {
interceptedRequest.continue({
// Replace https:// in url with http://
url: interceptedRequest.url.replace('https://', 'http://'),
});
return;
}

// Don't override other requests
interceptedRequest.continue();
})

await page.goto(pageUrl);
await browser.close();
})();

· 阅读需 2 分钟

今天在 git clone 一个 github 仓库的时候出现了以下错误

ssh_exchange_identification: read: Connection reset by peer

怀疑是代理的原因,试了全局、直连、规则都不行,查找了一些文章有说可以使用以下命令查看详细调试信息

ssh -vvv -T git@github.com

还是不行,在 v2ex 上看到一个楼主说需要加个配置,所以就试了下

~/.ssh/config 中添加以下配置

Host github.com
Hostname ssh.github.com
Port 443

再试下就可以了

· 阅读需 11 分钟

发现生产环境的业务报了好多错误, 涉及的 Node.js 代码是一个基于 Redis 的频率计数器,那部分逻辑大概是这样

// 查询并增加一次计数
async incr (id) {
const key = `${this.namespace}:${id}`
const now = getMicrotime()
const start = now - this.duration * 1000

const operations = [
['zremrangebyscore', key, 0, start],
['zcard', key],
['zadd', key, now, now],
['pexpire', key, this.duration]
]

const res = await this.redis.multi(operations).exec()
const count = toNumber(res[1][1])
return count
}

错误是:

Cannot read property '1' of undefined