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.
This file contains 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
<!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; } |
This file contains 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
# | |
# 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 |
This file contains 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
#!/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 | |
# |
This file contains 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
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 |
This file contains 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
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 |