Skip to content

Instantly share code, notes, and snippets.

View supernullset's full-sized avatar

Sean Williamson supernullset

View GitHub Profile
@supernullset
supernullset / aggregator.rb
Created April 1, 2013 05:47
First pass aggregator
class Aggregator
def initialize(target_filename, output_filename, pattern, output_file_type=nil)
@target_filename = target_filename
@output_filename = output_filename
@pattern = pattern
@output_file_type = output_file_type || "csv"
end
def run
open_files
@supernullset
supernullset / teams.thor
Created February 17, 2013 05:33
Quick task to add org members to a specific repo
require 'github_api'
require 'io/console'
class Teams < Thor
include Thor::Actions
desc "ls", "list users in an organization"
def ls(org)
connenction = connect
members = connenction.orgs.members.list org
@supernullset
supernullset / DB_cleaner.rb
Created January 21, 2013 21:00
Multi-Database DatabaseCleaner setup
RSpec.configure do |config|
config.before :suite do
# set up a global cleaning strategy
DatabaseCleaner.clean_with(:truncation)
# AR specific strategy
DatabaseCleaner[:active_record].strategy = :truncation
# Explicitly tell DatabaseCleaner what connection is AR
DatabaseCleaner[:active_record, connection: :pediafed_test]
@supernullset
supernullset / monsterAttack.rs
Created January 6, 2013 14:59
MonsterAttack
use core::rand::{Rng};
struct Monster {
name: ~str,
health: HealthPoints,
mut speed: int,
mut charisma: int,
mut max_attack: int,
position: Position
@supernullset
supernullset / BadDOM.coffee
Created December 21, 2012 20:33
Worst Abuse Ever
seat_index = "seat-#{arc_index}"
if href = SEATS[seat_index]["link"]
if !@links then @links = exports ? this
if [email protected] then @links.hash = {}
@links.hash[seat_index] = href
d3.select(".#{seat_index}").on "click", ->
seat_index = this.classList[1]
href = window.links.hash[seat_index]
window.open href, "_blank"
@supernullset
supernullset / gist:4271872
Created December 12, 2012 21:40
redirect_test
def create
# generic file specific code
if files = params.fetch(:flu_vaccine){{}}.fetch(:generic_files){nil}
@file_uploads = GenericFile.new files if files.fetch(:name) != ""
end
params.fetch(:flu_vaccine){{}}.delete :generic_files
# vaccine specific code
@vaccine = FluVaccine.new(params.fetch(:flu_vaccine){{}})
@supernullset
supernullset / method_chaining_helper.rb
Created December 11, 2012 04:26
Method chaining by message sending
class Object
def send_each(*methods)
methods.inject(self) do |o, m|
o.respond_to?(m) ? o.public_send(m) : o
end
end
end
class MethodSequence
def document_download_cells(object, name, icon_path)
require "sugar"
dust = require "dust"
redis = require "redis"
client = redis.createClient()
clicker = (app) ->
client.get "clicker", (e,cr) ->
client.get "timed", (e,tr) ->
app.render index: {clicker: cr, timed: tr}
@supernullset
supernullset / null.coffee
Created November 5, 2012 03:56
Example of WIP-Menu for supernullset.com
w = 1000
h = 500
X = d3.scale.ordinal().domain([90]).rangePoints([0,w],1)
Y = d3.scale.ordinal().domain([180]).rangePoints([0,h],2)
upper_arc = d3.svg.arc()
.innerRadius(95)
.outerRadius(105)
.startAngle(0)
.endAngle(Math.PI)
@supernullset
supernullset / test.rb
Created October 31, 2012 21:36
minitest integration
require "minitest_helper"
describe "Root path acceptance test" do
before do
@company1 = create(:awesome_sauce_llc, featured: true)
@company2 = create(:better_than_you_inc, featured: true)
end
describe "when not logged in" do
before { visit root_path }