Skip to content

Instantly share code, notes, and snippets.

View ming900518's full-sized avatar

Ming Chang ming900518

View GitHub Profile
@ming900518
ming900518 / LeetCode 23 - Merge k Sorted Lists.md
Last active June 29, 2023 01:00
LeetCode 23 - Merge k Sorted Lists

LeetCode 23 - Merge k Sorted Lists

Rust Implementation

ListNode struct

#[derive(Debug)]
pub struct ListNode {
    pub val: i32,
    pub next: Option<Box<ListNode>>,
@ming900518
ming900518 / LeetCode 86 - Partition List.md
Last active June 28, 2023 02:47
LeetCode 86 - Partition List

LeetCode 86 - Partition List

Rust Implementation

ListNode struct and the main function for the Rust Playground

#[derive(Debug)]
pub struct ListNode {
    pub val: i32,
    pub next: Option<Box<ListNode>>,
}
@ming900518
ming900518 / AoC22D2.md
Last active July 28, 2023 05:43
Advent of Code 2022 Day 2
@ming900518
ming900518 / AoC22D1.md
Last active September 9, 2023 07:46
Advent of Code 2022 Day 1

Part 1 (Rust)

fn main() {
    let mut result = 0;
    let mut buffer = 0;
    DATA.lines().for_each(|line| {
        if line.is_empty() {
            if buffer > result {
                result = buffer;
@ming900518
ming900518 / rust_arm_cross_compile_to_x86.md
Created May 19, 2023 05:48
在 Asahi Linux(Arch Linux ARM) 中編譯 target 為 x86_64-unknown-linux-gnu 的 Rust 程式

在 Asahi Linux(Arch Linux ARM) 中編譯 target 為 x86_64-unknown-linux-gnu 的 Rust 程式

Arch Linux ARM 似乎沒有可用的 x86_64-linux-gnu-gcc

所以我額外用 Docker 模擬出 Debian 環境,並透過 Debian 的 gcc-x86-64-linux-gnu 套件進行編譯

環境準備

  1. 用 Docker 開啓執行 Debian 的 Container
@ming900518
ming900518 / commands.md
Last active May 17, 2023 01:38
解決 Arch Linux ARM 執行 yay -Syu 後 Fcitx5 Rime 無法使用的問題

解決 Arch Linux ARM 執行 yay -Syu 後 Fcitx5 Rime 無法使用的問題

yay -S capnproto
cd /usr/lib
sudo ln -s libcapnpc.so.0.10.4 libcapnpc.so.0.10.3
@ming900518
ming900518 / node-sqlite3.md
Created May 8, 2023 02:18
node-sqlite3 v.s. rusty-sqlite3
Summary:                                                                                                                                                                              
  Total:        30.0199 secs                                                                                                                                                          
  Slowest:      0.0995 secs                                                                                                                                                           
  Fastest:      0.0212 secs                                                                                                                                                           
  Average:      0.0551 secs                                                                                                                                                           
  Requests/sec: 1813.5947                                                                                
@ming900518
ming900518 / perf-result-express.md
Last active March 24, 2023 07:10
API performance benchmark with express proxied result
ezcon@ez500:~/ezmonitor$ hey -z 30s -c 100 http://localhost:1234/api/get

Summary:
  Total:	30.1203 secs
  Slowest:	0.2984 secs
  Fastest:	0.0801 secs
  Average:	0.1514 secs
  Requests/sec:	659.1560
  
@ming900518
ming900518 / rust-static-file-serving-perf-test.md
Last active March 15, 2023 07:39
Rust Static File Serving Performance Test

Rust Static File Serving Performance Test

測試參數

項目 設定
CPU 12th Gen Intel(R) Core(TM) i7-12700
Rust rustc 1.68.0 (2c8cc3432 2023-03-06) stable-x86_64-unknown-linux-gnu
檔案大小 100 MiB
測試指令 hey -z 30s -c 100 http://localhost:1370/sendfile/testfile
const fileExisted = await Result.safe(fsPromises.stat(targetDir));
if (fileExisted.isOk()) {
    fs.rmSync(targetDir, { recursive: true });
}

const mkdir = await Result.safe(
    fsPromises.mkdir(targetDir, { recursive: true }),
);
if (mkdir.isErr()) {