View gist:43933
This file contains 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/ruby | |
# convert embed code generated by some Flash video players into valid markup | |
# (use object tag instead of deprecated embed tag) | |
require 'rexml/document' | |
require 'rubygems' | |
require 'builder' | |
View gist:49311
This file contains 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/ruby | |
# upload a local image or an image on the web to imageshack | |
require 'rubygems' | |
require 'mechanize' | |
require 'open-uri' | |
require 'uri' |
View gist:66728
This file contains 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/ruby | |
# sparkline showing the number of lines in a file | |
# run from cron at regular intervals | |
require 'rubygems' | |
require 'sparklines' | |
file_to_count = '/tmp/growing_file' | |
count_file = "#{file_to_count}.linecount" |
View gist:74780
This file contains 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 'pp' | |
temps = {} | |
temps['video'] = `aticonfig --od-gettemperature`.match(/Temperature - (\d+\.\d+) C/).captures.first.to_f | |
sensors_output = `sensors` | |
(['CPU', 'System'] + (0..3).to_a.map {|c| "Core #{c}"}).each do |x| |
View gist:78350
This file contains 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/ruby | |
# gmail unread message count | |
require 'open-uri' | |
require 'rexml/document' | |
unread_count = open('https://mail.google.com/mail/feed/atom', | |
:http_basic_authentication=>['you', 'secret']) do |f| | |
doc = REXML::Document.new(f.read) | |
doc.root.elements['//feed//fullcount/text()'].value.to_i |
View gcal_backup.rb
This file contains 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/ruby | |
# Google Calendar backup for custom domain | |
require 'rubygems' | |
require 'mechanize' | |
domain, user, pass = ARGV | |
unless [domain, user, pass].include?(nil) |
View get latitude and longitude from a photo
This file contains 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/ruby | |
# get latitude and longitude from a photo | |
# known to work with iphone photots | |
require 'rubygems' | |
require 'exifr' | |
x = EXIFR::JPEG.new(ARGV[0]) |
View prepend youtube links with thumbnails
This file contains 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
function add_youtube_thumbs() { | |
var m; | |
$('a').map(function() { | |
m = /http:\/\/(?:(?:www|uk)\.)?youtube\.com\/watch\?v=(.+?)(?:&|$)/.exec( | |
$(this).attr('href')); | |
if (m) { | |
$(this).prepend($('<img />').attr({ | |
'class' : 'youtube_thumb', | |
'src' : 'http://img.youtube.com/vi/' + m[1] + '/1.jpg' | |
})); |
View gist:115799
This file contains 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/ruby | |
# get number of active and allowed connections from a DD-WRT router | |
require 'rubygems' | |
require 'net/ssh' | |
Net::SSH.start('192.168.0.1', 'root') do |ssh| | |
max = ssh.exec!('cat /proc/sys/net/ipv4/netfilter/ip_conntrack_max').strip | |
tcp = ssh.exec!('grep -c ^tcp /proc/net/ip_conntrack').strip |
View stock quote
This file contains 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/ruby | |
require 'open-uri' | |
require 'hpricot' | |
symbol = ARGV[0] | |
open("http://www.nasdaq.com/aspxcontent/NasdaqRSS.aspx?data=quotes&symbol=#{symbol}") do |f| | |
doc = Hpricot(f) | |
desc = (doc/"//rss/channel/item/description").first.inner_html |
OlderNewer