This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 問題 | |
前輩您好,我是一年多前才轉職成為前端工程師的菜雞,轉職初期,使用ChatGPT一下子就解決了我google一兩個小時才搞懂的問題,漸漸的越來越頻繁使用ChatGPT寫程式,到後來的更聰明的claude 3.5 sonnet,最近的cursor IDE,每次使用都像飲鴆止渴,雖然處理問題的速度提升了,但是覺得自己被取代的畫面也越來越清晰了... | |
請問前輩,何以教我😭 | |
# 首先澄清一點 | |
AI 雖然會寫 code 但它還是很常犯錯。 | |
因此更需要真人俱備足夠能力去分辨哪些部份可直接用、哪些是錯的要修正才能用,更多時候是七分用它的但三分要視需求改寫,因此人類本身雄厚的程式功力還是非常必要的。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# LLM 最基本元素就兩個:generation 與 prompt | |
# generation | |
就像平常在 chatgpt 上提問後它會生出答案並可一來一往多輪對話,這個過程就是 LLM generation。換成 LLM 開發時則改成用程式呼叫某家服務商提供的 LLM API 做上面一樣的事,例如最常見的是 OpenAI 的 gpt-4 或 google 的 gemini。 | |
# prompt | |
就像在 chatgpt 上提問一般,用戶下指令告訴 LLM 要執行的任務,例如摘要一篇文章。這裏 tricky 的地方在於不同的任務需要不同的 prompt 才能順利完成,而 prompt 技巧千變萬化通常要不斷試誤才能找出最有效的。 | |
簡單講只要將不同公司的 LLM 想成不同品牌的 SQL server 就行,例如 MySql 與 PostgreSQL 功能其實大同小異,執行的語法也都是 SQL 只是稍有不同,換成在 LLM 的世界裏就是彼此用的 prompt 其實差不多,只是每家可能各有些專屬文法要注意即可。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BOOK INFO | |
- 黑暗巨塔 | |
- <no_subtitle> | |
- 大衛.恩里奇 | |
# OVERVIEW |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
# goal | |
- 在不修改 node-fetch 原始參數格式下新增兩功能 | |
1. 新增 timeout 設定且逾時自動重試 | |
2. 新增 retry 模式可指定重試次數 | |
- 所有 config{} 皆有預設值因此使用上與原始 fetch() 相同 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$$('*').forEach(e => {e.style.outline = "1px solid #" + (~~(Math.random()*(1<<24))).toString(16);e.style.outlineOffset='-1px'} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// sample code copied from the blog: | |
// https://blog.axlight.com/posts/you-might-not-need-react-query-for-jotai/ | |
const idAtom = atom(1) | |
const dataAtom = atom( | |
// read | |
async (get) => { | |
const id = get(idAtom) | |
const res = await fetch(`https://reqres.in/api/posts/${id}`) | |
const data = await res.json() | |
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function foo() { | |
// throw new Error('bb') | |
return new Promise((res, rej) => { | |
setTimeout(_ => { | |
// throw new Error('bb') | |
rej('cc') | |
}, 1000) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 前情提要:async/await 只是 Promise 的語法糖 | |
// 只要精熟 Promise 則使用 async/await 就心無罣礙 | |
// 範例 1 - 錯誤示範 | |
// main 為同步執行,不會等待 forEach 內三件 async 工作完成即先結束 | |
async function async_log(time) { | |
// 模擬這支 fn 經過 300ms 後才回應,因此是非同步函式 | |
// 想像成是 fetch() 就行 | |
return new Promise((resolve, reject) => { | |
setTimeout(_ => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [ | |
['a1', 'a2'], | |
['b1', 'b2', 'b3'] | |
] | |
let result = arr.reduce( | |
// ----------- | |
// 最外層 reduce 會依序遍歷 | |
// ['a1', 'a2'] 與 ['b1', 'b2', 'b3'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fetch = require('node-fetch') | |
const fs = require('fs-extra') | |
const { execSync } = require('child_process') | |
const main = async () => { | |
const query = `nasa,cycling,surfing,underwater,swimming` | |
const size = `1` | |
const order = `latest` | |
const orientation=`landscape` | |
const photoName = 'photo.png' |
NewerOlder