This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module FormHelper | |
def nested_form_for(object, *args, &block) | |
concat form_for(object, *(args << { :builder => NestedFormBuilder }), &block) | |
execute_after_nested_form_callbacks | |
end | |
def execute_after_nested_form_callbacks | |
@after_nested_form_callbacks ||= [] | |
@after_nested_form_callbacks.inject(String.new.html_safe) do |output, callback| | |
output << callback.call |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Shell script to install your public key on a remote machine | |
# Takes the remote machine name as an argument. | |
# Obviously, the remote machine must accept password authentication, | |
# or one of the other keys in your ssh-agent, for this to work. | |
ID_FILE="${HOME}/.ssh/id_rsa.pub" | |
if [ "-i" = "$1" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NewYachtModel < ActiveRecord::Base | |
belongs_to :new_yacht | |
has_many :contents, :class_name => 'NewYachtTopicContent' | |
has_many :topics, :class_name => 'NewYachtTopic', :through => :contents | |
accepts_nested_attributes_for :contents | |
end | |
class NewYachtTopic < ActiveRecord::Base |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "benchmark" | |
n = 100000 | |
klass = Benchmark | |
Benchmark.bm do |b| | |
b.report do | |
n.times { "visit_#{(klass.name || '').gsub('::', '_')}" } | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bundler Integration | |
require "bundler/capistrano" | |
# Application Settings | |
set :application, "yourapplicationname" | |
set :user, "serveruser" | |
set :deploy_to, "/home/#{user}/rails-applications/#{application}" | |
set :rails_env, "production" | |
set :use_sudo, false | |
set :keep_releases, 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get(name, type = :string) | |
parameter = name.is_a?(Array) ? self.key_chain(*name) : self[name] | |
if !parameter.blank? | |
case type | |
when :string then parameter.to_s | |
when :hash, :collection then parameter | |
when :csv then parameter.split(',').map(&:strip) | |
when :integer then Integer(parameter) | |
when :float then Float(parameter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Screenshoter | |
include Java | |
import java.io.File | |
import java.awt.Robot | |
import java.awt.Toolkit | |
import java.awt.Rectangle | |
import javax.imageio.ImageIO | |
def self.shoot!(output = "screenshot.png") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CQM < ActiveRecord::Base | |
self.abstract_class = true | |
establish_connection( | |
:adapter => "mysql2", | |
:host => "localhost", | |
:username => "root", | |
:password => "root", | |
:database => "cqm_development" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "ostruct" | |
module FormsHelper | |
def search_form_for(object_name, options={}, &block) | |
options[:html] = {:method => :get}.update(options[:html] || {}) | |
object = OpenStruct.new(params[object_name]) | |
form_for(object_name, object, options, &block) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply 'http://gist.github.com/raw/562316/1c45aa71f17491c36d74123abf7886b9a08daddf/basic_stack.rb' | |
apply 'http://gist.github.com/raw/562316/ed62987b05de614c9b37062f410a3a48e4e776f2/brazilian_app.rb' | |
apply 'http://gist.github.com/raw/562316/56326e84aa23d9ac1cc227f8aa8ae178f2d4d6b5/cleanup.rb' | |
apply 'http://gist.github.com/raw/562316/7406f13bf9d9b9d467f3d00a26b56a960685beeb/rspec.rb' | |
apply 'http://gist.github.com/raw/562316/ad35700fa4f3cf9163b0149b19beeba0407ea325/cucumber.rb' | |
apply 'http://gist.github.com/raw/562316/4cc84eb5ea709c2f0ea76783157548a660a374a2/w3.rb' |