This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_key: > | |
reallylongbase64encodedstring | |
splitovermultiplelinesforthes | |
akeofmyhealthandforvim== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get RSpec-style let() in your Mocha/Jasmine specs. | |
*/ | |
var let = function (callback) { | |
var value, called = false; | |
var memoizer = function() { | |
if (called) { | |
return value; | |
} else { | |
called = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imagine something like: | |
var http = require('http') | |
, cache = require('cache') | |
; | |
var options = { | |
ignoreCookies: true, | |
cacheStatics: 300 // 5 minutes, unless an explicit cache-control header is given | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (each-fib fn) | |
(letrec | |
((next (lambda (a b) | |
(fn a) | |
(next b (+ a b))))) | |
(next 0 1))) | |
(define (take-n-fibs n) | |
(call/cc | |
(lambda (return) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Given two sets, return a new set containing the unique members from each. | |
(define (union set1 set2) | |
(letrec | |
((union | |
(lambda (set) | |
(cond | |
((null? set) set2) | |
((member? (car set) set2) | |
(union (cdr set))) | |
(else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; This was damn hard. | |
;; | |
;; One of the exercises near the end of The Little Schemer requires defining | |
;; a function that uses a collector to remove odd numbers, recursively from | |
;; a list, sum the odd numbers and multiple the even numbers. | |
;; | |
;; This is it. | |
;; | |
;; It requires currying lambdas one inside another to deal with the recursion | |
;; in the collector function. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" actually run as vim, not vi | |
set nocompatible | |
" 256-color terminal | |
set t_Co=256 | |
" utf-8 by default | |
set encoding=utf-8 | |
" vundle requires turning off filetypes momentarily |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Remove a given member from a list | |
(define rember | |
(lambda (a lat) | |
(cond | |
((null? lat) '()) | |
((eq? (car lat) a) (cdr lat)) | |
(else (cons (car lat) | |
(rember a (cdr lat))))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Instructions for use | |
# | |
# 1. Execute "time rails runner nil" a few times in your shell, see how long rails takes to boot | |
# 2. Add this monkey patch to the top of config/boot.rb | |
# 3. Repeat step 1. What's the difference? | |
# | |
# This is just an experiment, but it gains me 30% on Rails' start time, which suggests there is something | |
# in Rails that is breaking the "run only once" behaviour of #require. | |
# | |
# Note: You can't override Kernel#require, since Rails by-passes it most of the time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" actually run as vim, not vi | |
set nocompatible | |
" 256-color terminal | |
set t_Co=256 | |
" utf-8 by default | |
set encoding=utf-8 | |
" vundle requires turning off filetypes momentarily |