Skip to content

Instantly share code, notes, and snippets.

class AddUsersRolesTable < ActiveRecord::Migration
def self.up
create_table :users_roles do |t|
t.integer :user_id
t.integer :role_id
end
end
def self.down
drop_table :users_roles
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.github.mxcl.homebrew.daemontools</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/svscanboot</string>
</array>
# http://unicorn.bogomips.org/SIGNALS.html
rails_env = ENV['RAILS_ENV'] || 'production'
rails_root = ENV['RAILS_ROOT'] || "/data/github/current"
God.watch do |w|
w.name = "unicorn"
w.interval = 30.seconds # default
# unicorn needs to be run from the rails root
@recursive
recursive / example.html
Created February 9, 2011 07:26
jquery odd row example
<!DOCTYPE html>
<html>
<head>
<style>
table {background:#ccc; color: white;}
.odd {background:#777;}
</style>
<script src="http://code.jquery.com/jquery-1.5.min.js"></script>
</head>
<body>
@recursive
recursive / stdout
Created January 13, 2011 01:21
Any Ideas?
ruby-1.9.2-p136@proman [git javascript] rake jasmine
(in /Users/developer/Development/Workspace/ProMan)
rake aborted!
no such file to load -- spec/javascripts/support/jasmine_config.rb
(See full trace by running task with --trace)
ruby-1.9.2-p136@proman [git javascript] ls -alh spec/javascripts/support/jasmine_config.rb
-rw-r--r--+ 1 developer staff 422B Jan 12 19:19 spec/javascripts/support/jasmine_config.rb
def create
@custom_errors = Array.new
@chain = current_user.chain
@chain.advertisers.each { |advertiser|
@deal = Deal.new(params[:deal])
@deal.advertiser_id = advertiser.id
@deal.advertiser.ripper = false
@deal.advertiser.category_id = advertiser.category.parent_id
@deal.advertiser.category_parent_id = advertiser.category.parent_id
if @deal.save
development:
adapter: sqlite3
database: db/development.sqlite3
timeout: 5000
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 5000
def html_safe_ajax_partial(name, partial, div)
link_to_remote name, :url => new_session_url(:partial => partial, :format => 'js'), :update => div, :method => :get, :html => { :href => new_session_url(:partial => partial) }
end
#html_safe_ajax_partial('Hello', 'hi', 'coolstuff')
#The above properly generates http://domain/session/new?partial=hi in the coolstuff div with text 'Hello'
#<a onclick="new Ajax.Updater('page_contents', 'http://localhost:3001/session/new.js?partial=hi', {asynchronous:true, evalScripts:true, method:'get', parameters:'authenticity_token=' + encodeURIComponent('U44dXFOJa2g4cpjYTL+SwSySN3lh0jo9dD8joocNEgo=')}); return false;" href="http://localhost:3001/session/new?partial=about">Hello</a>
#I want one to generate:
#<a onclick="new Ajax.Updater('page_contents', 'http://localhost:3001/session/new.js?partial=hi', {asynchronous:true, evalScripts:true, method:'get', parameters:'authenticity_token=' + encodeURIComponent('U44dXFOJa2g4cpjYTL+SwSySN3lh0jo9dD8joocNEgo=')}); return false;"
DateTime::DAYNAMES[DateTime::ABBR_DAYNAMES.index("Sun")].downcase
def route_to_poly_controller(polymorphic_type, polymorphic_id, action = :show)
return {:controller => polymorphic_type.tableize, :action => action, :id => polymorphic_id}
end