Skip to content

Instantly share code, notes, and snippets.

@mkb
mkb / gist:5051011
Created February 27, 2013 19:42
rvm install 2.0.0 w/MacPorts
[2013-02-27 11:35:52] /Users/mkb/.rvm/rubies/ruby-2.0.0-p0/bin/ruby
Exception `LoadError' at /Users/mkb/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1073 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /Users/mkb/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/rubygems.rb:1082 - cannot load such file -- rubygems/defaults/ruby
ERROR: Your gem push credentials file located at:
/Users/mkb/.gem/credentials
has file permissions of 0644 but 0600 is required.
You should reset your credentials at:
@mkb
mkb / gist:4760712
Created February 12, 2013 07:02
Background job processor requirements

Today @jdhuntington suggested writing a queuing system. This got me to thinking: What would I want in an ideal work queue? Here are some of my thoughts. I am eager to hear yours.

Key

Life without these has been difficut.

Reliable requeuing of failed jobs.

If a job craps out, don't just drop it on the floor. Keep re-trying until it succeeds. Bonus points for a configurable retry limit. Über bonus points for sending a notification when a job fails.

@mkb
mkb / .rvmrc
Created February 6, 2013 22:09
export rvm_path=$HOME/.rvm
rvm_gemset_create_on_use_flag=1
rvm_install_on_use_flag=1
export rvm_project_rvmrc=1
rvm_auto_reload_flag=1
rvm_keep_gemset_defaults_flag=1
rvm_without_gems=rubygems-bundler,rvm
rvm_with_gems=powder,awesome_print
if [[ $('uname') == 'Darwin' ]]; then
export CC=/usr/bin/gcc-4.2
@mkb
mkb / gist:4544259
Created January 16, 2013 02:57
Remove duplicate entries in Finder's "Open With" menu
/System/Library/Frameworks/ApplicationServices.framework/\Frameworks/LaunchServices.framework/Support/lsregister \-kill -r -domain local -domain system -domain user
killall Finder
@mkb
mkb / how_i_use_rspec.md
Created December 25, 2012 20:25
How I use RSpec

After writing tests with a lot of different pairs, hacking on a lot of existing tests, and reading various blog posts, I've settled on a set of RSpec practices which work well for me:

  1. Keep "it" blocks as small as practical. Strive for one assertion each.
  2. Invert dependencies as if your life depends on it.
  3. Nested describe blocks are your friends.
  4. Using "context" is sometimes more descriptive than "describe."
  5. A describe block for each method annoys the crap out of some people, but works well for me. Try it and let me know what you think.
  6. Don't retest behavior which is already verified in another nearby test.
  7. There's a matcher for that.
  8. Go ahead and say "test" instead of "spec" if you feel like it. The world won't end.
@mkb
mkb / Loopy.md
Created December 17, 2012 18:16

Loopy, et al

My cousin Craig asked about Loopy, the software I used for this track. Loopy is an easy to use loop recording app for iOS with an impressive demo video with Dub FX. Loopy was quick to pick up and fun to use. Layering loops was really easy, but I'll need practice before I can structure the loops into a real song.

The other software I used was:

@mkb
mkb / gist:4229114
Created December 6, 2012 22:36
Prepend to path, removing any duplicates present
prepend_path()
{
PATH=$1:$PATH
PATH="$(printf "%s" "${PATH}" | /usr/bin/awk -v RS=: -v ORS=: '!($0 in a) {a[$0]; print}')"
PATH="${PATH%:}"
export PATH
}
@mkb
mkb / foo.rb
Created November 16, 2012 20:15
Avoid printing directly to stdout to make testing easier.
class Foo
def bar(outstream)
outstream.puts "BAZ"
end
end
@mkb
mkb / stream_wrangler_spec.rb
Created October 24, 2012 01:03
Passing a block to RSpec's #stub
before do
@instream.stub(:read_nonblock) do
@called ||= 0
@called += 1
case @called
when 1
'monkey'
else
raise(EOFError)
@mkb
mkb / .gitconfig
Created October 13, 2012 01:10
.gitconfig
[branch]
autosetupmerge = true
[user]
name = Michael Brodhead
email = mkb@engineyard.com
[color]
ui = true
[push]
default = current