Skip to content

Instantly share code, notes, and snippets.

99.downto(1){|i| puts "#{i} bottles of beer on the wall, #{i} bottles of beer! Take one down, pass it around, #{i-1} bottles of beer on the wall!" }
# works
context "POST edit_subscriptions" do
setup do
fake_login
@user.subscriptions << Factory(:subscription)
@user.reminder_preferences << Factory(:reminder_preference)
post :edit_subscriptions, :params => {:commit => "Unsubscribe", :action => "edit_subscriptions", :id => @user.id, :controller => "users",
"#{@user.reminder_preferences.first.id}_email" => "on"}
assert_equal @user.reminder_preferences, []
cap production deploy
triggering start callbacks for `production'
Enter passphrase for /Users/jimmy/.ssh/id_rsa:
Identity added: /Users/jimmy/.ssh/id_rsa (/Users/jimmy/.ssh/id_rsa)
* executing `production'
triggering start callbacks for `deploy'
* executing `multistage:ensure'
Enter passphrase for /Users/jimmy/.ssh/id_rsa:
Identity added: /Users/jimmy/.ssh/id_rsa (/Users/jimmy/.ssh/id_rsa)
* executing `deploy'
development:
adapter: mysql2
username: root
password: coolio
socket: /tmp/mysql.sock
encoding: utf8
database: r101_development
# warning: the database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
development:
adapter: postgresql
encoding: unicode
username: vkansal
password:
pool: 5
min_messages: WARNING
database: caprica_dev
test:
@jperrine
jperrine / gist:1308232
Created October 24, 2011 02:12
note js
var Note = function (name) {
var someMethod = function() {};
return {
publicMethod: someMethod,
...
}
};
var note1 = new Note('whatever');
@jperrine
jperrine / gist:1308280
Created October 24, 2011 03:10
note js 2
var QwikObject = function (id, x, y, z) {
this._x = x || 0;
};
QwikObject.prototype = {
get x(){
return this._x;
},
set x(x){
this._x = x;
@jperrine
jperrine / gist:1322659
Created October 28, 2011 16:16
ignore field name in errors
# in your model
def self.full_message_fields
[:field1, :field2] # these fields will display the full message
end
# inside your form
-if @group.errors.any?
#error_explanation
%ul
- @group.errors.each do |attr, msg|
@jperrine
jperrine / gist:1323948
Created October 29, 2011 01:04
separation
# in lib/admin_user_methods.rb
module AdminUserMethods
# your methods go here
end
# in app/models/user.rb
class User < AR
include AdminUserMethods
end
@jperrine
jperrine / gist:1329577
Created November 1, 2011 01:15
modules
module AdminUserMethods
def self.included(base)
base.extend(ClassMethods)
end
# instance methods go here
module ClassMethods
# class methods go here
end