Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
Block or report user

Report or block capitalist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:12021
a = %w(a b c d)
a.inject([]) {|arr,e| arr[-1]=='a' ? arr.insert(-2,e) : arr.push(e)}
View AliasMethodChainWheelGist.rb
# This Gist is here to explain the wonders of alias_method_chain
#
# It's also pulling double duty as an example of the gist method in training wheels.
#
# Some stuff about alias_method_chain... blah, blah blah
# Example: Ripped off from errtheblog
def render_with_benchmark(*args)
benchmark("Render call") do
render_without_benchmark(*args)
View rails_reporter.rb
class Reporter
class << self
def run_example_report(person,start_date,end_date)
sd_string = start_date.strftime("%Y%m%d")
ed_string = end_date.strftime("%Y%m%d")
filename = "#{person.name}_report_for_#{sd_string}_#{ed_string}"
self.run_report(filename,"EXAMPLE") do |sheet|
sheet.add_row [person.name]
View http-proxy-server.rb
# This is a trivial HTTP proxy server, intended for use as a troubleshooting tool
# ONLY (not for real, actual, production use). I wrote this because I couldn't find
# a simple HTTP proxy that I could use to test HTTP proxy support in Net::SSH.
#
# This code is in the public domain, so do with it what you will!
require 'socket'
server = TCPServer.new('127.0.0.1', 8080)
client = server.accept
View gist:65556
gem list '\A(?:(?:d[mo])[_-]|data_?(?:mapper|objects)|extlib)' --no-versions \
| xargs sudo gem uninstall -aIx
View gist:109362
# This is a code example for the Ruby HTTP library Typhoeus
# here's an example for twitter search
# Including Typhoeus adds http methods like get, put, post, and delete.
# What's more interesting though is the stuff to build up what I call
# remote_methods.
class Twitter
include Typhoeus
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
:on_failure => lambda {|response| puts "error code: #{response.code}"},
View .kindle_export.rb
# PRINT TO KINDLE in Mac OSX (for Kindle DX)
#
# HUH?
# - Kindle file depository:
# - drag any supported Kindle file to a local folder
# - file will be automatically transfered whenever Kindle is connected
# - "Print To Kindle" Print menu option (PDF):
# - when Kindle is connected it will print as PDF straight to the Kindle (from anywhere)
# - when Kindle is not connected, it will print to the local folder and is transfered as soon as Kindle is connected
View deploy.rb
# copy to your Capistrano recipe file
namespace :deploy do
task :clear_cached_assets, :roles => :web do
dir = "#{current_release}/public"
run %(rm #{dir}/javascripts/all.js #{dir}/stylesheets/master.css)
end
end
View iphone-tethering.mdown

HOWTO: iPhone AT&T Tethering

In 10 steps:

  • Update iTunes to 8.2 via Software Update
  • Update your iPhone to the 3.0 release (out today - June 17th)
  • Download this dmg and mount it: tethering file
  • Enable hidden carrier testing option (in Terminal.app): defaults write com.apple.iTunes carrier-testing -bool TRUE
  • Start up iTunes
You can’t perform that action at this time.