Skip to content

Instantly share code, notes, and snippets.


Carin Meier gigasquid

View GitHub Profile
View switch.clj
(ns switch
(:require [clojure.pprint :as pprint]))
(defn project-clj-map [filename]
(->> (slurp filename)
(drop 1)
(partition 2)
(map vec)
(into {})))
reborg /
Last active Sep 29, 2021
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

ptaoussanis / transducers.clj
Last active Nov 18, 2020
Quick recap/commentary: Clojure transducers
View transducers.clj
(comment ; Fun with transducers, v2
;; Still haven't found a brief + approachable overview of Clojure 1.7's new
;; transducers in the particular way I would have preferred myself - so here goes:
;;;; Definitions
;; Looking at the `reduce` docstring, we can define a 'reducing-fn' as:
(fn reducing-fn ([]) ([accumulation next-input])) -> new-accumulation
;; (The `[]` arity is actually optional; it's only used when calling
;; `reduce` w/o an init-accumulator).
View index.html
<script type="text/javascript" src="/js/repl-test.js"></script>
View gist:5960953
(ns ml-jam.core
(:use clojure-csv.core))
(def training-data
(for [row (rest (parse-csv (slurp "./digitssample.csv")))]
(for [x row] ( Integer/parseInt x))))
(def check-data
(for [row (rest (parse-csv (slurp "./digitssample.csv")))]
(for [x row] ( Integer/parseInt x))))
stuartsierra / spellcheck.clj
Created Jul 9, 2013
Example implementation of Norvig's Spellchecker in Clojure, using core.async
View spellcheck.clj
;; Example implementation of Norvig's Spellchecker in Clojure,
;; using core.async
;; There are probably some bugs in this.
;; Original problem:
;; from Lambda Jam, Chicago, 2013:
;; Clojure core.async introduction:
timf /
Created Jun 20, 2013
Pass an X.tiff file to this --> X.png
echoerr() { echo "$@" 1>&2; }
if [ "X" == "X$1" ]; then
echoerr "error: requires argument: path to .tiff file"
exit 1
exe=`which sips`
jimweirich /
Last active Jul 22, 2017
Controlling multiple drones with a single Ruby program.
# This script should be run on the drone.
# Change the IP address to be difference
# for each drone on the same ad-hoc network
killall udhcpd
ifconfig ath0 down
iwconfig ath0 mode ad-hoc essid ardrone2_070401 channel auto commit
ifconfig ath0 netmask up
#Build OpenCV and the new Java JNI interface described here:
git clone git://
cd opencv
cmake -DBUILD_opencv_java=ON
ant jar
stuarthalloway / gist:1980351
Created Mar 5, 2012
frinj unit conversion running inside a Datomic datalog query
View gist:1980351
;; lein settings
(defproject foo "1.0.0-SNAPSHOT"
:description "Test App"
:dependencies [[com.datomic/datomic "0.1.2678"]
[frinj "0.1.2" :exclusions [org.clojure/clojure]]])
;; load libs
(use 'frinj.core 'frinj.calc)
(use '[datomic.api :only (q db) :as d])