View octopress-to-cryogen.clj
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
(require '[clojure.java.io :as io] | |
'[clojure.string :as string] | |
'[clojure.tools.cli :refer [parse-opts]]) | |
(def cli-options | |
[["-o" "--out DIR" "Output directory" | |
:default "out"] | |
["-s" "--source SOURCE" "Source directory" | |
:default "source/_posts"] | |
["-h" "--help"]]) |
View download-blob.cljs
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
;; heavily inspired by Mariano Guerra | |
;; http://marianoguerra.org/posts/download-frontend-generated-data-to-a-file-with-clojurescript.html | |
(defn download-blob [file-name blob] | |
(let [object-url (js/URL.createObjectURL blob) | |
anchor-element | |
(doto (js/document.createElement "a") | |
(-> .-href (set! object-url)) | |
(-> .-download (set! file-name)))] | |
(.appendChild (.-body js/document) anchor-element) | |
(.click anchor-element) |
View monads.clj
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
; A simple demo of monadic composition of side effects | |
; Program to take 3 nubers as input and print their sum. | |
(defn read-and-add! | |
[prev] | |
(print "Enter a number: ") | |
(+ prev (do (flush) | |
(Integer/parseInt (read-line))))) | |
(defn bind |
View flatten-maps.clj
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
(defn get-key | |
[prefix key] | |
(if (nil? prefix) | |
key | |
(str prefix "-" key))) | |
(defn flatten-map-kvs | |
([map] (flatten-map-kvs map nil)) | |
([map prefix] | |
(reduce | |
(fn [memo [k v]] |
View jjs-require.js
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
// Based on https://github.com/nodyn/jvm-npm | |
"use strict"; | |
(function() { | |
var System = java.lang.System, | |
File = java.io.File, | |
FileInputStream = java.io.FileInputStream, | |
StringBuilder = java.lang.StringBuilder, | |
BufferedReader = java.io.BufferedReader, | |
InputStreamReader = java.io.InputStreamReader; |
View git.clj
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 org.ozias.git | |
(:require [me.raynes.conch :refer (with-programs)])) | |
(def ^:private git-porcelain | |
["add" "am" "bisect" "branch" "bundle" "checkout" "cherry-pick" "citool" | |
"clean" "clone" "commit" "describe" "diff" "fetch" "format-patch" | |
"gc" "grep" "gui" "init" "log" "merge" "mv" "notes" "pull" "push" | |
"rebase" "reset" "revert" "rm" "shortlog" "show" "stash" "status" | |
"submodule" "tag"]) |
View boot.cljs
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
(defn handle-file-select [evt] | |
(.stopPropagation evt) | |
(.preventDefault evt) | |
(let [files (.-files (.-dataTransfer evt))] | |
(dotimes [i (.-length files)] | |
(let [rdr (js/FileReader.) | |
the-file (aget files i)] | |
(set! (.-onload rdr) | |
(fn [e] | |
(let [file-content (.-result (.-target e)) |
View latency.txt
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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
View express-sample.cljs
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 express_sample | |
(:require [cljs.nodejs :as node])) | |
(def express (node/require "express")) | |
(def app (. express (createServer))) | |
(defn -main [& args] | |
(doto app | |
(.use (. express (logger))) | |
(.get "/" (fn [req res] |