Skip to content

Instantly share code, notes, and snippets.

View TheWaWaR's full-sized avatar
🌀
Focusing

LingFeng TheWaWaR

🌀
Focusing
View GitHub Profile
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
下载/增量同步某知乎用户的全部回答,并渲染成一个 Bootstrap 5 单页。
数据流(默认输出到 answers/<user>/):
answers/<user>/answers.json ← 原始数据源(每条回答的原始 API 对象;截断的存重拉后的全文)
answers/<user>/images/ ← 本地化的图片
answers/<user>/assets/ ← 本地化的 bootstrap.min.css
answers/<user>/index.html ← 由 answers.json 渲染出的单页(标题/时间/赞数/正文 + 搜索)
@TheWaWaR
TheWaWaR / parser.mbt
Last active May 15, 2025 08:04
Command Line Argument Parser for MoonBit
struct Argument {
name: String
short: Option[Char]
nargs: Nargs
positional: Bool
/// If this value is empty means not limit to those value
choices: ArrayView[String]
default: ArrayView[String]
help: String
}
@TheWaWaR
TheWaWaR / cgp.md
Created April 9, 2025 06:36 — forked from notnotrobby/cgp.md
List of free resources to study computer graphics programming.
@TheWaWaR
TheWaWaR / wasm_module.rs
Created March 20, 2025 02:54
Define wasm import module name in Rust
#[link(wasm_import_module = "lunar")]
unsafe extern "C" {
pub fn get_renderer(input_length: usize) -> i64;
}
#[unsafe(no_mangle)]
pub extern "C" fn add_u32(a: u32, b: u32) -> u32 {
unsafe {
let _ = get_renderer(33usize);
}
const std = @import("std");
const xev = @import("xev");
const Instant = std.time.Instant;
const mem = std.mem;
const net = std.net;
const posix = std.posix;
const assert = std.debug.assert;
pub fn main() !void {
@TheWaWaR
TheWaWaR / Cargo.toml
Last active October 31, 2022 02:35
Rust ckb-sdk simple transfer tutorial
[package]
name = "ckb-sdk-transfer-tutorial"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "3.1.9", features = ["derive"] }
secp256k1 = { version = "0.20", features = ["recovery"] }
@TheWaWaR
TheWaWaR / upgrade-zig.sh
Last active October 5, 2022 14:09
Download zig binary extract it and link the executable file
set -e
DEFAULT_ZIG_DIR="$HOME/local/opt"
DEFAULT_BIN_DIR="$HOME/local/bin"
URL="${1}"
ZIG_DIR="${2:-$DEFAULT_ZIG_DIR}"
BIN_DIR="${3:-$DEFAULT_BIN_DIR}"
function error() {
@TheWaWaR
TheWaWaR / README.md
Created September 2, 2022 08:26 — forked from josephg/README.md
Getting Zig compiling to WASM

In case anyone else wants to play with Zig on webassembly, here's what you need to do to make it work on a mac today.

1. Get LLVM 7 compiled with webassembly support.

You'll need LLVM to output to the WASM target. This has just been added by default in trunk, so if LLVM >7 is available, you might be able to just brew install llvm.

If you have wasm support already you should see:

$ llc --version
@TheWaWaR
TheWaWaR / README.md
Created September 2, 2022 08:26 — forked from josephg/README.md
Getting Zig compiling to WASM

In case anyone else wants to play with Zig on webassembly, here's what you need to do to make it work on a mac today.

1. Get LLVM 7 compiled with webassembly support.

You'll need LLVM to output to the WASM target. This has just been added by default in trunk, so if LLVM >7 is available, you might be able to just brew install llvm.

If you have wasm support already you should see:

$ llc --version
## Build the contract
make all-via-docer
# - build/script-binary
# - build/script-binary.debug
## Deploy to CKB
depoly-to-ckb build/script-binary
## Error when send a transaction
ckb-cli tx send --tx-file xx.json