Skip to content

Instantly share code, notes, and snippets.

View infovore's full-sized avatar

Tom Armitage infovore

View GitHub Profile
@infovore
infovore / wotlisten.rb
Created February 20, 2009 20:32
tells you what a username is listening to right now on last.fm. Probably not of use to you.
#!/usr/bin/env ruby -KU
require 'rubygems'
require 'open-uri'
require 'hpricot'
if ARGV[0]
user = ARGV[0]
url = "http://www.last.fm/user/#{user}"
doc = Hpricot(open(url))
<?php
class MY_Exceptions extends CI_Exceptions {
function My_Exceptions()
{
parent::CI_Exceptions();
}
function log_exception($severity, $message, $filepath, $line)
SELECT s.schema_name,
CONCAT(IFNULL(ROUND((SUM(t.data_length)+SUM(t.index_length))
/1024/1024,2),0.00),"Mb") total_size,
CONCAT(IFNULL(ROUND(((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))/1024/1024,2),0.00),"Mb")
data_used,
CONCAT(IFNULL(ROUND(SUM(data_free)/1024/1024,2),0.00),"Mb") data_free,
IFNULL(ROUND((((SUM(t.data_length)+SUM(t.index_length))-SUM(t.data_free))
/((SUM(t.data_length)+SUM(t.index_length)))*100),2),0) pct_used,
COUNT(table_name) total_tables
FROM INFORMATION_SCHEMA.SCHEMATA s
#!/usr/bin/env ruby -wKU
require 'rubygems'
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open("http://www.theyworkforthebpi.com/"))
mps_page = Nokogiri::HTML(open("http://www.theyworkforyou.com/mps/"))
names = doc.css("p.tabletext span")
function roundDecimal(n, dp) {
/* round number [n] to [dp] decimal places */
return Math.round(n * Math.pow(10,dp)) / Math.pow(10,dp);
}
description "A blinking light"
author "Tom Armitage - [email protected]"
start on started mountall
stop on shutdown
script
export HOME="/home/pi"
export BUNDLE_GEMFILE="/home/pi/src/blink/Gemfile"
exec bundle exec ruby /home/pi/src/blink/blinken.rb
description "A script controlled by upstart"
author "Tom Armitage - [email protected]"
start on started mountall
stop on shutdown
script
export HOME="/home/pi"
exec /home/pi/src/script.sh
end script
require 'pi_piper'
include PiPiper
pin = PiPiper::Pin.new(:pin => 17, :direction => :out)
pin.off
loop do
pin.on
sleep 1
pin.off
@infovore
infovore / 6musicnow
Created March 27, 2015 12:25
Ruby script to spit out what's playing, by who, on 6Music right now, into your shell.
#!/usr/bin/env ruby
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://www.bbc.co.uk/6music'))
artist = doc.css('.realtime-now-playing .rtm-np-artist').text.strip
track = doc.css('.realtime-now-playing .rtm-np-track').text.strip
load_sample :loop_amen
load_sample :bass_dnb_f
with_fx(:rlpf, cutoff: 40, cutoff_slide: 4) do |c|
one_to_eight = (1..8)
live_loop :drums do |count|
if (count+1) % 8 == 0
# put a break in every eight bars where you chop the break randomly
slices = one_to_eight.to_a.sort_by { rand }