Skip to content

Instantly share code, notes, and snippets.

@WA9ACE
Last active December 12, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WA9ACE/4725031 to your computer and use it in GitHub Desktop.
Save WA9ACE/4725031 to your computer and use it in GitHub Desktop.
Bitcoin Gem price checker with notifications.
require 'nokogiri'
require 'open-uri'
require 'terminal-notifier'
title = 'Bitcoin Gem'
activate = 'com.googlecode.iterm2'
current_price = 0
while 1
page = Nokogiri::HTML open('http://bitcoingem.com/')
h2 = page.at 'h2'
price = h2.to_s[/(\d+\.\d+)/, 1].to_f
if price == current_price
sleep 5
elsif price > current_price
TerminalNotifier.notify("Price rose from #{current_price} to #{price}", :activate => activate, :title => title)
current_price = price
elsif price < current_price
TerminalNotifier.notify("Price dropped from #{current_price} to #{price}", :activate => activate, :title => title)
current_price = price
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment