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
| gem list | cut -d" " -f1 | xargs gem uninstall -aIx |
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
| # Let say we're defining method for #*_with_id here | |
| def method_missing(name, *args) | |
| super if name !~ /_with_id$/ | |
| define_method "#{name}_with_id" do | |
| instance_variable_get(:id) + "-" + instance_variable_get(:name) | |
| 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
| order = [1,2,3,4,5] | |
| params = [5,2,1,7,9] | |
| sort = order - (order - params) + (params - order) # => [1,2,5,7,9] |
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
| options = { :allow_destroy => false, :update_only => false } | |
| options.update(attr_names.extract_options!) | |
| options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only) | |
| options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank |
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
| CREATE DATABASE `database` CHARACTER SET utf8 COLLATE utf8_general_ci; |
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
| namespace :deploy do | |
| task :setup_solr_data_dir do | |
| run "mkdir -p #{shared_path}/solr/data" | |
| end | |
| end | |
| namespace :solr do | |
| desc "start solr" | |
| task :start, :roles => :app, :except => { :no_release => true } do | |
| run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids" |
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
| task :before_update_code do | |
| #stop solr: | |
| run "cd #{current_path} && rake sunspot:solr:stop RAILS_ENV=#{rails_env}" | |
| end | |
| after "deploy:update_crontab", "deploy:solr:symlink" | |
| namespace :solr do | |
| desc <<-DESC | |
| Symlink in-progress deployment to a shared Solr index. |
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 DSL | |
| def initialize &block | |
| @params = {} | |
| instance_eval &block | |
| end | |
| def param key, value | |
| @params[key] = value | |
| 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
| require 'aws' | |
| require 'trollop' | |
| opts = Trollop::options do | |
| opt :config, "amazon.yml config file path", :type => :string, :required => true | |
| opt :bucket, "bucket name", :type => :string, :required => true | |
| end | |
| AWS.config(YAML.load(File.read(opts[:config]))) |
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 parse data | |
| trips = get_trips data | |
| end | |
| def get_trips data | |
| trips = get_trips_data data | |
| trips.each do |trip| | |
| flight_sets = get_flight_sets trip | |
| end | |
| end |
OlderNewer