Skip to content

Instantly share code, notes, and snippets.

@stonegao
stonegao / docker_ufw_setup.sh
Created September 12, 2024 13:49 — forked from rubot/docker_ufw_setup.sh
easy fix for DOCKER-USER and ufw
#!/usr/bin/env bash
set -eu
# Solves the problem with open ports with docker and ufw
# As Docker uses the nat table, the filter table FORWARD chain is used and does not touch ufw-input chains as expected.
# Even for ufw-forward chains it would not work, as DOCKER chains are inserted in front.
# This is a simple fix that worked for me.
# https://github.com/moby/moby/issues/4737#issuecomment-420264979
# Unfortunately this fix stops forwarding users origin ip to host mode configured service
@stonegao
stonegao / main.rs
Created July 16, 2024 04:48 — forked from mayakerostasia/main.rs
Rust Message bus
#![allow(unused)]
use std::collections::HashMap;
use std::collections::VecDeque;
use std::thread::JoinHandle;
use tokio::sync::Mutex; use std::sync::Arc;
type MessageQueue = VecDeque<Message>;
type MailboxMap = HashMap<String, MessageQueue>;

A Proof of Liabilities Scheme for Ecash Mints

Abstract: In this document, I will outline a proof-of-liabilities (PoL) scheme for ecash systems and Cashu specifically, which is a Chaumian ecash system for Bitcoin. The PoL scheme consists of three parts. First, a publicly auditable list of all issued ecash tokens in the form of mint proofs, and second, a publicly auditable list of all redeemed ecash tokens in the form of burn proofs, which are both regularly published by the mint operator. Third, a mint publicly commits to rotate its keys regularly once each epoch and allows all ecash in circulation to recycle from old epochs to the newest one. If clients remain vigilant and mints agree on a certain set of rules of operation which are publicly verifiable, users of a mint can detect whether a cheating mint has printed unbacked ecash during a past epoch, and, in many cases, provide public proofs of the mint engaging in this adversary behavior. Users achieve this by regularly checking t

@stonegao
stonegao / coinswap-design.md
Created April 26, 2024 04:37 — forked from chris-belcher/coinswap-design.md
Design for a CoinSwap Implementation for Massively Improving Bitcoin Privacy and Fungibility

Design for a CoinSwap Implementation for Massively Improving Bitcoin Privacy and Fungibility

25/5/2020

Abstract

Imagine a future where a user Alice has bitcoins and wants to send them with maximal privacy, so she creates a special kind of transaction. For anyone looking at the blockchain her transaction appears completely normal with her coins seemingly going from address A to address B. But in reality her coins end up in address Z which is entirely unconnected to either A or B.

Now imagine another user, Carol, who isn't too bothered by privacy and sends her bitcoin using a regular wallet which exists today. But because Carol's transaction looks exactly the same as Alice's, anybody analyzing the blockchain must now deal with the possibility that Carol's transaction actually sent her coins to a totally unconnected address. So Carol's privacy is improved even though she didn't change her behaviour, and perhaps had never even heard of this software.

@stonegao
stonegao / closeAuxAccount.ts
Created April 26, 2024 02:27 — forked from Henry-E/closeAuxAccount.ts
Close aux token account
import * as anchor from "@coral-xyz/anchor";
import { PublicKey, Transaction, ComputeBudgetProgram } from "@solana/web3.js";
import * as token from "@solana/spl-token";
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
// Assumes your running with `anchor run closeAux --provider.cluster mainnet --provider.wallet ~/.config/solana/your-key.json`
const payer = provider.wallet["payer"];
@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