Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
@technicalpickles
technicalpickles / gist:1133074
Created August 8, 2011 23:51
[Draft] Fresh from the stills: moonshine_couchdb

Thanks to our friends at PeepCode, I'm happy to announce moonshine_couchdb, the moonshine way of managing couchdb.

Combine it with PeepCode's excellent CouchDB with Rails screencast, you will be relaxing with couch in no time.

Usage

moonshine_couchdb is pretty straightforward as far as things go. Install it as a Rails plugin:

@technicalpickles
technicalpickles / gist:1119603
Created August 2, 2011 04:27
rsync an iTunes Library to a new computer like a boss

Motivation

Shiny new MacBook Air, and I wanted to do this install from scratch (no TimeMachine recovery), but still get the good stuff from my old laptop. Also, rsync is awesome.

Prepare old computer

On old computer, from iTunes: File -> Library -> Organize Library and check Consolidate files.

@technicalpickles
technicalpickles / gist:1119488
Created August 2, 2011 02:40
errors on Lion with MacVim when switching between buffers
Error detected while processing function <SNR>31_ActivateBuffer:
line 6:
E684: list index out of range: 1
$ gem install bundler
ERROR: Could not find a valid gem 'bundler' (>= 0) in any repository
ERROR: Possible alternatives: bundler
$ gem install bundler
Fetching: bundler-1.0.15.gem (100%)
Successfully installed bundler-1.0.15
1 gem installed
Installing ri documentation for bundler-1.0.15...
Installing RDoc documentation for bundler-1.0.15...
class RegenerateRuntimeDependenciesList < ActiveRecord::Migration
def self.up
Dependency.find_each(:batch_size => 500) do |dep|
if dep.version
$redis.del(Dependency.runtime_key(dep.version.full_name))
dep.save
end
end
end
@technicalpickles
technicalpickles / controller.rb
Created April 22, 2011 04:34
timeout proxy object brainstorming
@video = timeout_after 5.seconds do
RemoteVideo.find(params[:id])
end
context 'when the claim fails to save' do
let :checkout do
checkout = Checkout::Base.new(:user => user, :offers => {offer.id => 3}, :root_offer_id => offer.id)
Claim.should_receive(:issue).with(offer, checkout, 3).and_return(claim)
claim.should_receive(:save).and_return(false)
checkout
end
it 'should add an error if the claim cannot be saved' do
[alias]
down = !sh -c 'open http://www.youtube.com/watch?v=qchPLaiKocI'
@technicalpickles
technicalpickles / gist:858471
Created March 7, 2011 12:53
fun with super
ree-1.8.7-2010.02 :001 > class Foo; def bar; super; end; end
nil
ree-1.8.7-2010.02 :002 > Foo.new.bar
NoMethodError: super: no superclass method `bar' for #<Foo:0x101bc7120>
from (irb):1:in `bar'
from (irb):2
ree-1.8.7-2010.02 :003 > class Foo; def bar; super if defined?(super); end; end
nil
ree-1.8.7-2010.02 :004 > Foo.new.bar
nil
@technicalpickles
technicalpickles / gist:839919
Created February 23, 2011 02:58
Rails 3 Application Template for making RVM, RVM gemsets, Passenger, and ruby-debug play nice-nice
file "config/setup_load_paths.rb", <<FILE
# based on http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError