Skip to content

Instantly share code, notes, and snippets.

View weihanglo's full-sized avatar

Weihang Lo weihanglo

View GitHub Profile
@weihanglo
weihanglo / rust-vs-go.md
Last active April 21, 2024 01:24
【譯】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!


@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 / rustconf-2019-1.md
Last active January 25, 2024 10:18
RustConf 2019 雲參訪錄(1)

RustConf 2019 雲參訪錄(1)

RustConf 是 Rust 社群年度最重要的研討會之一,從 [Rust 在 2015 年 1.0 版正式發布][rust-1.0]之後,[2016][2016]、[2017][2017]、[2018][2018] 連續三年都在美國舉辦,今年當然不例外,八月底在 NBA 球迷稱作 Rip City 的波特蘭舉行。由於歷史悠久,加上 Rust 社群在美國較為活躍,許多 Rust Core Team 成員都會共襄盛舉,這場研討會是 Rust 開發者絕對不能錯過的盛事。

RustConf 歷年來皆由 [Tilde Inc.][tilde] 旗下的 [Skylight][skylight] 主辦,Skylight 是一個 Rails profiler in production 的解決方案,產品中關鍵的模組用了不少 Rust。

好了,介紹完背景,這篇文章主要是紀錄小弟我「在 YouTube 上」觀看演講的心得分享,當然,RustConf 除了主要的演講軌,還有不少場邊工作坊等小活動,這就留給看倌明年到實地考察啦!

@weihanglo
weihanglo / carthage-intro.md
Last active January 9, 2024 06:54
Carthage 簡介

Carthage

[Carthage][carthage] 是一個較新的 Cocoa 開發第三方套件管理工具,相較於知名 [CocoaPods][cocoapods] 管理工具的複雜配置,輕巧的 Carthage 在推出之後廣受 Swift 社群喜愛。

本文基於 Carthage 0.20: Unary, Binary, Ternary

特色

  • 時代潮流:Written in Swift! (v.s. CocoaPods in Ruby)
  • 主流現代:iOS 8+, dynamic framework only
@weihanglo
weihanglo / thoughts-on-react-native-from-an-ios-developer.md
Last active August 2, 2023 16:51
Thoughts on React Native from an iOS developer

Thoughts on React Native from an iOS developer

React Native

About two month ago, I started making a React Native app ["PyConTW 17"][pycontw-mobile] for the biggest annual Python conference in Taiwan ([PyCon Taiwan][pycontw]). The app is quite simple, but still took some efforts for me to build. As a complete React newbie, I would like to share some of my thoughts about React Native.

(written on 2017-07-30, based on React Native 0.44.2)

@weihanglo
weihanglo / draw_gradient_pillow.py
Last active June 15, 2023 04:10
Draw gradient color with Pillow
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw
im = Image.open('img_original.png')
def interpolate(f_co, t_co, interval):
det_co =[(t - f) / interval for f , t in zip(f_co, t_co)]
for i in range(interval):
@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 / days-with-internet-explorer.md
Last active January 11, 2022 09:39
與 IE 相處的日子

與 IE 相處的日子

近幾年來,JavaScript 可謂風生水起,從後端到前端,從 mobile 到 desktop,各種 module 滿天飛,信手拈來就是一個 web app。不過,「沒碰過 IE,別說你會做前端」,本人從超新手的角度出發,整理最近修正 IE 相容性遇到的坑與解法,給自己日後留個參考。

(撰於 2017-07-15,基於 IE 11/Edge 15)

Contents

@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)

@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