Skip to content

Instantly share code, notes, and snippets.

View eightbitraptor's full-sized avatar

Matt Valentine-House eightbitraptor

View GitHub Profile
@eightbitraptor
eightbitraptor / slim_const_spike.rb
Created April 23, 2013 13:09
Spiking a slimline no work allowed approach to constructors in Ruby.
require 'rspec'
module Hardline
def self.extended(base)
base.define_singleton_method(:construct_with) do |*args|
base.define_singleton_method(:new) do |*init_args|
combined_args = args.zip(init_args)
me = self.allocate
me.tap do |obj|
combined_args.map do |(n, v)|
@eightbitraptor
eightbitraptor / ebr.sh
Created February 13, 2013 09:46
My tmux powerline theme file
# Default Theme
if patched_font_in_use; then
TMUX_POWERLINE_SEPARATOR_LEFT_BOLD="⮂"
TMUX_POWERLINE_SEPARATOR_LEFT_THIN="⮃"
TMUX_POWERLINE_SEPARATOR_RIGHT_BOLD="⮀"
TMUX_POWERLINE_SEPARATOR_RIGHT_THIN="⮁"
else
TMUX_POWERLINE_SEPARATOR_LEFT_BOLD="◀"
TMUX_POWERLINE_SEPARATOR_LEFT_THIN="❮"
class AddNameToComments < ActiveRecord::Migration
def change
add_column :comments, :name, :string # add a string column called name to the table comments
end
end
@eightbitraptor
eightbitraptor / game.py
Created November 27, 2012 07:28
A Naive (and broken) derp of the Game of Life in Python.
import time
import copy
from itertools import *
class Cell(object):
alive = False
def __str__(self):
return 'o' if self.alive else '.'
@eightbitraptor
eightbitraptor / gist:3404018
Created August 20, 2012 13:26
bootstrap.sh
#!/usr/bin/env bash
set -e
EXPECTED_ARGS=2
main(){
check_arguments $*
return_to=$PWD
Ethan
Firstly, a lot of the developers in the local Ruby community have been the target of your spam lately. Suffice to say that it is unwelcome and has not been well received. I notice that you've taken it upon yourself to start advertising our job for us. We no longer use recruiters to fill our development job vacancies and even if we did, we certainly would not be using testdrivenit based on what we have seen of your approach.
Please stop pretending that you represent us. We have not asked you to work on any vacancies for On the Beach and we do not want our reputation dragged through the mud with our local Ruby community.
As for your applicant, we are not interested in considering any of your candidates. The best thing you can do for them is tell them to get in touch directly if they are interested in working for On the Beach.
Regards,
@eightbitraptor
eightbitraptor / 01_test_migration.rb
Created February 5, 2012 21:47
test harness for faking a rails app in tests.
class TestMigration < ActiveRecord::Migration
def self.up
create_table :test_models do |t|
t.integer :created_at
end
end
end
Application = {}
jQuery(function($) {
for( key in Application) {
if( Application.hasOwnProperty(key)) {
if (typeof Application[key]["init"] === "function" && $('body').hasClass('with-js-' + key.toLowerCase())){
Application[key].init($)
}
};
};
}
@eightbitraptor
eightbitraptor / gist:1711353
Created January 31, 2012 16:11
decoration
# House Model
class House
has_many: occupants
# ... Other House related methods live here ...
end
# Presenter for a House object
# Deals with visual shenanigans for the view
class HouseDecorator
@eightbitraptor
eightbitraptor / compare.sh
Created January 23, 2012 16:10
Comparing files and git files
diff <(find . -type f | sed -e 's/\.\///' | sort| grep -v '.git') \
<(git ls-files | grep -v '.git' | sort)