Skip to content

Instantly share code, notes, and snippets.

View mustache_i18n.rb
class Stache18n
@@tags = {
'comment-and-close' => 'Comment and close',
'github' => 'GitHub',
'social-coding' => 'Social Coding'
def self.t
defunkt / gist:877708
Created Mar 19, 2011
Handing Mustache normal Ruby objects
View gist:877708
class Highlighter
def ruby(text)
"<pre class='ruby'>#{text}</pre>"
def python(text)
"<pre class='python'>#{text}</pre>"
defunkt / gist:877705
Created Mar 19, 2011 — forked from aumgn/gist:864853
Mustache Object Implementation
View gist:877705
class HighlighterHelper
def respond_to?(language)
def method_missing(language)
lambda { |text|
Highlighter.send(language, text)
defunkt /
Created Feb 28, 2011
Print the size of a minified & gzip'd js file.
#!/bin/sh -e
# Usage: jsize file.js
# Print the size of a minified & gzip'd js file.
# e.g.
# $ jsize src/facebox.js
# 1.4K
# Requires uglify-js
defunkt /
Created Feb 4, 2011
Easily grab a single file from GitHub.
# $ gh-get
function gh-get () {
curl -#O $(echo $1 | sed 's|blob|raw|')
defunkt /
Created Dec 29, 2010
—All You Zombies— by Robert A. Heinlein

All You Zombies

2217 Time Zone V (EST) 7 Nov. 1970--NTC-- "Pop's Place": I was polishing a brandy snifter when the Unmarried Mother came in. I noted the time---10:17 P. M. zone five, or eastern time, November 7th, 1970. Temporal agents always notice time and date; we must.

The Unmarried Mother was a man twenty--five years old, no taller than I am, childish features and a touchy temper. I didn't like his looks---I never had---but he was a lad I was here to recruit, he was my boy. I gave him my best barkeep's smile.

Maybe I'm too critical. He wasn't swish; his nickname came from what he always said when some nosy type asked him his line: "I'm an unmarried mother." If he felt less than murderous he would add: "at four cents a word. I write confession stories."

If he felt nasty, he would wait for somebody to make something of it. He had a lethal style of infighting, like a female cop---reason I wanted him. Not the only one.

View after-spec-merge
$ CACHED=1 ruby -rubygems -I lib benchmarks/speed.rb
Rehearsal ---------------------------------------------------
ERB w/ caching 0.190000 0.000000 0.190000 ( 0.200326)
HAML w/ caching 0.810000 0.010000 0.820000 ( 0.846492)
{{ w/ caching 0.840000 0.000000 0.840000 ( 0.842275)
------------------------------------------ total: 1.850000sec
user system total real
ERB w/ caching 0.190000 0.010000 0.200000 ( 0.194241)
HAML w/ caching 0.810000 0.010000 0.820000 ( 0.823237)
defunkt /
Created Jul 22, 2010
murder processes matching a pattern
# sh function to murder all running processes matching a pattern
# thanks 3n:
murder () {
ps | grep $1 | grep -v grep | awk '{print $1}' | xargs kill -9
defunkt / gist:449668
Created Jun 23, 2010 — forked from dustin/gist:397971
Emacs Lisp to automatically add, commit, and push when files change
View gist:449668
;; Automatically add, commit, and push when files change.
(defvar autocommit-dir-set '()
"Set of directories for which there is a pending timer job")
(defun autocommit-schedule-commit (dn)
"Schedule an autocommit (and push) if one is not already scheduled for the given dir."
(if (null (member dn autocommit-dir-set))
defunkt / pbcopy.rb
Created Jun 22, 2010
Copy a string to the pasteboard in MacRuby
View pbcopy.rb
def pbcopy(string)
pasteBoard = NSPasteboard.generalPasteboard
pasteBoard.declareTypes([NSStringPboardType], owner: nil)
pasteBoard.setString(string, forType: NSStringPboardType)