This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toccata | |
(def true) | |
(def false) | |
(def abort) | |
(def get-type) | |
(def type=) | |
(def subs) | |
(def number-str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------ | |
Conformances | |
------------ | |
protocol AbsoluteValuable | |
Conformances: | |
Comparable | |
IntegerLiteralConvertible | |
SignedNumberType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
OlderNewer