Skip to content

Instantly share code, notes, and snippets.

@jjcomer
jjcomer / README.md
Created April 1, 2020 00:13
SCRIPT-8
@jjcomer
jjcomer / keybase.md
Created May 20, 2015 16:58
keybase.md

Keybase proof

I hereby claim:

  • I am jjcomer on github.
  • I am jjcomer (https://keybase.io/jjcomer) on keybase.
  • I have a public key whose fingerprint is 8E60 EB2A 9A8F 5A4E 2146 3F4B 124D C290 7C94 9EF2

To claim this, I am signing this object:

@jjcomer
jjcomer / keybase.md
Last active August 29, 2015 13:58
keybase.md

Keybase proof

I hereby claim:

  • I am jjcomer on github.
  • I am jjcomer (https://keybase.io/jjcomer) on keybase.
  • I have a public key whose fingerprint is 951D BB52 4253 4B41 E48F 00BD 8FB0 6166 F8A9 582F

To claim this, I am signing this object:

@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 / 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 / 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 / columns.clj
Created August 8, 2012 00:38
Ordering columns
(def c-order
(let [order [:id :title :author :date :price]]
(zipmap order (range (count order)))))
(defn column-sort
[k1 k2]
(compare (get c-order k1 -1)
(get c-order k2 -1)))
(def test-data
@jjcomer
jjcomer / analysis.clj
Created January 29, 2012 12:02
Analysis of my Median Finding Algorithms
(ns median.analyze
(:use [median core]
[incanter core charts datasets stats]))
(defn test-lists
"Generate test lists applying f to p and n"
[n p f]
(map #(rand-list (f p %)) (range n)))
(defmacro time-it
@jjcomer
jjcomer / median.clj
Created January 29, 2012 11:53
Median Finding Algorithms
(ns median.core
(:use [clojure.math.numeric-tower :only [floor ceil]]))
(defn rand-list
"Generates a random vector of length n with unique
values inclusive 1 to exclusive n"
[n]
(shuffle (map inc (range n))))
(defn- median-skeleton
@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