Skip to content

Instantly share code, notes, and snippets.

View gigasquid's full-sized avatar

Carin Meier gigasquid

View GitHub Profile
(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 February 23, 2024 13:09
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
ptaoussanis / transducers.clj
Last active December 17, 2021 13:54
Quick recap/commentary: Clojure transducers
(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).
@ktsujister
ktsujister / index.html
Last active December 20, 2015 19:38 — forked from kohyama/README.md
<html>
<head>
</head>
<body>
<script type="text/javascript" src="/js/repl-test.js"></script>
</body>
</html>
(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 July 9, 2013 01:47
Example implementation of Norvig's Spellchecker in Clojure, using core.async
;; 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 June 20, 2013 01:55
Pass an X.tiff file to this --> X.png
#!/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 July 22, 2017 18:47
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 192.168.1.100 netmask 255.255.255.0 up
@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
@stuarthalloway
stuarthalloway / gist:1980351
Created March 5, 2012 18:56
frinj unit conversion running inside a Datomic datalog query
;; 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])