Skip to content

Instantly share code, notes, and snippets.

@jjcomer
jjcomer / json-middleware.clj
Created October 11, 2012 20:56
JSON Middleware
(defn- json-request?
[req]
(if-let [#^String type (:content-type req)]
(not (empty? (re-find #"^application/(vnd.+)?json" type)))))
(defn wrap-json-params [handler]
(fn [req]
(if-let [body (and (json-request? req) (:body req))]
(let [bstr (slurp body)
json-params (parse-string bstr)
@jjcomer
jjcomer / kahn.clj
Created May 10, 2013 18:25 — forked from alandipert/kahn.clj
Use disj
(use '[clojure.set :only (difference union intersection)])
(defn without
"Returns set s with x removed."
[s x] (disj s x))
(defn take-1
"Returns the pair [element, s'] where s' is set s with element removed."
[s] {:pre [(not (empty? s))]}
(let [item (first s)]
@jjcomer
jjcomer / personal.el
Last active December 26, 2015 05:28
Emacs dotfile
;;; personal.el -- Josh's EMACS config
;;
;;; Commentary:
;;
;; My config for Emacs, using the prelude settings pack.
;;
;;; License:
;;
;;The MIT License (MIT)
;;
@jjcomer
jjcomer / README.md
Created April 1, 2020 00:13
SCRIPT-8
@jjcomer
jjcomer / ants.clj
Created December 18, 2011 18:22
Ant Simulation -- From Clojure Concurrency Presentation
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ant sim ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
; which can be found in the file CPL.TXT at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
;As shown in the presentation: http://blip.tv/clojure/clojure-concurrency-819147