Skip to content

Instantly share code, notes, and snippets.

;variants of the code from point #2 of:
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses
;original
(apply merge-with +
(pmap count-lines
(partition-all *batch-size*
(line-seq (reader filename)))))

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@alexander-yakushev
alexander-yakushev / clojure-trivial-dialer.clj
Last active October 6, 2015 00:57
A simple demostration of neko.ui toolkit for building Android UI in Clojure
(ns test.leindroid.sample.main
(:use [neko.activity :only [defactivity set-content-view!]]
[neko.threading :only [on-ui]]
[neko.ui :only [make-ui]])
(:import android.widget.EditText
android.net.Uri
android.content.Intent))
(declare ^EditText edit
^android.app.Activity a)
@lynaghk
lynaghk / 0-build-opencv.sh
Created December 2, 2012 20:30
OpenCV in Clojure?
#Build OpenCV and the new Java JNI interface described here: https://github.com/emchristiansen/opencv/commit/0d323087fadaf931dbaf4120b69f0839b745b888
git clone git://github.com/Itseez/opencv.git
cd opencv
cmake -DBUILD_opencv_java=ON
ant jar
@jackrusher
jackrusher / SimpleMarkovChain.clj
Last active September 25, 2017 18:51
A very simple implementation of Markov chaining in Clojure.
(defn model-from-sequence
"Returns a transition matrix of 'depth' from 'sequence'"
[depth sequence]
(loop [accum {} chunks (partition (inc depth) 1 (seq sequence))]
(if (seq? chunks)
(let [chunk (first chunks)
prefix (drop-last chunk)
suffix (last chunk)]
(recur (assoc accum prefix (conj (get accum prefix []) suffix)) (next chunks)))
accum)))
@teropa
teropa / resources.md
Last active December 4, 2020 05:42
Clojure Resources

Tutorials

@Chouser
Chouser / externs_for_cljs.clj
Created June 17, 2013 13:44
Generate an externs.js file for arbitrary JS libraries for use in advanced Google Closure compilation, based on the ClojureScript code that uses the libraries.
(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)))))))
@favila
favila / restore_datoms.clj
Last active September 30, 2021 03:50
Restore a datomic database "manually", i.e. from raw datoms. Useful for memory databases. Context: https://groups.google.com/d/msg/datomic/BkTdKYB3WpE/AKfqKYqPONMJ
(ns favila.datomic-util.restore-datoms
"A \"manual\" datomic database restore.
Writes raw datoms (stored in a stream written by d/datoms) to an empty database.
Useful for memory databases: you can write out all the datoms in it, then read
them into another database. (Note mem dbs have no log or retractions)."
(:require [datomic.api :as d]
[clojure.edn :as edn]))
(defrecord datom [e a v tx added?])
@tomconnors
tomconnors / om-tutorial.cljs
Last active December 21, 2015 18:26
An attempt at adding routes to the Om Components, Identity, and Normalization tutorial
(ns om-tutorial.core
(:require [goog.dom :as gdom]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]))
(enable-console-print!)
(def init-data
{:list/one [{:name "John" :points 0}
{:name "Mary" :points 0}
@amalloy
amalloy / .gitattributes
Created April 10, 2017 16:56
Clojure-aware git-diff hunk headers
*.clj diff=clojure
*.cljs diff=clojure
*.cljx diff=clojure