diff --git a/bcinflationchart/bcinflation.pl b/bcinflationchart/bcinflation.pl new file mode 100755 index 0000000..8a01131 --- /dev/null +++ b/bcinflationchart/bcinflation.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# 3456789#123456789#123456789#123456789#123456789#123456789#123456789#123456789# +# bcinflation.pl 20101228 jeffrey paul +# 5539 AD00 DE4C 42F3 AFE1 1575 0524 43F4 DF2A 55C2 # please sign! + +use strict; +use warnings qw( all ); +use LWP::Simple; +use Data::Dumper; +use HTML::Strip; +use DateTime; + +# thanks to nullvoid for historical block data +my $historyurl = 'http://nullvoid.org/bitcoin/difficultiez.php'; +my $growthfactor = 1.0; + +main(); + +sub main { + my $hist = fetch_history_data() or die "unable to fetch history!"; + my $block = 0; + my $totalbc = 0; + my $perblock = 50; + my $at = 1231006505; # block zero timestamp + while ($block < 1500000) { # arbitrary + $block++; + $perblock /= 2 unless $block % 210000; + $at += 60*10/$growthfactor; # estimate block timestamp + # replace with real data if we have it: + $at = $hist->{$block} if exists($hist->{$block}); + $totalbc += $perblock; + if ($block == 210000) { + print ts2nice($at); + die; + } + unless($block % 21000) { + print ts2nice($at) . ","; + print $block . ","; + print $perblock . ","; + print $totalbc. ","; + print "\n"; + } + } +} + +sub ts2nice { return DateTime->from_epoch( epoch => shift() )->ymd; } + +sub fetch_history_data { + my $raw = get($historyurl) or die "derp: $!"; + + my $clean = HTML::Strip->new()->parse($raw); + $clean =~ s/Block/\nBlock/g; + my $out = {}; + foreach my $l (split(/\n+/,$clean)) { + next unless $l =~ /^Block\s+([0-9]+)\s+was.*at\s+([0-9]+).*Difficulty\:\s+([0-9\.]{3,10}).*$/; + $out->{$1} = $2; + } + return unless $out->{98784}; + return $out; +} + +1; +__END__ diff --git a/bitcoin.blockchain/test.py b/bitcoin.blockchain/test.py new file mode 100755 index 0000000..8cb9ea7 --- /dev/null +++ b/bitcoin.blockchain/test.py @@ -0,0 +1,14 @@ +#!/usr/bin/python2.6 + +import sys +import bsddb + +bitcoin_dir = "%s/Library/Application Support/Bitcoin/" % os.environ['HOME'] + +def main(argv): + d = bsddb.btopen("%s/blkindex.dat" % bitcoin_dir) + + print d.keys() + +sys.exit(main(sys.argv)) + diff --git a/bitcoin.shallow/generate.py b/bitcoin.shallow/generate.py new file mode 100755 index 0000000..0b5e59e --- /dev/null +++ b/bitcoin.shallow/generate.py @@ -0,0 +1,19 @@ +#!/usr/bin/python2.6 + +import urllib +import sys +import json +import decimal + +def main(argv): + current = fetch_mtgox_orders() + +def fetch_mtgox_orders(): + url = 'https://mtgox.com/code/data/getDepth.php' + parsed = json.loads( + urllib.urlopen(url).read(), + parse_float=decimal.Decimal + ) + print repr(parsed) + +sys.exit(main(sys.argv))