Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
@rubiii
rubiii / how_it_works.md
Created December 2, 2012 11:14
MacVim-Formatter for RSpec
$ rspec --format MacVimFormatter --color spec
@jimweirich
jimweirich / soap.txt
Created November 22, 2012 09:17
Results of an Informal Twitter Survey on the State of the Art for Ruby SOAP Clients
Today I ran a quick twitter poll asking: "What is the state of the art
in Ruby SOAP clients".
Savon (http://savonrb.com/) was by far the big winner with 29
recommendations.
Surprisingly Soap4r actually got 6 votes, but most were accompanied by
comments like "the last time I used SOAP". It was also the only entry
that got negative votes (3) with comments like "soap4r is broken and
crap by the way".
@masonforest
masonforest / gist:4048732
Created November 9, 2012 22:28
Installing a Gem on Heroku from a Private GitHub Repo

Installing a Gem on Heroku from a Private GitHub Repo

Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.

Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.

  1. Get an OAuth Token from GitHub

First you will need to get an OAuth Token from GitHub using your own username and "note"

@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@ahoward
ahoward / render.rb
Created August 20, 2012 17:19
rendering outside a controller
av = ActionView::Base.new(Rails.application.config.paths['app/views'].first)
### av.controller = Current.mock_controller # gem install rails_current
av.render( :locals => {:model => Model.first}, :partial => "shared/model" ) #=> string
@andkerosine
andkerosine / raskell.rb
Created August 15, 2012 05:56
Haskell-like list comprehensions in Ruby
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@
@ahoward
ahoward / backup.rake
Created July 17, 2012 20:04
lib/tasks/backup.rake
## file : RAILS_ROOT/lib/tasks/backup.rake
namespace('backup') do
namespace('dump') do
##
desc 'backup:dump:all'
task('all' => %w( dump:schema dump:tables dump:assets ))
##
desc 'backup:dump:schema'
@ahoward
ahoward / Capfile.rb
Created July 16, 2012 17:19
lib/tasks/jobs.rake, config/schedule.rb, Capfile
## maybe we have background tasks running...
#
namespace :jobs do
task :restart do
run("cd #{ deploy_to }/current && ./script/jobs restart; true")
end
task :start do
run("cd #{ deploy_to }/current && ./script/jobs start; true")
end
@ahoward
ahoward / job.rb
Created July 16, 2012 17:13
app/models/job.rb
#
# this module encapsulate the interface expected by DelayedJob, and Resque -
# if you use it your app will not need to change if you change background
# processing systems. it also centralizes and makes easy to test all
# potential background jobs independently of your preferred system.
#
# all jobs are stored in the db, but a queueing system, like resque, is used
# to run them in the background. this way the job class can support a rich
# query interface and persistence regardless of the background processing
# system used.
@mrmemes-eth
mrmemes-eth / decent_decorator.rb
Created June 1, 2012 19:17
Simple monkey patch for decent_exposure's nu_nu branch to add automatic decoration of singular resources. Throw this in config/initializers and monkey patch your way to victory! Assumes a module like the one included.
class DecentExposure::ActiveRecord::Finder
def decorated_singular_resource
singular_resource.extend("#{singular_resource.class.name}Decorator".constantize)
rescue NameError
singular_resource
end
def resource
if plural?