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 'json' | |
class LoggedRequest | |
attr_reader :response_time, :path, :status | |
def initialize(request) | |
if request =~ /\"[A-Z]{3,4}\ (.+)\ HTTP/ | |
@path = $1.gsub('//', '/') |
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 Fancy | |
def self.test | |
puts "Ask me a question:" | |
t = gets | |
puts "You said: #{t}" | |
puts "What about this other thing?" | |
t2 = gets | |
puts "Now you said: #{t2}" | |
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
def socket | |
%return @sock if @sock and not @sock.closed? | |
@sock = nil | |
# If the host was dead, don't retry for a while. | |
return if @retry and @retry > Time.now | |
# Attempt to connect if not already connected. | |
begin |
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 a server to handle the request based on a hash of the key. | |
def get_server_for_key(key, options = {}) | |
raise ArgumentError, "illegal character in key #{key.inspect}" if | |
key =~ /\s/ | |
raise ArgumentError, "key too long #{key.inspect}" if key.length > 250 | |
raise MemCacheError, "No servers available" if @servers.empty? | |
return @servers.first if @servers.length == 1 |
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
# Executes the block with auditing disabled. | |
# | |
# Foo.without_auditing do | |
# @foo.save | |
# end | |
# | |
def without_auditing(&block) | |
auditing_was_enabled = auditing_enabled | |
disable_auditing | |
returning(block.call) { enable_auditing if auditing_was_enabled } |
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 @geo_locations.blank? | |
params.merge!( MobHelper::LOCATION_NEXT_CTRL => 'search' ) | |
params.merge!( MobHelper::LOCATION_NEXT_ACT => 'search_brand' ) | |
params.merge!( :controller => 'location' ) | |
params.merge!( :action => 'find_location' ) | |
params.merge!( :only_path => true ) | |
params.merge!( :search_term => @search_term ) | |
params.merge!( :search_key => @search_key ) | |
redirect_to params | |
return |
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' | |
require 'rubygems' | |
require 'gruff' | |
require 'httparty' | |
require 'json' | |
class LoggedRequest | |
attr_reader :response_time, :path, :status | |
def initialize(request) |
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/bash -e | |
if [[ -z "$1" ]] | |
then | |
echo "Usage: $0 <server.datacenter (e.g. prod2.wc1)>" | |
exit 1 | |
fi | |
print_json_response "http://$1.yellowpages.com:7000/_priv/sysinfo/" |
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' | |
require 'rubygems' | |
require 'gruff' | |
require 'httparty' | |
require 'json' | |
class LoggedRequest | |
attr_reader :response_time, :path, :status | |
def initialize(request) |
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 | |
find = ARGV[0] | |
replace = ARGV[1] | |
unless find && replace | |
puts "You must provide two arguments, find-and-replace <find> <replace>" | |
exit | |
end | |
list = `ack-grep #{find}` |