Skip to content

Instantly share code, notes, and snippets.

strictly_for_fun?
make_happy
make_depressed
willing_to_give_up_manhood?
make_depressed
willing_to_give_up_manhood?
require 'rubygems'
require 'transitions'
# show me the caller name
module Wombatize
def method_name
caller[0][/`([^']*)'/, 1]
end
end
make_depressed
Willing to giveup manhood?
make_depressed
Willing to giveup manhood?
gem "mongoid", "~> 2.0.0.rc.6"
gem "bson_ext", "~> 1.2"
group :test, :development do
gem "rspec-rails", "~> 2.4"
gem "jslint_on_rails"
end
group(:test) do
require 'spec_helper'
describe "Application" do
# TODO: implement
pending "should earn loads of money"
end
require 'spec_helper'
describe Cat do
describe "validations" do
it "should be valid" do
cat = Cat.new(:name => "panther", :url => "http://great.panther.com/pan.jpg")
cat.should be_valid
end
class Cat
include Mongoid::Document
include ActiveModel::Validations
# fields
field :name
field :url, :type => String
# validations
<!DOCTYPE html>
<html>
<head>
<title>Gib moneyz!</title>
<%= csrf_meta_tag %>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<%= stylesheet_link_tag "reset.css", "960.css", "application.css" %>
<%= javascript_include_tag "jquery-1.5.1.min", "application" %>
</head>
<body>
@JakubOboza
JakubOboza / oh fails :(
Created March 4, 2011 19:23
first some tests....
require 'spec_helper'
describe CatsController do
describe "#index" do
it "should display cats" do
get :index
response.status.should eql(200)
end
end
@JakubOboza
JakubOboza / gist:893286
Created March 29, 2011 21:00
cache or not to cache
require "benchmark"
module Functional
def memo
cache = {}
lambda do |*args|
unless cache.has_key?(args)
cache[args] = self[*args]
end