Skip to content

Instantly share code, notes, and snippets.

for v in system `rbenv versions --bare`; do RBENV_VERSION=$v ruby -v; done
@misfo
misfo / gist:3162165
Created July 23, 2012 06:03
Potential Ruby 1.9.3 bug - class variables set on the wrong class
$ RBENV_VERSION=1.9.3-p194 ruby -e 'p Object.class_variables; Class.new { def set() @@v = 11 end }.new.set; p Object.class_variables'
[]
-e:1: warning: class variable access from toplevel
[:@@v]
# Turns out it's was an intentional (?!?!?!) change: http://bugs.ruby-lang.org/issues/5544
@misfo
misfo / gist:3053737
Created July 5, 2012 13:42
When was Yale's 483rd reunion?
(ns reunions.core)
(defn- next-year
[years reunion-counts]
(let [this-year (inc (last (keys reunion-counts)))
reunion-counts (assoc reunion-counts this-year 0)
add-reunion (fn [counts year]
(let [abs-year (- this-year year)]
(if (contains? counts abs-year)
(update-in counts [abs-year] inc)
dscl . append /Groups/com.apple.access_ssh user $DUMMY_ACCOUNT
dscl . append /Groups/com.apple.access_ssh groupmembers `dscl . read /Users/$DUMMY_ACCOUNT GeneratedUID | cut -d " " -f 2`
def i_can_haz_namespaced_function?
false
end
"Completely unrelated object".send :i_can_haz_namespaced_function?
#=> false
# http://linux.die.net/man/1/gvim
/^[gm]?vi/
"-f"
"--nofork"
# http://www.gnu.org/software/emacs/manual/html_node/emacs/emacsclient-Options.html
"emacsclient"
!"-n"
!"--no-wait"
import re, string
from functools import partial
from clojure_types import Keyword, Symbol, UnknownObject, Vector
debug = False
re_symbol = re.compile(r"[-\w*+!?/<>&.]+")
re_keyword = re.compile(r":([-\w*+!?/<>&]+)")
re_number = re.compile(r"\-?\d+(\.\d+)?")
re_string = re.compile(r"\"(([^\\\"]|\\.)*)\"")
@misfo
misfo / session-doesnt-work.clj
Created December 21, 2011 15:01
wrap-session not working in a nested Moustache app
(ns tache-middlewares.core
(:use [net.cgrand.moustache]
[ring.handler.dump]
[ring.middleware.session]))
(def handler (app
["supa" &] (app
wrap-session
["set"] (fn [req] {:status 200, :body "set", :session {:thing 1}})
["dump"] handle-dump)))
window.Matt = {}
Matt.Printer = do ->
message1 = "Yo ho ho"
message2 = "Five dwarves"
print1 = ->
console.log message1
print2 = ->
console.log message2
@misfo
misfo / gist:1212371
Created September 12, 2011 20:51
Sublime Text Vintage mode wishlist
  • r<enter>
  • c{motion} should yank into the register
  • pasting over a visual mode selection should replace it and yank the replaced text into the register
  • ~