Skip to content

Instantly share code, notes, and snippets.

View jimmychu0807's full-sized avatar
🎯
Focusing

Jimmy Chu jimmychu0807

🎯
Focusing
View GitHub Profile
@jimmychu0807
jimmychu0807 / why-startup.md
Last active April 6, 2017 15:31
點解要攞苦來辛,自己搞 startup?

打工每月有4/5 萬人工。收入較穩定,工時較穩定。少些煩心,憂心事。

點解要攞苦來辛,自己搞 startup?

  • 我其中一個最大價值在於靈活性,自覺是複合型人才,會走位,有權變。打工講專才。做工程師,很多時就只有寫 code. 商務人就要吹水交際去 conf,不同社交場合。好少見到複合型人才,可在工作崗位允許隨機應變,隨所遇而施之。要到這境界,要遇到好老闆,並且他相信你。今時今日,難。

  • 唔想被蠢過自己的上司指東指西,執行一些無聊頂透的指令。也不想和只拿薪金,無擔當的人一起工作。職場上遇到他們,如在打工,我只能消極避開。自己開公司,可選擇和一流的人才工作。

  • 唔想俾人用 4/5萬月薪豢養起來。唔通我就係咁要安全感?就咁唔敢冒險?不時想起秦末起義,聯軍在黃河一邊,無人敢進攻秦國。項羽等到不耐煩,終於等了47天,見自己上司也無意進攻,早上起來進營中殺了上司宋義,奪兵權,然後帶領楚軍,破釜沉舟,只帶三天糧食過河,與秦軍決一死戰。然後楚軍以一當十。最後楚軍大敗秦軍,史稱 鉅鹿之戰。當其時,其他諸侯還只敢作壁上觀,不敢參與其中。遙想當年項羽真英雄也。說到㡳,我還想用自己雙手打出一片天。

@jimmychu0807
jimmychu0807 / introrx.md
Created February 19, 2019 12:00 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@jimmychu0807
jimmychu0807 / openssl.md
Created September 2, 2019 03:58 — forked from NoMan2000/openssl.md
Common OpenSSL Commands with Keys and Certificates

Common OpenSSL Commands with Keys and Certificates

SSL Info

Generate RSA private key with certificate in a single command

openssl req -x509 -newkey rsa:4096 -sha256 -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650 -passout pass:foobar

Generate Certificate Signing Request (CSR) from private key with passphrase

openssl x509 -x509toreq -in example.crt -out example.csr -signkey example.key -passin pass:foobar

@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@jimmychu0807
jimmychu0807 / 0_General_Instructions.md
Created December 16, 2019 07:19 — forked from shawntabrizi/0_General_Instructions.md
Sub 0.1 Workshop Setup Instructions

General Instructions

Most workshops at Sub0 will require that you have set up your computer to compile Substrate.

You can use this one-liner to do many of these steps for you automatically:

curl https://getsubstrate.io -sSf | bash -s -- --fast
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 11:58
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// babe 組件內的常量
console.log(api.consts.babe.epochDuration.toNumber());
// balances 組件內的常量
console.log(api.consts.balances.creationFee.toNumber());
console.log(api.consts.balances.transferFee.toNumber());
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 11:58
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 從 mnemonic 來生成,建議方法:
const PHRASE = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought';
const newPair = keyring.addFromUri(PHRASE);
// 只限開發時使用,即運行 Substrate 節點時加了 `--dev` 參數:
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
// 用 32 位的 16 進制數字生成
const hexPair = keyring.addFromUri('0x1234567890123456789012345678901234567890123456789012345678901234');
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 11:58
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
const unsub = await api.queryMulti([
// 一個 getter function
api.query.timestamp.now,
// 另一個 getter function,及所需參數
[api.query.balances.freeBalance, ADDR],
[api.query.system.accountNonce, ADDR],
], ([now, balance, nonce]) => { // 回調函數
console.log(`${now}: balance of ${balance} and a nonce of ${nonce}`);
});
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 11:58
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 訂閱著該數值
const unsub = await api.query.balances.freeBalance(ADDR, balance => {
console.log(`balance of ${balance}`);
});
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 11:58
Markdium-用 Polkadot-JS API 輕鬆搭建 Substrate 前端
// 創建 api
// const api = await ...;
api.query.system.events(events => {
events.forEach(record => {
// 遍歷所有事件記錄
const { event, phase } = record;
const types = event.typeDef;
// 過濾掉我們不關注的事件