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
require 'minitest/autorun' | |
GREEN_EGGS_AND_HAM = %{ | |
I am Sam | |
Sam I am | |
That Sam-I-am | |
That Sam-I-am! | |
I do not like that Sam-I-am |
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
%tr | |
%td{:align => "left", :height => "21", :valign => "bottom"} | |
%font{:color => "#000000"} | |
%br/ | |
- 20.times do | |
%td{:align => "left", :valign => "bottom"} | |
%font{:color => "#000000"} | |
%br/ |
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
# /* [ <!-- */ include <stdio.h> /* \ | |
#{\ | |
`""""true \\#{"\n#"}; \ | |
\ | |
if [ -n "$ZSH_VERSION" ]; then \ | |
\ | |
echo exec echo I\'m a zsh script.; \ | |
\ | |
elif [ -n "$BASH_VERSION" ]; then \ | |
\ |
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
controller: | |
def task_summary | |
# Find all the tasks | |
tasks = Task.find(:all) | |
# Create an IO buffer for the generated excel data | |
target_string = StringIO.new |
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
#!/usr/bin/env ruby | |
# for usage: ruby timecard.rb --help | |
require 'rubygems' | |
require 'optparse' | |
# This requires the 'cyberfox-gchart' gem (0.5.4), as the standard | |
# gchart gem is woefully broken for this kind of graph. Broken to the |
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
in application.rb | |
config.active_record.observers = :foo_observer | |
foo_observer.rb: | |
class FooObserver < ActiveRecord::Observer | |
def before_update(foo) |
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 SQLGrowler | |
class Subscriber < ActiveRecord::Railties::Subscriber | |
def sql(event) | |
super | |
g('%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')]) | |
end | |
end | |
def self.enable | |
if Kernel.respond_to?(:g) |
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
require 'test/unit' | |
module GetterSetter | |
def getter_setter(attribute) | |
instance_variable = "@#{instance_variable}" | |
define_method("#{attribute}=") do |value| | |
instance_variable_set(instance_variable,value) | |
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
require 'enumerator' | |
class Always42 | |
include Enumerable | |
def each | |
while true | |
yield 42 | |
end | |
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
require 'test/unit' | |
class Thingy | |
def method_missing(method_name,*args) | |
@attrs ||= {} | |
case method_name.to_s | |
when /^set_(.+)/ then | |
@attrs[$1] = args.first | |
when /^get_(.+)/ then |