Skip to content

Instantly share code, notes, and snippets.

View hsqStephenZhang's full-sized avatar
🎯
Focusing

z combinator hsqStephenZhang

🎯
Focusing
View GitHub Profile
@frroossst
frroossst / queen.rs
Created November 15, 2025 16:02
N queen problem in the Rust type system
#! /usr/bin/env -S cargo +nightly -Zscript
---
[package]
edition = "2024"
[dependencies]
---
#![recursion_limit = "1024"]
use std::marker::PhantomData;
@novafacing
novafacing / RUST_OPTION_RESULT_CONVERSIONS.md
Created October 17, 2023 23:13
Rust Option/Result conversion functions

I used to have a site bookmarked with a table of all these functions, but the link is dead. Here's a matrix of Option and Result conversion functions. These become second nature once you have used Rust for any significant length of time, but it's useful to have a table reference.

For each of the below:

  • T is the value possibly contained in an input Ok Result or Some Option.
  • U is a new value created by transforming or replacing an input T. Note that when U appears in methods like map, U ?= T, for example by calling
{
"type": "hysteria",
"tag": "hysteria-out",
"server": "SERVER-IP-ADDRESS",
"server_port": 8443,
"up_mbps": 500,
"down_mbps": 500,
"auth": "8JCsPssfgS8tiRwiMlhARg==",
"auth_str": "upiTU?rUW3+4e6Radro",
"disable_mtu_discovery": false,
@hsqStephenZhang
hsqStephenZhang / gist:5620b89314c49b22b3d8dc402af54229
Created January 20, 2022 04:48
linux objdump certain function
#!/bin/sh
routine=$1
func=$2
if [ -z "$routine" ]; then
exit
fi
start=$(nm -n $routine | grep "\w\s$func" | awk '{print "0x"$1;exit}')
@sts10
sts10 / rust-command-line-utilities.markdown
Last active March 14, 2026 17:33
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note: I have moved this list to a proper repository. I'll leave this gist up, but it won't be updated. To submit an idea, open a PR on the repo.

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, fd, fend, hyperfine, miniserve, ripgrep, just, cargo-audit and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
@grahamking
grahamking / main.rs
Created June 5, 2021 00:00
Memory ordering experiment in Rust. See https://preshing.com/20120515/memory-reordering-caught-in-the-act/ . Try changing the two HERE lines.
// 1. Run it as is (SeqCst). Should be just timing output
// 2. Change the two HERE lines to Ordering::Relaxed and run it again.
// That should give lots of (seemingly impossible) memory reorderings.
use rand;
use std::sync::atomic::{AtomicU8, Ordering};
use std::sync::*;
use std::thread;
fn main() {
@apivovarov
apivovarov / riscv-debian.md
Last active March 5, 2026 17:17
Run RISC-V Debian via QEMU #riscv #qemu

Run RISC-V Debian GNU/Linux bullseye/sid via QEMU.

  1. Run the latest version of Debian on regular x86_64 box (at least ver 10 Buster, better to run ver 11 Bullseye)
  2. If opensbi and u-boot-qemu packages are not found add testing apt repository (aka bullseye). Or even unstable (aka sid)
sudo vi /etc/apt/sources.list

# Add testing repo (or unstable)
deb http://cdn-aws.deb.debian.org/debian testing main
deb-src http://cdn-aws.deb.debian.org/debian testing main
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active December 27, 2025 05:35
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

@MattPD
MattPD / analysis.draft.md
Last active February 22, 2026 07:22
Program Analysis Resources (WIP draft)

##分布式系统(Distributed System)资料


#####希望转载的朋友,你可以不用联系我.但是一定要保留原文链接,因为这个项目还在继续也在不定期更新.希望看到文章的朋友能够学到更多.

介绍:这是一篇介绍在动态网络里面实现分布式系统重构的paper.论文的作者(导师)是MIT读博的时候是做分布式系统的研究的,现在在NUS带学生,不仅仅是分布式系统,还有无线网络.如果感兴趣可以去他的主页了解.