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
;; On my box, wc processes the 11GB JSON file in 50sec | |
;; This code does it in 11sec | |
;; Compiled with lein uberjar, and run with java -server -jar word-count-STANDALONE.jar | |
(ns word-count.core | |
(:import (java.io RandomAccessFile File) | |
(java.nio.channels FileChannel$MapMode) | |
(java.nio ByteBuffer)) | |
(:gen-class)) |
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
(def data {:cards | |
[{:id "card-1", :idList "list-id-1", :name "Task 1"}], | |
:lists | |
[{:id "list-id-1", :name "List 1"} | |
{:id "list-id-2", :name "List 2"}]}) | |
(vec (o/for-query | |
(o/and | |
(d/query-in data _ [:lists _] ?list-item) | |
(d/query data ?list-item :id ?list-id) |
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 my-dsl-fn | |
([mp] | |
... do stuff with map ... | |
([k v & {:as mp}] | |
(my-dsl-fn (assoc mp k v)))) |
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 quil.cljshttp | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:refer-clojure :exclude [get]) | |
(:require [cljs-http.client :as http] | |
[cljs.core.async :refer [<!]])) | |
(def username (atom "someone")) | |
(defn get-from-server [login-name] | |
(go (let [response (<! (http/get "https://api.github.com/users/octocat/gists" {:with-credentials? false\ |
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
import time | |
class Reduced(object): | |
def __init__(self, itm): | |
self._itm = itm | |
def deref(self): | |
return self._itm | |
def reduced(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
(defn batch [max in] | |
(let [out (chan 1)] | |
(go-loop [out-coll []] | |
(when-some [v (<! in)] | |
(let [new-coll (concat out-coll v)] | |
(if (< (count new-coll) max) | |
(recur new-coll) | |
(do (>! out new-coll) |
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 other-examples.shapes-3d | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def red (ui/color :red 1 :blue 0 :green 0)) | |
(def green (ui/color :red 0 :blue 0 :green 1)) | |
(def blue (ui/color :red 0 :blue 1 :green 0)) | |
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5)) |
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 other-examples.shapes-3d | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def red (ui/color :red 1 :blue 0 :green 0)) | |
(def green (ui/color :red 0 :blue 0 :green 1)) | |
(def blue (ui/color :red 0 :blue 1 :green 0)) | |
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5)) |
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 other-examples.todo | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def main-font (ui/font :family "Helvetica" :size 20)) | |
(defui TodoItem | |
(render [this {:keys [done? idx text]}] | |
(ui/border-pane |
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 other-examples.todo | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def main-font (ui/font :family "Helvetica" :size 20)) | |
(defui TodoItem | |
(render [this {:keys [done? idx text]}] | |
(ui/border-pane |