Skip to content

Instantly share code, notes, and snippets.

View zerowidth's full-sized avatar

Nathan Witmer zerowidth

View GitHub Profile
Rubinius Crash Report #rbxcrashreport
Error: signal SIGSEGV
[[Backtrace]]
0 rbx 0x000000010000fb30 _ZN8rubiniusL12segv_handlerEi + 160
1 libSystem.B.dylib 0x00007fff88ee366a _sigtramp + 26
2 ??? 0x0000000000000643 0x0 + 1603
3 rbx 0x0000000100019beb _ZN8rubinius11InlineCache11empty_cacheEPNS_2VMEPS0_PNS_9CallFrameERNS_9ArgumentsE + 91
4 ??? 0x0000000102c7df92 0x0 + 4341620626
@zerowidth
zerowidth / api_hacks.rb
Created May 26, 2011 03:16
quick api hacks
# requires patron, nokogiri, map
class Api
Error = Class.new(StandardError)
class << self
attr_accessor :base_url
end
attr_reader :http
@zerowidth
zerowidth / orequals.rb
Created May 29, 2011 15:43
a demonstration of the ||= idiom
#!/usr/bin/env ruby -wKU
#
# a demonstration of the ||= idiom
#
# x ||= y
#
# is usually translated as
#
# x = x || y
#
@zerowidth
zerowidth / copy_rtf.vim
Created July 21, 2011 01:50
copy a vim buffer or selection as syntax-highlighted RTF to the clipboard
" copy the entire buffer or selected text as RTF
" inspired by https://github.com/dharanasoft/rtf-highlight
" but only uses commands available by default on OS X.
"
" To set html conversion options, :help TOhtml
" And, undocumented, to set the font used,
" let g:html_font="Your Preferred Font"
"
function! CopyRTF(line1,line2)
if !executable('textutil')
@zerowidth
zerowidth / example.rb
Created July 28, 2011 18:41
short circuiting and side effects
# as suggested by @mcmire, https://twitter.com/mcmire/status/96632723220869120
# and clarified in https://twitter.com/mcmire/status/96647536521129985
class Array
def thoroughly_all?(&block)
all_true = true
each {|obj| all_true &= yield(obj) }
all_true
end
# simple guardfile for vital testing workshop.
#
# $ gem install guard guard-rspec growl_notify
#
# put your code in lib/thing.rb
# and the specs in spec/thing_spec.rb
#
# then
#
# $ guard
@zerowidth
zerowidth / ar_pg_defaults.gemspec
Created October 4, 2011 16:11
Let postgres insert default values for columns with default values that AR 3.1 doesn't understand
Gem::Specification.new do |s|
s.name = "ar_pg_defaults"
s.version = "0.0.1"
s.platform = Gem::Platform::RUBY
s.author = "Nathan Witmer"
s.email = "nwitmer@gmail.com"
s.homepage = "https://gist.github.com/1262051"
s.summary = "Help AR let postgres do its thing"
s.description = "Let postgres insert default values for columns with default values that AR 3.1 doesn't understand"
@zerowidth
zerowidth / cleanup.sh
Created February 28, 2012 22:26
git cleanup script
#!/bin/bash
# inspired by https://gist.github.com/1564252
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
RESET=$(tput sgr 0)
function header() {
@zerowidth
zerowidth / rage.coffee
Created March 24, 2012 22:06
jointhecolorwar rage face
# npm install socket.io-client canvas
io = require "socket.io-client"
util = require "util"
fs = require "fs"
Canvas = require "canvas"
EventEmitter = require("events").EventEmitter
class Pixels extends EventEmitter
constructor: ->
@zerowidth
zerowidth / gist:2430323
Created April 20, 2012 17:06 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#