Skip to content

Instantly share code, notes, and snippets.

@hubert3
Last active October 20, 2023 21:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hubert3/6621972 to your computer and use it in GitHub Desktop.
Save hubert3/6621972 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import requests, re
btc_rate = 139.0
dollar_total = 0.0
btc_total = 0.0
page = requests.get('http://istouchidhackedyet.com/').text
dollar_pledges = re.findall(r'-.+\$(\d+)', page)
dollar_total = sum(map(float,dollar_pledges))
btc_pledges = re.findall(r'([\d.]+) bitcoin', page, re.IGNORECASE)
btc_total += sum(map(float,btc_pledges))
print '%s USD (%s donors)' % (dollar_total, len(dollar_pledges))
print '%s BTC (%s donors)\n' % (btc_total, len(btc_pledges))
print 'TOTAL $%s' % int(round(dollar_total + btc_total*btc_rate,0))
@PaulMaddox
Copy link

...with extra added hangover calculator!

#!/usr/bin/python

import requests, re
btc_rate = 139.0
dollar_total = 0.0
btc_total = 0.0

page = requests.get('http://istouchidhackedyet.com/').text
dollar_pledges = re.findall(r'-.+\$(\d+)', page)
dollar_total = sum(map(float,dollar_pledges))
btc_pledges = re.findall(r'([\d.]+) bitcoin', page, re.IGNORECASE)
btc_total += sum(map(float,btc_pledges))
bottle_pleges = re.findall(r'bottle', page, re.IGNORECASE)

print '%s USD (%s donors)' % (dollar_total, len(dollar_pledges))
print '%s BTC (%s donors)' % (btc_total, len(btc_pledges))
print '... and %s bottles of booze!\n' % (len(bottle_pleges))
print 'TOTAL $%s + a hangover of brutal proportions' % int(round(dollar_total + btc_total*btc_rate,0))

@topeg
Copy link

topeg commented Sep 20, 2013

use the right tool and you get the right answer ;-)

#!/usr/bin/perl
use LWP::Simple;

my $btc_rate = 139.0;

$page = get('http://istouchidhackedyet.com/') or die "error download\n";
$page =~ s!^.+?<br/>!!s;
$page =~ s!<p>Terms and Conditions.+?$!!s;

$dollar_cnt++ and $dollar_total += $1 while($page=~s!\$((?:\d*\.)?\d+)! !s);
$dtc_cnt++ and $btc_total += $1 while($page=~s!((?:\d*\.)?\d+)\s*bitcoins?! !is);

$page =~ s!<a[^<>]+>.*?</a>! and !gs;
$page =~ s!<[^<>]+>!!gs;
$page =~ s/\W\s+plus\s+/ and /igs;
$page =~ s/[^\w"']+/ /gs;
$page =~ s/(?:\s*and\s*)+/ and /gs;
$page =~ s/\s*and\s*$//gs;
$page =~ s/\s+/ /gs;
$page =~ s/and/\nand/gs;

printf "%0.02f USD (%u donors)\n",$dollar_total,$dollar_cnt;
printf "%0.02f BTC (%u donors)\n",$btc_total,$dtc_cnt;
printf "TOTAL \$%0.02f\n", $dollar_total + $btc_total * $btc_rate;
print "$page\n";

Better Dollar Counting and prints all the additional Stuff.

@anthonymonori
Copy link

Updated with automatic BTC/USD rate from MtGox https://gist.github.com/anthonymonori/6640288

@ezfe
Copy link

ezfe commented Sep 23, 2013

I've been having trouble running it, can someone tell me what it outputs at the moment?

@intelliot
Copy link

+1 @ezfe's request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment