Skip to content

Instantly share code, notes, and snippets.

activity_file_1 = ActivityFile.create!( :title => "ActivityFile 1", :date_issued => Date.parse( "2009-02-02" ), :size => 10, :content_type => "text/pdf", :filename => "temp1.pdf", :facility => facility )
activity_file_2 = ActivityFile.create!( :title => "ActivityFile 2", :date_issued => Date.parse( "2009-01-12" ), :size => 10, :content_type => "text/pdf", :filename => "temp1.pdf", :facility => facility )
activity_file_3 = ActivityFile.create!( :title => "ActivityFile 3", :date_issued => Date.parse( "2009-03-24" ), :size => 10, :content_type => "text/pdf", :filename => "temp1.pdf", :facility => facility )
activity_file_4 = ActivityFile.create!( :title => "ActivityFile 4", :date_issued => Date.parse( "2009-02-24" ), :size => 10, :content_type => "text/pdf", :filename => "temp1.pdf", :facility => facility )
activity_file_5 = ActivityFile.create!( :title => "ActivityFile 4", :date_issued => Date.parse( "2009-02-23" ), :size => 10, :content_type => "text/pdf", :filename => "temp1.pdf", :fac
@eqdw
eqdw / hotswap.rb
Created January 4, 2011 21:29
Proof of Concept of Erlang-style hot-swapping in Ruby
$CALLBACK = nil
$i = 0
class HotCode
def self.dispatcher(&block)
while(42)
sleep(0.25)
block.call
if($CALLBACK != block)
it "should return error 401 with bad key" do
get :list, :api_key => "My name is ryan and I'm a big jerkface who goes to Montreal and brags about how awesome the restaurants are"
response.status.should == "401"
end
{ :checklist =>
{ :id => checklist.id,
:title => checklist.title,
:items => checklist.items
}
}.to_json
class Post < ActiveRecord::Base
has_many :comments
end
class PostController < ApplicationController
def show
@post = Post.find(param[id])
def archive
dates = Post.date_counts(3).sort{|a,b| b <=> a}
@links = dates.map do |elem|
year, month = elem[0].split(/\//)
{:string => DateTime.strptime(elem[0], "%Y/%m").strftime("%B %Y"), :year => year, :month => month}
@links = @links[]
end
render
end
foo(0, 0, 0) -> %%funcbody
foo(3, [A:B], C) -> %%funcbody
foo(A, B, C) -> %%functionbody
namespace :db do
desc "Initialize the dev database"
task :init_dev => :environment do
user = User.find(1)
100.times do |i|
post = Post.create(:title => "Sample post ##{i+1}",
$("foo").load("herpaderp", function(){/*callback*/});
//becomes
$("foo").load('herpaderp');
& /* callback */