Skip to content

Instantly share code, notes, and snippets.

<!-- A stab at how the first pie chart on http://teethgrinder.co.uk/open-flash-chart/gallery-pie.php could be created from a table -->
<table summary="Microsoft's Internet Explorer appears to be dying, with the Wii taking 20% of market">
<caption>Pie Chart</caption>
<tr>
<td>Wii</td>
<td>15%</td>
</tr>
<tr>
<td>Opera</td>
<td>12%</td>
const MICROBLOG_STATUS_MAXLEN = 140;
CmdUtils.CreateCommand({
name: "dent",
takes: {status: noun_arb_text},
author: {name: "Daniel Haran, barely modifying work by Blair McBride as seen in the Ubiquity tutorial", homepage: "http://danielharan.com/"},
license: "MPL",
preview: function(previewBlock, statusText) {
require 'rubygems'
require 'mechanize'
postal_codes = File.open("postal_codes.txt").read.split("\n")
# randomize to make the pattern slightly harder to see in logs
postal_codes = postal_codes.sort_by {|e| rand(10_000)}
@agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
a.max_history = 1
require 'rubygems'
require 'mechanize'
postal_codes = File.open("postal_codes.txt").read.split("\n")
# randomize to make the pattern slightly harder to see in logs
postal_codes = postal_codes.sort_by {|e| rand(10_000)}
@agent = WWW::Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
a.max_history = 1
require 'rubygems'
require 'mechanize'
postal_codes = File.open("postal_codes.txt").read.split("\n")
# randomize to make the pattern slightly harder to see in logs
postal_codes = postal_codes.sort_by {|e| rand(10_000)}
def filename(postcode)
postcode.sub(' ', '')
end
Dir.glob("*").each do |pc|
File.open(pc).read =~ /aug08cpocRidingProfileTitle>([^<]*)</
puts "#{pc},#{$1}"
end
class Hash
def +(other)
(self.keys + other.keys).uniq.each do |key|
if [self[key], other[key]].all?
if self[key].is_a?(Hash)
self[key] += other[key]
elsif self[key].respond_to?(:+)
self[key] += other[key]
else
raise "values for #{key} were neither hashes or summable"
class String
def starts_with?(str)
self =~ /#{str}/
end
end
names_to_edid = File.open(File.dirname(__FILE__) + '/edid_names').read.split("\n").
collect {|line| edid, pruid, edname = line.split("|"); [edname.strip, edid.strip]}.
inject({}) {|hash,e| hash[e.first] = e.last; hash }
class KeyValuePairs
# Take a file like:
# G6C=24034
# H9E=24049
# and create the hash you'd expect
# if instead you have something like:
# G6C=24034,24036
# H9E=24049
# then use a block to do the specify the value
def self.hash(file_name, separator='=', &block)
require 'rubygems'
require 'mechanize'
postal_codes = File.open("postal_codes.txt").read.split("\n")
# randomize to make the pattern slightly harder to see in logs
postal_codes = postal_codes.sort_by {|e| rand(10_000)}
def filename(postcode)
postcode.sub(' ', '')
end