Last active
October 27, 2015 08:55
-
-
Save topher6345/30619b3beb37d327e9c4 to your computer and use it in GitHub Desktop.
Print out the change in the last hour of various crypotcurrencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
require 'colorize' | |
def fetch(url) | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
JSON.parse(data) | |
end | |
coinmarketcap = fetch "http://coinmarketcap.northpole.ro/api/all.json" | |
coinmarketcap["markets"].reverse.each do |c| | |
price = c["change1h"].green if c["change1h"].to_f > 0 | |
price = c["change1h"].red if c["change1h"].to_f < 0 | |
puts %Q[ #{c["name"]} #{price}] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
require 'colorize' | |
def fetch(url) | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
JSON.parse(data) | |
end | |
coinmarketcap = fetch "http://coinmarketcap.northpole.ro/api/all.json" | |
coinmarketcap["markets"].reverse.each do |c| | |
price = c["change1h"].green if c["change1h"].to_f > 0 | |
price = c["change1h"].red if c["change1h"].to_f < 0 | |
puts %Q[ #{c["name"]} #{price}] | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
require 'colorize' | |
def fetch(url) | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
JSON.parse(data) | |
end | |
coinmarketcap = fetch "http://coinmarketcap.northpole.ro/api/all.json" | |
coinmarketcap["markets"].sort_by! {|coin| coin["change1h"].to_f } | |
coinmarketcap["markets"].each do |c| | |
next if c["change1h"].to_f.zero? | |
price = "+#{c['change1h']}".green if c["change1h"].to_f > 0 | |
price = c["change1h"].red if c["change1h"].to_f < 0 | |
puts %Q[ #{c["name"]} #{price}] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
to install
sudo mv coinmarket usr/bin/coinmarket
sudo chmod 777 usr/bin/coinmarket
sudo chmod u+x usr/bin/coinmarket