Skip to content

Instantly share code, notes, and snippets.

Avatar

Carin Meier gigasquid

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

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
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
<html>
<head>
</head>
<body>
<script type="text/javascript" src="/js/repl-test.js"></script>
</body>
</html>
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
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: https://github.com/ericnormand/spelling-jam
;; from Lambda Jam, Chicago, 2013: http://lambdajam.com/
;;
;; Clojure core.async introduction:
;; http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
@timf
timf / tiff-to-png.sh
Created Jun 20, 2013
Pass an X.tiff file to this --> X.png
View tiff-to-png.sh
#!/bin/bash
echoerr() { echo "$@" 1>&2; }
if [ "X" == "X$1" ]; then
echoerr "error: requires argument: path to .tiff file"
exit 1
fi
exe=`which sips`
@jimweirich
jimweirich / adhoc.sh
Last active Jul 22, 2017
Controlling multiple drones with a single Ruby program.
View adhoc.sh
# 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 192.168.1.100 netmask 255.255.255.0 up
View 0-build-opencv.sh
#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
@stuarthalloway
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)
(frinj-init!)
(use '[datomic.api :only (q db) :as d])