Skip to content

Instantly share code, notes, and snippets.

kanzure /
Created March 27, 2022 01:36
Webcash merchant demo using python/flask
A small Flask web application to demonstrate a shopping cart with simple checkout.
This file was written mostly by Github Co-pilot!
Only the webcash API endpoint was specialized knowledge.
import secrets
import datetime
import json
kanzure /
Last active September 25, 2021 12:56
Split an irssi IRC log file into multiple files (by date)
#author: Bryan Bishop <>
#date: 2010-03-16
#updated: 2020-02-10
from datetime import datetime
strptime = datetime.strptime
logs = open("irclogs.txt", "r").read().split("\n")
LOG_OPENED = "--- Log opened "
kanzure /
Last active July 15, 2020 02:21
tool for timestamping IRC logs
This file creates opentimestamps timestamps for daily IRC logs. It works when
running on a daily basis (called from a cronjob) or when called manually with
multiple days since the last run.
The script will identify all new log files and create timestamps for those new
kanzure / blstoy.cpp
Created April 3, 2017 01:09
Short attempt at verifying an aggregate signature using BLS and a single pubkey
#include <iostream>
#include "bls.h"
int main() {
std::cout << "Signature aggregation toy attempt\n";
// create instance of Bls class
bls::Bls my_bls = bls::Bls();
kanzure /
Last active August 23, 2016 03:40
Find the most recent common block between two different, partially synchronized blockchain data stores. Attempt to do so without calling the _batch RPC call for 500,000 getblockhash requests. See
Toy demo for finding the most recent common block between a database and a
bitcoind instance. The goal is to correctly handle reorgs and long periods of
downtime if any. The previous implementation used getblockhashes and the _batch
RPC call to get 300,000 blockhashes at a time. Unfortunately bitcoind is not
really made to handle requests of that size. Instead, here is a more optimized
implementation that should take less time and a minimal number of RPC requests.
The output of this is fed into a planner which generates a plan for processing
the blocks between a current blockhash and the last most recent common block.
kanzure /
Created February 13, 2016 17:12
Unexpected docker build cache miss after successful --no-cache
git checkout master # setup Dockerfile
docker-compose build # uses cache (expected)
git checkout HEAD^1 # removes some line from Dockerfile
docker-compose build # uses cache (expected)
git checkout master # adds back same line to Dockerfile
docker-compose build --no-cache # does not use input from the cache (expected)
git checkout HEAD^1 # removes same line from Dockerfile
docker-compose build # has unexpected cache miss
kanzure /
Created November 21, 2015 19:25
hplusroadmap irc log visualization
Render an image of the "text mass" per minute per day of logs. Horizontal
minutes against vertical days. The color of each pixel represents the relative
text mass for that time slice (that minute).
1440 minutes/day
2555 days
1440 * 2555
kanzure / replication-steps.txt
Created July 17, 2015 19:03
Replication of RPC thread hanging using bitcoind v0.10.2.0-g16f4560
# start bitcoind in regtest mode
# ... set the following parameters:
# -rpcthreads=1 -rpctimeout=5
# The behavior can be seen more readily with rpcthreads=1.
bitcoind -regtest -rcpthreads=1 -rpctimeout=5 -debug=1 -logtimestamps=1 -printtoconsole=1 -server=1 -listen=1 -maxconnections=500 -txindex=1
# NOTE: Also, alertnotify and blocknotify scripts are being executed, although
# they don't seem to be necessary to trigger this behavior?
# using python-bitcoinlib in python3.4, although python-bitcoinrpc or even bitcoin-cli might work for this
kanzure /
Created April 13, 2015 18:13
Prototype: stochastic cooperation in the One-Shot Prisoner's Dilemma in probabilistic programming

(The following is from an email that was received on the mailing list...)

Well, I finally managed to sit down and code the entire prototype. This has been refined a couple times and tested via the Church play-space ( The parameters and set-up can probably use some tweaking to make the cooperation more robust (ie: more probable/numerous as a fraction of the histogram used for testing), but oh well.

The paper follows the Goodman & Tenenbaum approach of "commonsense reasoning as conditional simulation (in probabilistic generative models)". Each agent simulates:

  • The other agent simulating it,
  • Simulating the other agent playing naively.

So the recursion levels are:

kanzure /
Created March 19, 2015 13:56
Get better at visually distinguishing between varying length sequences of zeros.
Small program to help develop the ability to count the number of zeros in a
number very quickly.
An upgrade to this would be the following: Randomly generate a number with
multiple long repeating sequences of integers. Then ask the user for the length
of the longest repeating sequence within the number.
import random