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
# open the file containing the gems to load and install each | |
File.open(Dir.pwd << "/gems.txt", "r") do |f| | |
while (line = f.gets) | |
puts `sudo gem install --no-ri --no-rdoc #{line}` unless line.strip.empty? | |
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
# Pick up to 10 names, making sure to draw from each "hat" at least once | |
class Name < Struct.new(:first, :last); end | |
max_names = 10 | |
hat1 = [Name.new('Abraham', 'Lincoln'), Name.new('George', 'Washington')] | |
hat2 = [Name.new('Thomas', 'Jefferson'), Name.new('James', 'Madison'), Name.new('Theodore', 'Roosevelt'), Name.new('John', 'Kennedy')] | |
hat3 = [Name.new('Calvin', 'Coolidge'), Name.new('Ronald', 'Regan'), Name.new('Woodrow', 'Wilson')] | |
[hat1, hat2, hat3].sort{|a,b| b.size <=> a.size}.inject{|memo, names| memo.zip(names)}.flatten.compact[0, max_names] |
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
# This module should be used for situations where enumerating over constant values is desired. | |
# This facilitates keeping the code DRY by keeping the constant values defined in one place, and | |
# still having the ability to enumerate over them wherever they are needed. | |
# | |
# Example use cases: | |
# | |
# * defining constants for possible field values in an AR object and including this module to | |
# provide access to the values in a 'validates_inclusion_of' validation | |
# * defining constants for select box values in a view and including this module to allow them to be | |
# enumerated over in the select tag |
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 Travis | |
class Builder | |
@@ -29,9 +30,18 @@ module Travis | |
host = rails_config['url'] || 'http://127.0.0.1' | |
url = "#{host}/builds/#{build['id']}#{'/log' if data.delete(:append)}" | |
uri = URI.parse(host) | |
- data = { :body => { :_method => :put, :build => data }, :head => { :authorization => [uri.user, uri.password] } } | |
- # stdout.puts "-- post to #{url} : #{data.inspect}" | |
- register_connection EventMachine::HttpRequest.new(url).post(data) | |
+ data = { |
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
# Somewhere in the file | |
Capybara.auto_save_and_open_page = true if 'true' == ENV['CAPYBARA_AUTO_SAVE_AND_OPEN_PAGE'] |
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
if Rails.env.production? | |
require 'fileutils' | |
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin")) | |
template_path_one = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/app/assets/stylesheets" | |
template_path_two = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/sass" | |
old_compile_path = "#{Rails.root}/public/stylesheets/admin" | |
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin" | |
Sass::Plugin::remove_template_location template_path_one |
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
Sample::Application.routes.draw do | |
# Route /a/b -> Foo::BarsController. This is useful | |
# when you need to conform to a certain url structure | |
# while using a controller that doesn't match that structure, | |
# eg. a controller supplied by a Rails engine. | |
scope '/a' do | |
resources :b, controller: 'bars', module: 'foo' | |
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
# These instructions are for Ruby 1.9.3 under rbenv. | |
# To install ruby-debug19 for ruby-1.9.3 you need to download the following gems from http://rubyforge.org/frs/?group_id=8883 | |
linecache19-0.5.13.gem | |
ruby_core_source-0.1.5.gem | |
ruby-debug19-0.11.6.gem | |
ruby-debug-base19-0.11.26.gem | |
#Then in your console |
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 Capybara | |
def Capybara.auto_save_and_open_page=(val) | |
@auto_save_and_open_page = !!val | |
end | |
def Capybara.auto_save_and_open_page? | |
@auto_save_and_open_page ||= false | |
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
client = Savon::Client.new do | |
# This can be a URL also | |
wsdl.document = "/Path/to/your.wsdl" | |
# These are optional, only if your WSDL sucks :) | |
wsdl.endpoint = "https://your_endpoint" | |
wsdl.namespace = "http://your_namespace" | |
certs = Akami::WSSE::Certs.new :cert_file => "/path/to/cert.crt", :private_key_file => "/path/to/private/key.pem", :private_key_password => "password" | |
wsse.sign_with = Akami::WSSE::Signature.new certs |
OlderNewer