Skip to content

Instantly share code, notes, and snippets.

View jdunphy's full-sized avatar

Jacob Dunphy jdunphy

  • Google
  • Madison, WI
View GitHub Profile
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('//', '/')
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
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
##
# 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
# 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 }
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
require 'benchmark'
require 'rubygems'
require 'gruff'
require 'httparty'
require 'json'
class LoggedRequest
attr_reader :response_time, :path, :status
def initialize(request)
#!/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/"
require 'benchmark'
require 'rubygems'
require 'gruff'
require 'httparty'
require 'json'
class LoggedRequest
attr_reader :response_time, :path, :status
def initialize(request)
#!/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}`