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 'rubygems' | |
| require 'httparty' | |
| require 'benchmark' | |
| require 'thread' | |
| class Google | |
| include HTTParty | |
| base_uri 'http://google.com' | |
| def self.benchmark |
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 update_main_artist | |
| artist = artists.first | |
| if rovi_artist | |
| artist = Artist.create(:name => rovi_artist.name) | |
| end | |
| update_attribute :main_artist_id, artist.id | |
| end | |
| def update_main_artist |
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
| pkill() { | |
| if [ $1 ]; then | |
| kill `ps -ef | grep $1 | grep -v 'grep' | awk '{print $2}'` | |
| fi | |
| } |
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 'whiskey_disk/rake' | |
| require 'whiskey_disk/helpers' | |
| namespace :deploy do | |
| ENV['to'] ||= 'staging' | |
| def verbose_cmd(cmd) | |
| system %(set -x && #{cmd}) | |
| 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
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'httparty' | |
| class FakeRestJsonApi | |
| include HTTParty | |
| base_uri 'http://google.com/THIS_IS_A_FAKE_URL' | |
| headers 'Accept' => 'application/json' | |
| default_params :output => 'json' |
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 ActionDispatch | |
| class ShowExceptions | |
| private | |
| def original_exception(exception) | |
| if registered_original_exception?(exception) | |
| exception.original_exception | |
| else | |
| exception |
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
| # Dicking around with various setups | |
| # We can define the custom hooks in the deploy rake task itself because | |
| # rake is still the main interface for deployments - no need for a | |
| # separate whiskey_disk_hooks.rb file | |
| require 'whiskey_disk/rake' | |
| # I don't love the way this turned out but the ideas is that WhiskeyDisk | |
| # provides a command-api to build local and remote commands. | |
| class GemCache < WhiskeyDisk::Command |
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
| Fabricate.class_eval do | |
| def self.attributes_for(name, options={}) | |
| fetch_schematic(name).attributes.inject({}) do |hash, attribute| | |
| value = attribute.value.respond_to?(:call) ? attribute.value.call : attribute.value | |
| hash.merge(attribute.name => value) | |
| end.merge(options) | |
| end | |
| private |
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 CachedImagesController < ApplicationController | |
| def show | |
| path = File.join(ImageUploader.cache_dir, params[:path], params[:name]) | |
| extension = File.extname(params[:name])[1..-1] | |
| headers['Cache-Control'] = 'public; max-age=300' | |
| send_data File.read(path), :disposition => 'inline', :type => Mime::Type.lookup_by_extension(extension) | |
| 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
| # Simple test to see how subprocesses handle signals. | |
| # The result is that the terminal sends the INTERRUPT signal to both the | |
| # main process and subprocesses. | |
| # If you use the `kill` command on the main process' pid, subprocesses don't | |
| # respond. | |
| def forking | |
| Signal.trap('INT') { puts "INT Trapped"; exit } | |
| 5.times do |