Skip to content

Instantly share code, notes, and snippets.

@dsapala
dsapala / 00_destructuring.md
Created September 2, 2016 14:11 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

@dsapala
dsapala / index.html
Created March 25, 2016 22:17 — forked from jazzido/index.html
Webcam barcode reading (zbar, emscripten)
<!DOCTYPE html>
<html>
<head>
<title>JS in-browser barcode reader</title>
<style type="text/css">
body > div {
position: relative;
width: 320px; height: 240px;
}
video { position: absolute; top: 0; left: 0; width: 320px; height: 240px; }
@dsapala
dsapala / namespace.coffee
Created April 6, 2012 11:02
namespaces on coffeescript
#
# http://stackoverflow.com/questions/8730859/classes-within-coffeescript-namespace
# from https://github.com/jashkenas/coffee-script/wiki/FAQ
# Code:
#
namespace = (target, name, block) ->
[target, name, block] = [(if typeof exports isnt 'undefined' then exports else window), arguments...] if arguments.length < 3
top = target
target = target[item] or= {} for item in name.split '.'
block target, top
@dsapala
dsapala / hack.sh
Created April 1, 2012 20:35 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@dsapala
dsapala / my_app_money.rb
Created February 5, 2012 18:49 — forked from nilakanta/my_app_money.rb
Use Money gem with mongoid (works with mongoid 2.1.0 and higher)
module MyApp
class Money
include Mongoid::Fields::Serializable
def cast_on_read?; true; end
def deserialize(object)
return nil if object.blank?
::Money.new(object[:cents] || object["cents"], object[:currency] || object["currency"])
end
@dsapala
dsapala / my_app_money.rb
Created January 29, 2012 20:24 — forked from nilakanta/my_app_money.rb
Use Money gem with mongoid (works with mongoid 2.1.0 and higher)
module MyApp
class Money
include Mongoid::Fields::Serializable
def cast_on_read?; true; end
def deserialize(object)
return nil if object.blank?
::Money.new(object[:cents] || object["cents"], object[:currency] || object["currency"])
end