Skip to content

Instantly share code, notes, and snippets.

View djanowski's full-sized avatar

Damian Janowski djanowski

View GitHub Profile
class Ancestor
attr_accessor :id
def initialize(id)
@id = id
end
def ==(other)
id == other.id
end
A->B:
B->C:
module ActiveRecord
class Base
alias_method :original_to_json, :to_json
end
end
require "json/add/rails"
module ActiveRecord
class Base
def image_tag(source, options = {})
if options.is_a?(Hash) && source !~ /^http/
size = `identify public/images/#{source}`[/ (\d+x\d+) /, 1]
if options[:size]
if options[:size] != size
line = "*** WRONG SIZE SPECIFIED FOR #{source}: :size => #{size.inspect} ***"
end
else
get '/posts/:id' do
# Render with or without a layout depending
# on request#xhr?. Useful for rendering regular
# requests and also partial updates like:
# $("#post").load('/posts/1')
haml :'posts/show', :layout => !request.xhr?
end
@djanowski
djanowski / gist:44344
Created January 7, 2009 17:24
Testing Facebook interaction with Facebooker
# DISCLAIMER: this is just a hack, not even tested.
# I use this for testing interaction with Facebook.
# Basically there are a bunch of fixture XMLs that
# represent the response from Facebook.
# Oh, make sure you do this somewhere, probably in
# a setup/before block:
#
# Facebooker::Session.current = Facebooker::MockSession.create
#
# (You might need to stub session[:facebook_session] too.)
# class TagsHelperTest < Test::Unit::TestCase
# helper 'app/helpers/tags'
#
# def test_tag
# assert_equal "<div></div>", helper.tag(:div)
# end
# end
require 'haml/engine'
#!/usr/local/bin/ruby
# Usage:
#
# $ build.rb http://yoururl.com/your_project/push
#
# $ echo "HEAD -1 refs/heads/master" | build.rb http://yoururl.com/your_project/push
#
# or you can hard-code the URL in the following line instead
# of passing it as an argument.
require 'rubygems'
dependencies = <<-EOS
rack 0.9.1
activesupport >= 2.2.2
daemons >= 1.0.10
djanowski-workling
djanowski-collage >= 0.1.3
faker >= 0.3.1
fiveruns-memcache-client >= 1.5.0
require "test/unit"
class FooTest < Test::Unit::TestCase
def setup
@value = true
end
def test_truth
assert @value
end