Skip to content

Instantly share code, notes, and snippets.

@rbranson
rbranson / delayed_job
Created October 29, 2010 02:43
A hack of a delayed_job monitoring script for Munin
#!/usr/bin/env ruby
if ARGV[0] == "autoconf"
puts "yes"
exit
end
if ARGV[0] == "config"
puts <<EOT
graph_title delayed_jobs
@rbranson
rbranson / slurp-election-xml.rb
Created November 3, 2010 17:23
Reads ABC's XML files for 2010 election totals and dumps them out.
#!/usr/bin/env ruby
#
# Read's ABC's XML files for 2010 election totals and dumps them out.
#
# http://a.abcnews.com/xml/elections/2010/dynamic/dynamicgeneral/prod/elections/national/HouseMap.xml
# http://a.abcnews.com/xml/elections/2010/dynamic/dynamicgeneral/prod/elections/national/SenateMap.xml
#
# Copyright (c) 2010 Rick Branson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@rbranson
rbranson / minify_javascript_cache.rb
Created November 5, 2010 19:28
An initializer that will make Rails run JSMin on any cached JavaScript files
# Copyright (c) 2010 Richard Branson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@rbranson
rbranson / gist:664855
Created November 5, 2010 20:57
Roughly Benchmark Page Speed as if it was from a 1.5mbit Connection
wget -nv --limit-rate=150k --delete-after -p http://www.site.com/path/to/page
@rbranson
rbranson / pidigits.rb
Created November 17, 2010 07:36
Implementation of pidigits using GMP
# The Computer Language Benchmarks Game
# http://shootout.alioth.debian.org/
# transliterated from Mario Pernici's Python program
# contributed by Rick Branson
require "rubygems"
require "gmp"
def gmpz(n)
#!/bin/sh -x
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
if [ "$CURRENT" == "master" ]; then
echo "Current branch is master!"
exit
fi
git checkout master
#!/bin/sh -x
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
git checkout master
git merge ${CURRENT}
git push origin master
git checkout ${CURRENT}
@rbranson
rbranson / db-slam.rb
Created November 26, 2010 20:56
A simple SQL load generator (not for benchmarking)
#!/usr/bin/ruby
#
# db-slam.rb: A simple SQL database load generator. Not for benchmarking.
#
# Requires "sequel" gem, and a gem for whatever database you're trying to
# connect to. Accepts a URI parameter as a Sequel URI, such as:
#
# $ db-slam.rb postgres://user:password@host/database
#
@rbranson
rbranson / crossdomain.conf
Created February 3, 2011 21:13
nginx Flash XML policy server
# Add this to your nginx.conf under http { }
server {
listen 843;
server_name localhost;
location / {
rewrite ^(.*)$ /crossdomain.xml;
}
@rbranson
rbranson / copyright-year-always-right.html
Created April 2, 2011 00:44
Yo dawg, your copyright year still says last year. You look retarded. Never worry about that again...