Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
# Neater Github gem dependencies for Rails
module GithubGem
def github_gem(gem_name, opts={})
lib_name = gem_name.split('-', 2)[1]
self.gem gem_name, {:lib => lib_name, :source => 'http://gems.github.com'}.merge(opts)
end
end
Rails::Initializer.run do |config|
module PythonishDecorator
def method_added(name)
return unless @decorations
decorations = @decorations.dup
@decorations = nil
alias_method "undecorated_#{name}", name
define_method(name) do |*args|

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
# 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
# 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
# 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}"},
@capitalist
capitalist / gist:65556
Created February 17, 2009 03:20 — forked from dkubb/gist:31187
gem list '\A(?:(?:d[mo])[_-]|data_?(?:mapper|objects)|extlib)' --no-versions \
| xargs sudo gem uninstall -aIx
# 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
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]