Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
@technicalpickles
technicalpickles / gist:2026264
Created March 13, 2012 02:44
Fun with memory & profiling
%w(debug? info? warn? error? fatal?).map(&:to_sym).each do |level|
define_method level do
non_nil_loggers = @loggers.find_all{|l| l.level}
matching_loggers = non_nil_loggers.map{|l| l.send(level)}
matching_loggers.any?
end
end
var gif = document.location.toString().split('#')[0] + $('#gif img').attr('src');
var gifInput = '<input type="text" style="width: 100%" value="' + gif + '"/>';
$('body').prepend(gifInput);
@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