Skip to content

Instantly share code, notes, and snippets.

View miner's full-sized avatar

Steve Miner miner

View GitHub Profile
@gfredericks
gfredericks / schema->gen.clj
Created March 26, 2014 16:49
Trying to generate test.check generators from prismatic schemas.
(ns schema->gen
"Functions for generating test data from schemas."
(:require [four.stateful :as four]
[re-rand :refer [re-rand]]
[schema.core :as sch]
[simple-check.generators :as gen]))
(defn ^:private re-randify-regex
"schema requires ^$ while re-rand forbids them"
[re]
(in-ns 'eclj.core)
(defprotocol Fn
:on-interface clojure.lang.Fn
"Marker interface indicating invokeables that are explictly functions")
(defprotocol IFn
:on-interface clojure.lang.IFn
(^{:on :invoke} -invoke
[this]
toccata
(def true)
(def false)
(def abort)
(def get-type)
(def type=)
(def subs)
(def number-str)
@gfredericks
gfredericks / test-check-perf.sh
Last active August 29, 2015 14:22
Instructions for benchmarking the 0.8.0-alpha3 release of test.check
#
# In your project.clj, make sure you're currently using test.check
# version 0.7.0, then add a plugins entry:
#
# :plugins [[com.gfredericks/corncob-cigar "0.1.4"]]
#
# Then run:
echo "Testing 0.7.0..." > test.check.log
lein do clean, benchmark-task 10 test 2>/dev/null | grep "Ran task 10 times" >> test.check.log
@alandipert
alandipert / paths.clj
Last active September 17, 2015 12:04
Enumerate paths into a nested map
;; Copyright (c) Alan Dipert. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; 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.
(defn paths
"Enumerate paths into a nested map."
([root]
@miner
miner / roman.clj
Created August 6, 2012 14:16
Roman Numerals
(ns miner.roman
(:require [clojure.test :refer :all]))
;; inspired by
;; http://www.jayway.com/2012/08/04/a-decimal-to-roman-numeral-converter-in-just-a-few-lines/
(def roman-map {1000 "M" 900 "CM" 500 "D" 400 "CD"
100 "C" 90 "XC" 50 "L" 40 "XL"
10 "X" 9 "IX" 5 "V" 4 "IV" 1 "I"})
@cgrand
cgrand / comprehensions.clj
Created May 24, 2013 14:06
Comprehension framework, upon which are (re)implemented, for, doseq, reducible/foldable for and reduce-based doseq
;; I wrote this in the Eurostar on my way back from the last lambdanext.eu clojure course.
(ns comprehensions
(:refer-clojure :exclude [for doseq])
(:require [clojure.core.reducers :as r]))
;; borrowed from clojure.core
(defmacro ^{:private true} assert-args
[& pairs]
`(do (when-not ~(first pairs)
------------
Conformances
------------
protocol AbsoluteValuable
Conformances:
Comparable
IntegerLiteralConvertible
SignedNumberType
@ohpauleez
ohpauleez / colorblock.sh
Last active September 9, 2016 15:24
Capture blocks of Clojure code in the paste buffer for making Keynote presentations
#!/usr/bin/env bash
## Given a Clojure source file, 'example.clj'
## Where the contents are captured by START and END comments like:
##
## ;;START SomeTagName
## (println (inc 2))
## ;;END
##
## Run this script: colorblock.sh example.clj SomeTagName
@cgrand
cgrand / kein.sh
Last active May 31, 2017 14:11
Launch a plain clojure repl according to project.clj without leiningen (most of the time)
#!/bin/bash
# launch a clojure plain repl but with options and classpath matching project.clj
# Except when project.clj changes (and on first launch), lein is not called.
CODE='
(let [p (leiningen.core.project/read)
args (@(var leiningen.core.eval/get-jvm-args) p)
cp (with-out-str (leiningen.classpath/classpath p))]
(print "ARGS=\"")
(apply print args)