Skip to content

Instantly share code, notes, and snippets.

@kanzure
kanzure / zerocounter.py
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
@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 decision-theory-workshop@googlegroups.com 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:

@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 / droid2png.sh
Created July 25, 2011 22:39
droid2png - capture screenshots of your android progress
#!/bin/bash
#file: droid2png.sh
#author: Bryan Bishop <kanzure@gmail.com>
#date: 2011-04-07
#license: gplv2+
#url: http://heybryan.org/
#example: http://heybryan.org/shots/2011-04-11-212956-hopper-progress.gif
if [[ "$1" == "" ]]; then echo "missing argument (output filename, .png)"; exit; fi;
@kanzure
kanzure / markdownify.md
Created August 1, 2012 23:08
testing mediawiki2markdown output

DIYbio FAQ v1.5: "The biohacker's FAQ"

The openwetware html was passed through markdownify to generate this document.

This FAQ for DIYbio is actively maintained by it's editors, and by you! Edit your contributions directly or email updates to the DIYbio email list, diybio@googlegroups.com.
Major contributors (in alphabetical order):
@kanzure
kanzure / androtyper.py
Created November 20, 2012 19:11
Fast keyboard input to Android from your development machine
#!/usr/bin/env monkeyrunner
import sys
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print "Waiting for device..."
device = MonkeyRunner.waitForConnection()
print "Getting input arguments..."
input_text = sys.argv[1]
@kanzure
kanzure / webkit-inspector-shell.coffee
Created December 22, 2012 09:53
proof of concept for a command-line interface to the webkit inspector
#!/usr/bin/env node
#
# Proof of concept for accessing the WebKit Inspector from the shell. This
# traverses the DOM and dumps the raw HTML. A more sophisticated demo might
# allow you to inject javascript into the page. Also, this works with phantomjs
# out of the box.
#
# things to install:
# google-chrome --remote-debugging-port=9222 https://gmail.com/
# npm install traverse request ws
@kanzure
kanzure / stats.py
Last active December 10, 2015 05:58
base stats dumper for pokecrystal
# http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon_base_stats_data_structure_in_Generation_II
from crystal import load_rom
from pokemon_constants import pokemon_constants
rom = load_rom()
basestats = 0x51424
len_mon = 0x20
spacing = "\t"
@kanzure
kanzure / cake.py
Created January 4, 2013 08:08
happy cake day to me?
lines = {
11: " / ; ,-, \\_> <<_' ____________;_)",
7: " | | .--| |,~~~~~| |~~~,,,,'-| |",
3: " ( Y Y ( )",
9: " .| |~ // ___ '-',,'.",
15: " | '-._ ~~,,, ,,,~~ __.-'~ | |",
13: " | ; '-'\_\/> '-._ |",
20: " \ `'==========='` .'",
2: " ( ) ( ) (",
8: " | |-,,~~'-'___ '-' ~~| |._",
@kanzure
kanzure / greasemonkey-springerlink-downloader.js
Created January 15, 2013 02:01
greasemonkey-springerlink-downloader