Skip to content

Instantly share code, notes, and snippets.

@stonegao
stonegao / gist:a1d2c44814e6ab9689dc3ba712f4b453
Created November 28, 2023 03:05 — forked from levelsio/gist:5bc87fd1b1ffbf4a705047bebd9b4790
Secret of Monkey Island: Amsterdam (by @levelsio) or how to create your own ChatGPT image+text-based adventure game
# 2023-11-27 MIT LICENSE
Here's the open source version of my ChatGPT game MonkeyIslandAmsterdam.com.
It's an unofficial image+text-based adventure game edition of Monkey Island in Amsterdam, my home town.
Please use it however you want. It'd be nice to see more ChatGPT-based games appear from this. If you get inspired by it, please link back to my X https://x.com/levelsio or this Gist so more people can do the same!
Send me your ChatGPT text adventure game on X, I'd love to try it!
@stonegao
stonegao / EIP138128.md
Created November 6, 2023 09:16 — forked from Shungy/EIP138128.md
EIP138128: Custom selector and encodings (Very early draft)

Using LEB128 encoding scheme for custom abi/interface.

ERC-138128: Custom function selector and calldata encoding scheme declaration standard

  • A contract SHOULD use ERC-165 standard to declare its support for ERC-138128 standard.
  • A contract supporting ERC-138128 MUST have these two view functions: customSelectors() and customEncodings().

customSelectors()

This function is used to declare alternative function selectors for any number of standard function signatures. This function MUST have the following interface.

@stonegao
stonegao / nestjs.Dockerfile
Created October 10, 2023 11:24 — forked from CorneilleEdi/nestjs.Dockerfile
NestJS Dockerfile with multi-stage
FROM node:16-alpine as builder
RUN apk add curl bash
# install node-prune (https://github.com/tj/node-prune)
RUN curl -sfL https://gobinaries.com/tj/node-prune | bash -s -- -b /usr/local/bin
USER node
WORKDIR /home/node
@stonegao
stonegao / fix_exfat_drive.md
Created September 9, 2023 02:09 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@stonegao
stonegao / install_guide.md
Created June 30, 2023 03:34 — forked from teebaumcrypto/install_guide.md
lighthouse & reth install and sync mainnet ethereum

Specs

CPU

  • AMD Ryzen 9 7900X AM5, 4.70 GHz, 12-Core

RAM

  • Corsair 6000-40 Vengeance 2 x 32GB 6000 MHz (DDR5)

Nvme

  • WD Black SN850X 4 TB M.2 2280
@stonegao
stonegao / p2pk.rs
Created June 15, 2023 11:55 — forked from sgeisler/p2pk.rs
// bitcoin = "*"
// bitcoin_hashes = "*"
use bitcoin::{Address, Network, Script};
use bitcoin::util::address::Payload;
use bitcoin::util::psbt::serialize::Deserialize;
use bitcoin_hashes::{hash160, Hash};
fn main() {
let bytes: &[u8] = &[
@stonegao
stonegao / interesting_crates.md
Created May 16, 2023 11:59 — forked from vi/interesting_crates.md
List of crates that improves or experiments with Rust, but may be hard to find

Let's list here crates that enhance Rust as a language.

It not "batteries" like in stdx, but Rust-specific crates for workarounds for various missing features and experimental ideals from non-accepted/postponed RFCs, or just hacky tricks.

The list is supposed to contain (mostly) crates that are internal to Rust, not ones for making Rust deal with "external world" like other languages bindings, file formats, protocols and so on.

Primary focus should be on crates that are not easy to find by conventional means (e.g. no algorithm name, format or protocol to search for).

Note that quality of the listed crates may vary from proof-of-concept to stable-and-widely-used.

@stonegao
stonegao / Cargo.toml
Created May 16, 2023 11:59 — forked from LeoDog896/Cargo.toml
Small WebRTC-rs example
[package]
name = "rs-example"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
webrtc = "0.4.0"
tokio = { version = "1.15.0", features = ["full"] }
@stonegao
stonegao / work_queue.rs
Created May 16, 2023 11:58 — forked from NoraCodes/work_queue.rs
An example of a parallel work scheduling system using only the Rust standard library
// Here is an extremely simple version of work scheduling for multiple
// processors.
//
// The Problem:
// We have a lot of numbers that need to be math'ed. Doing this on one
// CPU core is slow. We have 4 CPU cores. We would thus like to use those
// cores to do math, because it will be a little less slow (ideally
// 4 times faster actually).
//
// The Solution:
@stonegao
stonegao / rust-server.rs
Created May 16, 2023 11:57 — forked from Vultour/rust-server.rs
TCP server in Rust
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream, Shutdown};
use std::sync::mpsc;
use std::io::BufReader;
use std::thread;
use std::str;
fn listen(tx_pipe: mpsc::Sender<u32>){
let listener = TcpListener::bind("127.0.0.1:7777").unwrap();