Skip to content

Instantly share code, notes, and snippets.

@oakwhiz
oakwhiz / dumptxoutset_to_sqlite.py
Created February 22, 2024 02:11
port of utxo_to_sqlite.go from utxo_dump_tools
#!/usr/bin/env python3
import sqlite3
import struct
from pathlib import Path
import argparse
from hashlib import sha256
from time import time
# Install these packages via pip if not already installed
from ecdsa.numbertheory import square_root_mod_prime
@oakwhiz
oakwhiz / README.md
Last active February 12, 2024 02:15
How to set up a bitcoin node on Debian using the official "hardened" systemd unit file, with external storage + testnet

How to set up a bitcoin node on Debian using the official "hardened" systemd unit file, with external storage + testnet

Disclaimer of liability & warnings

It's your responsibility to handle Bitcoin correctly, failure to do so could cause cybersecurity breaches or financial losses, which you are solely responsible for. You should change all passwords, ensure you have a good firewall configuration, keep up-to-date, only use trusted sources for software and configuration, maintain your hardware, ensure working backups and redundancies, etc. You must also double check that these documents are not outdated, malicious or tampered with. The author(s) of these documents cannot be held responsible for losses or damages arising from use or misuse of the information within.

If you are using a bitcoin node in a commercial setting, you need to think about things like redundancy, uptime and recovery. What would happen if you were relying on a single bitcoin node and it went down? How long will it last if you "set it

# START
from mpmath import mp
import numpy as np
import matplotlib.pyplot as plt
import cmath
# Set the desired precision
mp.dps = 50
# Define the angles of the fundamental domain
@oakwhiz
oakwhiz / router.cfg
Last active January 10, 2023 11:14 — forked from marfillaster/router.cfg
[For reference only] MikroTik RouterOS v7 dual DHCP WAN recursive failover w/ PCC load-balancing; and recursive ECMP
# jul/28/2022 00:34:21 by RouterOS 7.4rc2
# incomplete config, do not use directly
/ip firewall address-list
add address=192.168.88.0/24 list=local
add address=192.168.88.0/24 list=preferprimary
add address=1.2.3.0/24 list=localnet-primary
add address=4.5.6.0/24 list=localnet-backup
add address=9.9.9.10 list=reserved-main
add address=9.9.9.11 list=reserved-isp1
@oakwhiz
oakwhiz / gist:ec1ef551f889c4db2708
Last active August 29, 2015 14:17
A failed attempt to hide the console in Windows.
#![feature(thread_sleep, std_misc)]
extern crate winapi;
extern crate "kernel32-sys" as kernel32;
extern crate "user32-sys" as user32;
fn main() {
println!("About to hide the console.");
sleep(1);
unsafe {
@oakwhiz
oakwhiz / disk_cache_script.bat
Last active August 29, 2015 14:10
read folder into windows disk cache (simple one-liner)
REM precache files into windows disk cache
REM first argument should be the name of a folder
REM all the files will be recursively copied to nul in order to put them in the disk cache
FOR /R %1 %%F IN (*) DO copy /b "%%F" nul
@oakwhiz
oakwhiz / layer2-ssh-tun.sh
Last active August 29, 2015 14:06
Tunnel SSH over Layer 2 Ethernet (rough sketch)
#!/bin/sh
# Tunnel SSH over Layer 2 Ethernet (rough sketch)
# requires FIFOs, netcat, linkcat
testfun () {
read line
nc "${@}" < <(echo $line ; cat)
}
@oakwhiz
oakwhiz / simulationcombinator.hs
Last active August 29, 2015 14:06
Simulation combinator - iterates from a starting point toward a fixed point.
-- Simulation combinator.
-- If (f x /= x) then try f f x, f f f x, etc.
-- Keeps chaining f until nothing new happens, i.e. the simulation has "settled"
-- Similar to the fixed point combinator but with a starting condition.
simC :: Eq a => (a -> a) -> a -> a
simC f x | f x == x = x | otherwise = simC f (f x)
-- Same as above, but keeps a list of the intermediate states.
-- let simCList :: Eq a => (a->a) -> [a] -> [a]; simCList f x | f (last x) == (last x) = x | otherwise = simCList f (x ++ [f (last x)])
simCList :: Eq a => (a -> a) -> [a] -> [a]
@oakwhiz
oakwhiz / primes.hs
Last active August 29, 2015 14:05
thanks to lspitzner pointing out my simple mistake, this is now a fully working program that generates primes using a method described in GEB
module Main where
import Data.List (nub, (\\))
import Data.Maybe (mapMaybe, catMaybes)
import Control.Applicative
import Debug.Hood.Observe
@oakwhiz
oakwhiz / dirtree-compare-plusfiles.sh
Last active August 29, 2015 14:04
Bash script to compare two directory trees, including the files, without actually comparing the content of the files themselves.
find "$2" -printf "%P\n" | sort | diff - <(find "$1" -printf "%P\n" | sort)