Skip to content

Instantly share code, notes, and snippets.

View weihanglo's full-sized avatar

Weihang Lo weihanglo

View GitHub Profile
@weihanglo
weihanglo / .editorconfig
Created August 16, 2017 17:03
Editorconfig for web development
# http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@weihanglo
weihanglo / binary-data-manipulations-in-javascript.md
Last active December 2, 2021 05:47
Binary Data Manipulations in JavaScript

使用 JavaScript 處理二進位資料

由於高度封裝與抽象,JavaScript 的執行效率比不上 C 的語言。例如 JavaScript 的 Array 下標(subscript)是根據 hash key 而非實體記憶體位址 offset 取值,雖然方便,卻多了效能開銷。當 Canvas、WebGL、WebVR 開始走紅,效能越來越受重視,如何讓 JavaScript 達到如同 C 指標般操作 binary data 變得至關重要。

存在許久但最近才變為 ES6 標準「Typed Array」就是解放 JavaScript 操作 binary data 能力的好工具!一起來了解 Typed Array 吧!

(撰於 2017-09-03,基於 ECMAScript 6+,Node.js 8.3)

I/O Redirection 常用指令紀錄

greptrsedawk 是幾個很常見的標準串流 [Standard Streams][1] 處理工具,靠著regex的加持,這些工具使用在 I/O redirection 比起寫個python script快多了,唯一的壞處就是options太多,容易遺忘。本文主要紀錄上述工具使用筆記與心得。

(撰於 2016 年年初,致青春)

sed

sedStream EDitor 的縮寫,最常用來處理pipeline。特色是一次只讀取一行input到buffer處理,導向至「標準輸出(STDOUT)」後,再處理下一行。

@weihanglo
weihanglo / how-is-new-terminal-in-vs-code-so-fast.md
Last active October 27, 2021 02:18
How Is New Terminal In VS Code So Fast?

Last week, a new version (1.17) of Visual Studio Code was released. While there are many fascinating improvements and features introduced, the one that cought my eyes is "Integrated Terminal performance" section. Let's check out what they've done!

(written on 2017-10-12, based on Xterm.js v3, VS Code 1.17)

Old Performance Issue

@weihanglo
weihanglo / openssl-cheatsheet.sh
Last active December 5, 2020 02:01
OpenSSL CheatSheet
# Create X509 self-signed certificate.
openssl req \
-newkey rsa:2048 -nodes -keyout cert.key \
-x509 -days 365 -out cert.pem
# Convert from PEM format to DER.
openssl pkcs12 \
-inkey cert.key -in cert.pem \
-export -out cert.pfx
@weihanglo
weihanglo / days-with-internet-explorer-2.md
Last active February 3, 2020 06:20
與 IE 相處的日子二:淺談網頁相容性

與 IE 相處的日子二:淺談網頁相容性

還記得之前整理的 [IE 相容性][days-with-internet-explorer] 一文嗎?筆者最近參與公司新版 Web App 架構規劃與開發,又遇到許多相容性的問題,連新版瀏覽器也無法倖免。就讓我們再次探討瀏覽器相容性吧!

(撰於 2017-12-09,基於各種莫名其妙的狀況)

@weihanglo
weihanglo / tokio-internals.md
Last active March 14, 2024 15:48
【譯】Tokio 內部機制:從頭理解 Rust 非同步 I/O 框架

本文譯自 [Tokio internals: Understanding Rust's asynchronous I/O framework from the bottom up][tokio-internals]。
Thanks [David Simmons][david-simmons] for this awesome article!

[Tokio][tokio] 是 Rust 的開發框架,用於開發非同步 I/O 程式(asynchronous I/O,一種事件驅動的作法,可實現比傳統同步 I/O 更好的延伸性、效能與資源利用)。可惜的是,Tokio 過於精密的抽象設計,招致難以學習的惡名。即使我讀完教程後,依然不認為自己充分內化這些抽象層,以便推斷實際發生的事情。

從前的非同步 I/O 相關開發經驗甚至阻礙我學習 Tokio。我習慣使用作業系統提供的 selection 工具(例如 Linux epoll)當作起點,再轉移至 dispatch、state machine 等等。倘若直接從 Tokio 抽象層出發,卻沒有清楚了解 epoll_wait() 在何處及如何發生,我會覺得難以連結每個概念。Tokio 與 future-driven 的方法就好像一個黑盒子。

@weihanglo
weihanglo / 4-podcasts-software-engineers-may-love.md
Last active March 31, 2021 12:07
4 Podcasts Software Engineers May Love

4 Podcasts Software Engineers May Love

Image by Nick Youngson CC BY-SA 3.0

As a non-native English speaker, I often try several methods to improve my English skills. Listening to podcasts is one of the most interesting way to practice English, especially with fascinating topics I indulge in.

Therefore, I pick some of my favorite podcasts about software engineering to share with you. Enjoy these awesome shows and don't forget to give them some feedback.

@weihanglo
weihanglo / rust-vs-go.md
Last active April 28, 2024 01:21
【譯】Rust vs. Go

【譯】Rust vs. Go

本文譯自 Julio Merino 2018 年七月撰寫的 Rust vs. Go 一文。Julio Merino 是 G 社僱員,在 G 社工作超過 8 年,無論工作內外,都接觸開發不少 Go 語言,並撰寫 [Rust 點評][rust-review]系列文,來聽聽他對 Rust 與 Go 的想法吧。

Thanks Julio Merino for this awesome article!


Keybase proof

I hereby claim:

  • I am weihanglo on github.
  • I am weihanglo (https://keybase.io/weihanglo) on keybase.
  • I have a public key whose fingerprint is 7D84 EA07 47C1 240C 2A16 D2A6 D7DB F189 825E 82E7

To claim this, I am signing this object: