This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Notable < ActiveRecord::Base | |
self.abstract_class = true | |
has_many :notes, :as => :notable | |
accepts_nested_attributes_for :notes | |
end | |
class User < Notable | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(".")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bohconf | |
class Bohconf < Processing::App | |
def setup | |
background 0 | |
frame_rate 30 | |
no_stroke | |
@xy = [] | |
400.times { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blankslate - livecoding practice start file | |
class Blankslate < Processing::App | |
def setup | |
end | |
def draw | |