Skip to content

Instantly share code, notes, and snippets.

@jbr
jbr / 0-notes.md
Created February 17, 2011 00:39
Tail recursion special-form for sibilant

Some caveats about this method:

  • The "call" in the name of _tco_ is a lie. It's tail recursion, not tail call optimization. I'll update the name if I include this in sibilant.
  • It drops some boilerplate (the _tco_ function) at the top, which is something I don't feel too good about.
  • It only works from a tail position — if you don't return (recur ...), it does nothing.

It can be enabled either globally:

(enable-tco)

(defun infinite-loop () (recur)) ;=> infinite loop, no stack

# I've been forgetting this long enough it's time to declare a memory
# failure and make the code adapt to my stupidity. I mean, why can't
# they all be plural *OR* singular?
namespace :test do
task :integrations => :integration
task :functional => :functionals
task :unit => :units
end
; A monad comprehension is a syntactic construct that translates
; synchronous-looking code into a callback-based implementation. Monads
; are a very general abstraction - which means that monad comprehensions
; have more expressive power than other sync-to-async code
; transformations.
; Here is an example that uses jQuery's $.get method to fetch resources:
(def post-with-author (id)
(for
@jbr
jbr / gmail-invite-sept-2004
Created January 24, 2014 21:44
Gmail invite September 2004
Jacob Rothstein has invited you to open a free Gmail account. The invitation
will expire in three weeks and can only be used to set up one account.
To accept this invitation and register for your account, visit
http://gmail.google.com/gmail/a-c811c932a5-60d08b256e-a0346e3ae6
Once you create your account, Jacob Rothstein will be notified with
your new @gmail.com address so you can stay in touch with Gmail!
If you haven't already heard about Gmail, it's a new search-based webmail
@jbr
jbr / keybase.md
Last active May 17, 2016 19:21
keybase.md

Keybase proof

I hereby claim:

  • I am jbr on github.
  • I am jbr (https://keybase.io/jbr) on keybase.
  • I have a public key ASBMUsjB3R8xKqlQ9-uqmVLnQPg9si550quYQU4GRXY4ago

To claim this, I am signing this object:

function project {
PROJECT_BASE=~/code
PROJECT_FILE=.jbr
if [ "$1" ]; then
PROJECT=$PROJECT_BASE/$1
if [ -d $PROJECT ]; then
touch $PROJECT_BASE/$1
elif [ $1 = "-" ]; then
project `ls -t1 $PROJECT_BASE|head -n2|tail -n1`
elif [ $1 = "list" ]; then
@jbr
jbr / in-a-bind.rb
Created May 19, 2014 21:09
bind and define rbx vs 2.1.2
class A
def method_from_a() :from_a end
end
class B < A
def method_from_b() :from_b end
end
module M
def method_from_m() :from_m end
function isType (type) {
return function (arg) {
return typeof(arg) === type;
};
}
function instanceOf (clazz) {
return function (arg) {
return arg instanceof clazz;
};
@jbr
jbr / tempfile-unlink-mocha.rb
Last active August 29, 2015 14:10
Why doesn't mocha stub Tempfile#unlink?
@jbr
jbr / crashreport
Created February 27, 2015 23:36
ObjectSpace.each_object {|o| p o}
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/CrashReporter
* /Library/Logs/CrashReporter
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
-- Control frame information -----------------------------------------------
c:0035 p:---- s:0133 e:000132 CFUNC :inspect