Skip to content

Instantly share code, notes, and snippets.

@kanzure
kanzure / pipermail-extractor.sh
Last active November 11, 2024 16:27
Use the bitcoin-dev pipermail archive and create individual files for each email, using the pipermail order for counting. This should create an identical mapping between URLs from lists.linuxfoundation.org and the actual emails. I use this mapping on gnusha.org/url for the redirect service. Try using https://gnusha.org/url if you need redirect s…
#!/bin/bash
#
# Used for processing the mbox files found in:
# https://diyhpl.us/~bryan/irc/bitcoin/bitcoin-dev/bitcoin-dev-ml-archive.2024-02-09-004.tar.gz
#
# Why?
#
# Linux Foundation has deprecated lists.linuxfoundation.org, and now we need a url rewriting map
# for the pipermail archive to numbered email files.
#
@kanzure
kanzure / merchantcash.py
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
kanzure / split_log.py
Last active September 25, 2021 12:56
Split an irssi IRC log file into multiple files (by date)
#!/usr/bin/python
#author: Bryan Bishop <[email protected]>
#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
kanzure / timestamper.py
Last active July 15, 2020 02:21
tool for timestamping IRC logs
"""
Timestamps!
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
logfiles.
@kanzure
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
kanzure / find-most-recent-common-block.py
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 https://botbot.me/freenode/bitcoin-core-dev/2016-04-28/?msg=65077020&page=3
"""
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
kanzure / unexpected-docker-build-cache-miss.md
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
kanzure / textmass.py
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).
http://gnusha.org/logs/graphs/300-days-anycolor-heatmap-cropped-sorted.png
1440 minutes/day
2555 days
1440 * 2555
@kanzure
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
kanzure / README.md
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 [email protected] 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 (https://probmods.org/play-space.html). 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: