Skip to content

Instantly share code, notes, and snippets.

View ywwwtseng's full-sized avatar

William ywwwtseng

  • LangLive
  • Taipei, Taiwan
View GitHub Profile

Program & Process & Thread

🧾 Program(程式)

定義:一個儲存在磁碟上的靜態指令集合,通常是可執行檔(例如 .exe.out)。

特性

  • 是「還沒被執行」的程式碼。
  • 例如:你電腦上的 chrome.exe 就是一個程式,只有在你點它時才會變成 process。

OIDC、OAuth 2.0、SSO、JWT、Token、Session、Cookie 全面整理


🔐 一、OAuth 2.0(AUTH 2.0)

OAuth 2.0 是一種授權(Authorization)框架,不是用來驗證身份的(不是 Authentication),而是允許第三方應用程式代表用戶訪問資源,但不暴露用戶密碼。

📌 比喻:

你去銀行(資源伺服器)開戶,銀行要你提供身份證(Access Token),但不是你的鑰匙(密碼),這個身份證是政府(身份提供者)發給你的。

🧠 JavaScript 記憶體管理基礎:Stack vs Heap

JavaScript 引擎執行時,會使用兩種記憶體空間:

區域 說明 舉例
🧱 Stack(堆疊) 用來儲存函數的執行上下文(Execution Context)與區域變數(primitive) 呼叫函數時進入 call stack、執行完就退出
🗃 Heap(堆) 儲存物件、函數等參照型資料(reference types) 像是閉包、物件、陣列、函數本體

📌 補充說明

🌀 Event Loop Queue vs Job Queue 差異說明

項目 Event Loop Queue(Macro Task Queue) Job Queue(Micro Task Queue)
📌 又稱 Task Queue / Callback Queue Microtask Queue / Job Queue
🎯 負責處理 setTimeout、setInterval、I/O callbacks、DOM Events 等 Promise.then()、queueMicrotask()、MutationObserver
⏳ 執行時機 每輪事件循環的最後階段才會執行 每個 task 執行結束後立即清空 microtasks
🥇 優先順序 較低,等微任務執行完才會輪到它 較高,會優先執行完所有 microtasks 才會進入下一個 macro task
✅ 用途 處理整體非同步任務 處理細粒度更新、異步邏輯鏈接
del_all_branch () {
current_branch=$(git branch --show-current)
git branch | grep -Ev "^\s*(master|main|develop|dev|${current_branch})$" | xargs git branch -D
}
kill_port() {
if [ -z "$1" ]; then
echo "Usage: kill_port <port>"
return 1
fi
import { useState, useMemo } from 'react'
class ArrayUtil {
static range(...T) {
let start, end;
if (T.length === 1) {
start = 0;
end = T[0];
} else {
@ywwwtseng
ywwwtseng / easing.js
Created December 6, 2021 10:07 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: t => t,
// accelerating from zero velocity
easeInQuad: t => t*t,
// decelerating to zero velocity
在開發過程中,當需求變得龐大且模糊時,會延長開發週期,而無法在一個 sprint (2~4週) 完成,也就無法給顧客即時的回報,如果花費大量
的時間開發,最後與客戶的方向不同,會得不償失。
在 Scrum 的開發流程中,我們將需求依需求尺寸由大到小分成 Investment theme, epic, feature, user story, task.
Investment theme: 投資主題,主要定義主方向,像我們提供的 Investment theme 為教育服務,或許這個概念比較抽象,你可以把它想成 myViewBoard.com。
Epic: 顧名思義就是很長的敘事性詩篇,在 Scrum 的開發過程中,屬於 high level 的需求描述,你可以想成 myViewBoard.com 中各個
子網站,如 Start myViewBoard, myViewBoard classroom 等。
@ywwwtseng
ywwwtseng / vim_cheatsheet.md
Created December 27, 2019 07:49 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Dependency directories
node_modules/