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.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
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 ruby | |
# To make it work: | |
# - change account details to yours ( obviously ;) ) | |
# - install mechanize gem in version 1.0.0 ( gem install mechanize -v '1.0.0' ) | |
# - look for !!HERE!! comments in code in case you'd like to change default behavior | |
# - for best results run this script few times as hipchat / ruby openssl don't play together that well and | |
# there might be an exception thrown from time to time. Script should retry then but hey.. Nobody is perfect. | |
# .. and finally. Remember that other part should run this script as well to make history clean. |
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
var crypto = require("crypto") | |
var User = function(attributes) { | |
this._attributes = attributes || {} | |
} | |
User.KEY_LENGTH = 32 | |
User.WORK_FACTOR = 20000 | |
User.prototype.setPassword = function(password, callback) { |
- Get evaluation license key : http://my.datomic.com/eval/request
- Download pro version : http://downloads.datomic.com/pro.html
- Dev mode setup
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
var ngAppElem = angular.element(document.querySelector('[ng-app]') || document); | |
window.$injector = ngAppElem.injector(); | |
window.inject = $injector.invoke; | |
window.$rootScope = ngAppElem.scope(); | |
// getService('auth') will create a variable `auth` assigned to the service `auth`. | |
var getService = serviceName => | |
inject([serviceName, s => window[serviceName] = s]); |
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
bit = require "bit" | |
ev = require "ev" | |
ltn12 = require "ltn12" | |
socket = require "socket" | |
-- make protect and newtry coroutine friendly | |
socket.protect = (fn) -> fn | |
socket.newtry = (finalizer) -> | |
(...) -> |
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
(ns typed-play.core | |
(:require-macros [cljs.core.typed :as t]) | |
(:require [cljs.core.typed :as t])) | |
(t/ann my-identity (All [x] (Fn [x -> x]))) | |
(defn my-identity [x] | |
(if (number? x) | |
(inc x) | |
x)) |
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
(ns n01se.externs-for-cljs | |
(:require [clojure.java.io :as io] | |
[cljs.compiler :as comp] | |
[cljs.analyzer :as ana])) | |
(defn read-file [file] | |
(let [eof (Object.)] | |
(with-open [stream (clojure.lang.LineNumberingPushbackReader. (io/reader file))] | |
(vec (take-while #(not= % eof) | |
(repeatedly #(read stream false eof))))))) |