Skip to content

Instantly share code, notes, and snippets.


Andrew Sullivan sllvn

View GitHub Profile
View gist:2152742
class ZombiesController < ApplicationController
before_filter :find_zombie
def show
render :action => :show
def find_zombie
@zombie = Zombie.find params[:id]
if @zombie.tweets.size == 0
View gist:2188969
# Disable Resume system-wide
defaults write NSGlobalDomain NSQuitAlwaysKeepsWindows -bool false
# Disable the “reopen windows when logging back in” option
# This works, although the checkbox will still appear to be checked.
defaults write TALLogoutSavesState -bool false
defaults write LoginwindowLaunchesRelaunchApps -bool false
sllvn / tally.rb
Created Apr 14, 2012
Verite Spotify contest vote tallier
View tally.rb
#!/usr/bin/env ruby
# CSV file available at:
require 'csv'
class Tally < Hash
def vote(key, x)
self[key] = 0 unless self[key]
self[key] += x
sllvn / gist:2554014
Created Apr 29, 2012
Create a hash with keys set in array
View gist:2554014
keys = %w[event event_id event_type name description date]
Hash[* { |v| [v.to_sym, nil] }.flatten]
View gist:2865923
octave:1> A = [1 2; 3 4]
A =
1 2
3 4
octave:2> A - mean(A)
warning: operator -: automatic broadcasting operation applied
ans =
View gist:2896614
<name>North America</name>
<description>North America is a continent in the northern hemisphere, bounded on the north by the Arctic Ocean, on the ea
A change: Both North and South America are named after Amerigo Vespucci, who was the first European to suggest that the Americas were not the E
North America occupies the northern portion of the landmass generally referred to as the New World, the Western Hemisphere, the Ameri
View knight-random-walk.rb
#!/usr/bin/env ruby
class Knight
attr_accessor :x, :y, :count
def initialize(x, y)
@x, @y, @count = x, y, 0
def position
View knight-random-walk.rb
knight =, 0)
memo =
1.upto(100000) do |x|
knight.move until knight.position == [0, 0]
puts x if x % 100 == 0
memo << knight.count
knight.count = 0
View gist:3249355
import arcpy
from arcpy import env
env.workspace = "C:\UtahAddressModel\SouthJordan_July2012"
rows = arcpy.UpdateCursor("SJC_AddressPts")
for row in rows:
if row.getValue("TYPE") == "CHURCH":
row.setValue("TYPE_D", "REL")
View gist:3267523
self.dateFormat = [[NSDateFormatter alloc] init];
[self.dateFormat setDateFormat:@"d MMMM YYYY"];
NSLog(@"now formatted = %@", [self.dateFormat dateFromString:@"5 August 2012"]);