Skip to content

Instantly share code, notes, and snippets.

View ashmckenzie's full-sized avatar

Ash McKenzie ashmckenzie

View GitHub Profile
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
require 'hpricot'
s = %q{<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html><body><input type="text" name="test" value="\" /><div id="footer"></div></body></html>}
selector = '#footer'
inner_html = 'testing'
#!/usr/bin/env ruby
require 'pp'
DEBUG = false
stats = {}
stats['Firefox-3.5'] = { :hits => 0, :percent => 0 }
stats['Firefox-3.0'] = { :hits => 0, :percent => 0 }
# Used to graph results from autobench
#
# Usage: ruby autobench_grapher.rb result_from_autobench.tsv
#
# This will generate three svg & png graphs
require "rubygems"
require "scruffy"
require 'csv'
require 'yaml'
@ashmckenzie
ashmckenzie / gist:738504
Created December 13, 2010 00:39
Equilibrium index code
require 'rubygems'
require 'test/unit'
def equi(list)
left = 0
right = list.inject { |x, y| x + y }
equilibrium_indicies = []
list.each_with_index do |val, i|
right -= val
@ashmckenzie
ashmckenzie / gist:738540
Created December 13, 2010 01:37
Find the smallest index in an array where all array values exist prior to index
def ps(list)
freq = {}
list.each do |v|
freq[v] = 0 if freq[v].nil?
freq[v] += 1
end
list.each_with_index do |v, i|
@ashmckenzie
ashmckenzie / cake_habtm.php
Created January 8, 2011 00:56
CakePHP HABTM problem
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
);
CREATE TABLE `announcements` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@ashmckenzie
ashmckenzie / gist:848146
Created February 28, 2011 22:07
VLine letter of complaint 01/03/2011

What a disgrace.

Your trains rarely arrive on time, consistently late and usually without a/c or any available seating. Where is the money that I’m spending on your ‘service’ on a daily basis going exactly ?

I’ve been using your ‘service’ for four (very) long years and in that time the ‘service’ has not improved once, in fact it’s steadily declined. Congratulations. I realise there are factors outside of VLine’s control (city congestion) but c’mon, a lot of the problems stem from lack of co-ordination, organisation and just generally caring about the ‘service’ you provide to hundreds of paying customers who rely on your ‘service’. It’s no secret that your lack of ‘service’ is directly affecting the lives of hundreds of people, consistently causing them to arrive home late to their husbands, wives and kids.

I would be ashamed and disgusted to work for VLine. It’s arrogant to continue to treat your customers with such disrespect and contempt by not doing a DAMN THING ABOUT FIXING THE SERVICE.

VLi

export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
if [ $(git status -s | wc -l) -gt 0 ]; then
changes="*"
fi
echo "-["${ref#refs/heads/}"${changes}]"
}
@ashmckenzie
ashmckenzie / gist:2556520
Created April 30, 2012 08:20
Witch dangling symlink
[ash@ash-macbook-air]-[18:16:46]-[0]-[1.9.3-falcon]-[/Volumes/Witch]
$ cp -r 'Witch.prefPane' /Users/ash/Library/PreferencePanes
cp: Witch.prefPane/Contents/Resources/witchdaemon.app/Contents/Frameworks/Sparkle.framework/Resources/fr_CA.lproj: No such file or directory
cp: Witch.prefPane/Contents/Resources/witchdaemon.app/Contents/Frameworks/Sparkle.framework/Versions/A/Resources/fr_CA.lproj: No such file or directory
cp: Witch.prefPane/Contents/Resources/witchdaemon.app/Contents/Frameworks/Sparkle.framework/Versions/Current/Resources/fr_CA.lproj: No such file or directory
[ash@ash-macbook-air]-[18:17:09]-[0]-[1.9.3-falcon]-[/Volumes/Witch]
$ ls -la Witch.prefPane/Contents/Resources/witchdaemon.app/Contents/Frameworks/Sparkle.framework/Resources/fr_CA.lproj
lrwxr-xr-x 1 ash staff 110 Apr 8 08:31 Witch.prefPane/Contents/Resources/witchdaemon.app/Contents/Frameworks/Sparkle.framework/Resources/fr_CA.lproj -> /Users/andym/Development/Build Products
@ashmckenzie
ashmckenzie / .port
Created July 12, 2012 05:06 — forked from tommeier/.port
Install local ssl with pow
5000