Skip to content

Instantly share code, notes, and snippets.

View bittersweet's full-sized avatar

Mark Mulder bittersweet

View GitHub Profile
bittersweet / gist:5634954
Created May 23, 2013 09:38
run ctags on current project and every gem
View gist:5634954
$ ctags -R --exclude=.git --exclude=log * ~/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/*
bittersweet / Array with instances benchmark
Created December 14, 2012 09:53
Quick Benchmark to check what kind of array 'slicing' performs well
View Array with instances benchmark
require 'benchmark'
class User
def initialize
@instance_var = rand(100)
users = []
10000.times do |i|
bittersweet / gist:3892492
Created October 15, 2012 13:34
Wrapping an instance method
View gist:3892492
module Instrument
def instrument(method)
alias_method "#{method}_old", "#{method}"
define_method method do |*args|
t =
send("#{method}_old", *args)
result = - t
p "#{method}: #{result} seconds"
bittersweet / gist:2249539
Created March 30, 2012 08:23
Mute OSX volume with MacRuby and AppleScript
View gist:2249539
framework "ScriptingBridge"
def volume(value)
volume = "set volume output volume #{value}"
applescript = NSAppleScript.alloc.initWithSource(volume)
result = applescript.executeAndReturnError(nil)
bittersweet / gist:1901637
Created February 24, 2012 15:28 — forked from stephankaag/gist:1901565
DataMapper collection bug
View gist:1901637
require 'rubygems'
dm_version = "=1.2.0"
gem "dm-core", dm_version
require 'dm-core'
gem "dm-migrations", dm_version
require 'dm-migrations'
class Thing
bittersweet / gist:1467545
Created December 12, 2011 14:40
autovivicating hash
View gist:1467545
def autovivicating_hash {|ht,k| ht[k] = autovivicating_hash}
x = autovivicating_hash
x["a"]["b"]["c"] = 1
bittersweet / gist:1219121
Created September 15, 2011 12:32
Creating a capped collection via the mongo ruby driver
View gist:1219121
require 'mongo'
m =
db = m['metric_io_development']
db.create_collection('incoming', {:capped => true, :max => 10})
bittersweet / gist:1211139
Created September 12, 2011 12:26
Goliath logger middleware
View gist:1211139
module Goliath
module Rack
class Logger
include Goliath::Rack::AsyncMiddleware
def initialize(app)
def call(env)
bittersweet / gist:998960
Created May 30, 2011 14:19
how to insert current file with vimscript
View gist:998960
function! InsertCurrentFile()
let filename = expand("%:p")
execute "normal a".filename
:call InsertCurrentFile
View faye debug chrome 11:25:16 [INFO] [Faye.Client] New client created for "" 11:25:16 [DEBUG] [Faye.Transport] Created new "callback-polling" transport for "" 11:25:16 [INFO] [Faye.Client] Initiating handshake with "" 11:25:16 [DEBUG] [Faye.Transport] Client undefined sending message to "": [{"channel":"/meta/handshake","version":"1.0","supportedConnectionTypes":["callback-polling"],"id":"1ginf3l17dssdu1g6u5of1yhkx9i"}] 11:25:16 [DEBUG] [Faye.Transport] Client undefined received from "": [{"id":"1ginf3l17dssdu1g6u5of1yh