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 / 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 / semaphore-v4-ceremony_attestation.log
Created June 16, 2024 08:49
Attestation for Semaphore V4 Ceremony MPC Phase 2 Trusted Setup ceremony
Hey, I'm jimmychu0807-898091 and I have contributed to the Semaphore V4 Ceremony.
The following are my contribution signatures:
Circuit # 1 (semaphorev4-1)
Contributor # 136
Contribution Hash:
02b0bc08 ee92a2a8 c030b5fb c2059263
36c4f5c9 210366d3 044c958d 64fea3f9
88a4debe a73b7ee5 03e8c38a 1c2bc722
42b93baa 956c6ca4 e148becf 30491f59
@jimmychu0807
jimmychu0807 / self-signed-certificate-with-custom-ca.md
Created November 3, 2020 06:04 — forked from fntlnz/self-signed-certificate-with-custom-ca.md
Self Signed Certificate with Custom Root CA

Create Root CA (Done once)

Create Root Key

Attention: this is the key used to sign the certificate requests, anyone holding this can sign certificates on your behalf. So keep it in a safe place!

openssl genrsa -des3 -out rootCA.key 4096
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
useEffect(() => {
let unsubscribe;
api.query.templateModule.something(newValue => {
// The storage value is an Option<u32>
// So we have to check whether it is None first
// There is also unwrapOr
if (newValue.isNone) {
setCurrentValue('<None>');
} else {
setCurrentValue(newValue.unwrap().toNumber());
@jimmychu0807
jimmychu0807 / Markdium-Shell.bash
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
# -- ๅฎ‰่ฃ NodeJS v12 (https://nodejs.org/en/download/),
# ๅŠ yarn ๅทฅๅ…ท (https://classic.yarnpkg.com/en/docs/install)
# -- ไธ‹่ผ‰ Substrate ๅ‰็ซฏๆจก็‰ˆไธฆ่ท‘่ตทไพ†
cd ..
git clone https://github.com/substrate-developer-hub/substrate-front-end-template front-end-template
cd front-end-template
yarn install
yarn start
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
api.tx.my_pallet.dispatch_call(params).signAndSend(accountPair, ๅ›ž่ชฟๅ‡ฝๆ•ธ)
@jimmychu0807
jimmychu0807 / Markdium-JSON.json
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
{
"PROVIDER_SOCKET": "ws://<ไฝ ็š„ ws/wss ๅœฐๅ€>"
}
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
let unsubscribe;
api.query.templateModule.something(function(val) {
// ๅ›ž่ชฟๅ‡ฝๆ•ธ
// ๅœจ้€™่ฃก่จญ็ฝฎ UI ้‡Œไฝฟ็”จ็š„่ฎŠ้‡ใ€‚
}).then(unsub => {
//ๅ–ๆถˆ่จ‚้–ฑๅ‡ฝๆ•ธ
unsubscribe = unsub;
})
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
import { useSubstrate } from './substrate-lib';
import { TxButton } from './substrate-lib/components';
//...
function main (props) {
//...
return (
<Grid.Column>
<h1>Template Module</h1>
@jimmychu0807
jimmychu0807 / Markdium-javascript.js
Created March 4, 2020 12:06
Markdium-็”จ Substrate Front-end Template ่ผ•้ฌ†ๆ‰“้€ ไฝ ็š„ React ๆ‡‰็”จ
{
//ๅค–้ƒจไบคๆ˜“ๅ‡ฝๆ•ธ
// ้€™ๅ€‹ๅƒ็œ‹ๅ›ž `pallet/template/src/lib.rs` ็š„ๅๅญ—
tx: api.tx.<ๆจกๅกŠๅๅญ—>.<extrinsic ๅๅญ—>
//ๅค–้ƒจไบคๆ˜“ๅ‡ฝๆ•ธ็š„่ผธๅ…ฅๅƒๆ•ธๆ•ธ็ต„
params: [...]
}