Skip to content

Instantly share code, notes, and snippets.

@richterd
Last active December 23, 2015 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richterd/6636098 to your computer and use it in GitHub Desktop.
Save richterd/6636098 to your computer and use it in GitHub Desktop.
Check the current amount of money in $ and € offered for the first person to hack the touchID from iOS 7 (Uses the current rate of bitcoin to dollar and dollar to euro)
#encoding: utf-8
require 'open-uri'
require 'json'
page = open('http://istouchidhackedyet.com/').read
bitcoin_page = open('http://api.bitcoincharts.com/v1/weighted_prices.json').read
to_euro_page = open('http://rate-exchange.appspot.com/currency?from=USD&to=EUR').read
to_dollar_page = open('http://rate-exchange.appspot.com/currency?from=EUR&to=USD').read
to_euro_json = JSON.parse(to_euro_page)
to_dollar_json = JSON.parse(to_dollar_page)
bitcoin_json = JSON.parse(bitcoin_page)
bitcoin_rate = bitcoin_json["USD"]["7d"].to_i
#Find Dollars
dollars = page.scan(/\$(\d+)/)
dollar_sum = dollars.inject(0){|sum, x| sum + x[0].to_i} - 50 #minimum information
#Find Bitcoins
bitcoins = page.scan(/([.\d]+) [Bb]itcoin/)
bitcoin_sum = bitcoins.inject(0){|sum, x| sum + x[0].to_i}
#Find Euros
euros = page.scan(/(\d+) [Ee]uro/)
euro_sum = euros.inject(0){|sum, x| sum + x[0].to_i}
total = (bitcoin_sum * bitcoin_rate + dollar_sum + euro_sum * to_dollar_json['rate'])
puts 'Total: $ ' + total.round.to_s
puts 'Total: € ' + (total * to_euro_json['rate']).round.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment