Skip to content

Instantly share code, notes, and snippets.

View abachman's full-sized avatar
🙌
good times

Adam Bachman abachman

🙌
good times
View GitHub Profile
class Notable < ActiveRecord::Base
self.abstract_class = true
has_many :notes, :as => :notable
accepts_nested_attributes_for :notes
end
class User < Notable
end
# how bad of form is this?
# Using the scale given at:
# http://docs.google.com/drawings/pub?id=1yAsORHdSy8MZo3Wc9RdtL-yJ_z8YpqRKe1_A1TXkkCA&w=960&h=720
# and in light of ruby best practices.
class Document
attr_accessor :foo, :bar
def initialize
if block_given?
module Paperclip
class Geometry
def self.from_file file
parse("100x100")
end
end
class Thumbnail
def make
src = Test::FileHelper.fixture_file('white_pixel.jpg')
dst = Tempfile.new([@basename, @format].compact.join("."))
@abachman
abachman / auto confirm js popups in cucumber.feature
Created June 2, 2010 21:06
Accomodating rails' default javascript-driven "delete" link behavior in Cucumber.
# web_steps.rb
When /^I am going to confirm all js popups on this page$/ do
# hackish, but not unreasonable.
page.evaluate_script("window.alert = function(msg) { return true; }")
page.evaluate_script("window.confirm = function(msg) { return true; }")
end
# some_feature.feature
# note that "I am going to confirm..." has to be called after arriving on
# a page and before pressing links that use confirm (delete, in most cases)
# Bohconf
class Bohconf < Processing::App
def setup
background 0
frame_rate 30
no_stroke
@xy = []
400.times {
The Tabular plugin: http://github.com/godlygeek/tabular
" nice indentation for Cucumber scripts (if you're not already nesting)
:'<,'>Tabularize /^.*\(Given\|And\|When\|Then\) /l0
So that:
Scenario: Admin user should be able to access categories index from form library page
Given I am an admin user with the login "administrator" and the password "administrator"
And there is a active study
class ToHaml
def initialize(path)
@path = path
end
def convert!
Dir["#{@path}/**/*.erb"].each do |file|
puts "converting #{file}"
# run html2haml on the input file in erb mode with strict parsing
# on the input (xhtml mode)
# Arcify
class Arcify < Processing::App
class Arc
attr_accessor :id
def initialize x,y,r,s,f,i
@x = x
@y = y
@r = r
@s = s
@abachman
abachman / treelike.rb
Created June 18, 2010 00:36
treelike - livecoding practice
We couldn’t find that file to show.
@abachman
abachman / blankslate.rb
Created June 18, 2010 00:39
livecoding practice starting point
# Blankslate - livecoding practice start file
class Blankslate < Processing::App
def setup
end
def draw