Skip to content

Instantly share code, notes, and snippets.

View kisai's full-sized avatar

Sergio Diaz kisai

  • UNOSQUARE
  • Mexico
View GitHub Profile
@robballou
robballou / someModule.js
Created October 29, 2014 23:04
Testing jQuery code in Mocha
// The hacky bit of this approach is that this module uses
// jQuery, but it is not referenced here. This is because I
// am populating it in the test via global namespace.
//
// In the browser this still works because I am adding jQuery
// via a Browserify transform (browserify-global-shim).
function someModule() {
}
modules.export = someModule;
@chaitanyagupta
chaitanyagupta / _reader-macros.md
Last active March 29, 2024 19:56
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@pithyless
pithyless / either.rb
Created March 27, 2012 14:44
Chaining Either for Ruby
# A chainable Either monad for Ruby
#
# Examples
#
# Either.right('s') >> proc { |s| Either.right(s + '-1') } >> proc { |s| Either.right(s + '-2') }
# #=> #<Either @left=nil, @right="s-1-2">
#
# Either.right('s') >> proc { |s| Either.left('error!') } >> proc { |s| Either.right(s + '-2') }
# #=> #<Either @left='error!', @right=nil>
#