-
Simple made easy by Rick Hickey Author of Clojure
-
Why OO Sucks Erlang by Joe Armstrong Author of Erlang
-
execution in kingdom of nouns by Steve Yegge
-
Perception and Action by Stuart Halloway
-
Pure, functional JavaScript by Christian Johansen
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
Function.prototype.runOnBackgroundThread = function (aCallback) { | |
var _blob = new Blob(['onmessage = '+this.toString()],{"type":"text/javascript"}); | |
var _worker = new Worker((webkitURL.createObjectURL || URL.createObjectURL)(_blob)); | |
_worker.onmessage = aCallback; | |
_worker.postMessage(); | |
} | |
var _test = function () { | |
postMessage((1+1).toString()); | |
} |
This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.
Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:
getTweetsFor("domenic", function (err, results) {
// the rest of your code goes here.
Author: Gregg Lind glind@mozilla.com
example coverage report: http://gregglind.github.com/micropilot/coverreport.html
Quick Recipe:
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
#!/bin/sh | |
# | |
# An example hook script to verify what is about to be committed. | |
# Called by "git commit" with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
# | |
# Usage: | |
# Remove the .sh file extension when you put the script in your hooks folder! | |
# |
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 require = function (file, cwd) { | |
var resolved = require.resolve(file, cwd || '/'); | |
var mod = require.modules[resolved]; | |
if (!mod) throw new Error( | |
'Failed to resolve module ' + file + ', tried ' + resolved | |
); | |
var cached = require.cache[resolved]; | |
var res = cached? cached.exports : mod(); | |
return res; | |
}; |
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 cljs.core-test) | |
(defn test-stuff [] | |
(println "Starting tests") | |
;; js primitives | |
(let [keys #(vec (js-keys %))] | |
(assert (= [] (keys (js-obj)) (keys (apply js-obj [])))) | |
(assert (= ["x"] (keys (js-obj "x" "y")) (keys (apply js-obj ["x" "y"]))))) |
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
(load-file "../test/cljs/cljs/quick.cljs") | |
(run-tests) | |
(load-file "../test/cljs/cljs/core_test.cljs") | |
(test-stuff) |
Basic unit type:
λ> replTy "()"
() :: ()
Basic functions:
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
-------------------------- | |
-- CORE LIBRARY IMPORTS -- | |
-------------------------- | |
import Task exposing (Task, ThreadID, andThen, sequence, succeed, spawn) | |
import Json.Decode exposing (Decoder, list, int, string, (:=), map, object2) | |
import Signal exposing (Signal, Mailbox, mailbox, send) | |
import List | |
--------------------------------- | |
-- THIRD PARTY LIBRARY IMPORTS -- |