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
;; Originally dual licensed under EPL 1.0 and AGPL 3. | |
(import 'org.apache.logging.log4j.ThreadContext) | |
(defn capture-logging-context [] | |
(into {} (ThreadContext/getContext))) | |
;; Modified from withdrawn library: | |
;; https://github.com/malcolmsparks/clj-logging-config/blob/master/src/main/clojure/clj_logging_config/log4j.clj | |
(defmacro with-logging-context [x & body] |
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
(defn column-names-seq | |
"Given an alphabet string generate a lazy sequences of column names | |
e.g. | |
`(column-names-seq \"abcdefghijklmnopqrstuvwxyz\") ;; => (\"a\" \"b\" \"c\" ... \"aa\" \"ab\")`" | |
[alphabet] | |
(->> (map str alphabet) | |
(iterate (fn [chars] | |
(for [x chars | |
y alphabet] | |
(str x y)))) |
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 | |
":";grafter='grafter {:mvn/version "0.11.5"}' | |
":";cli='org.clojure/tools.cli {:mvn/version "0.3.7"}' | |
"exec" "clojure" "-Sdeps" "{:deps {$grafter $cli}}" "$0" "$@" | |
(require '[grafter.rdf :as rdf]) | |
(require '[grafter.rdf.io :as rio]) | |
(require '[clojure.java.io :as io]) |
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 clojure -Sdeps {:deps,{clj-time/clj-time,{:mvn/version,"0.14.4"}}} | |
(require '[clj-time.core :as t]) | |
(println (t/now)) | |
(println "Received command line arguments " *command-line-args*) |
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 ring-file-upload.core | |
(:require [ring.adapter.jetty :as jetty]) | |
(:require [ring.middleware.multipart-params :as mp] | |
[ring.middleware.params :as param])) | |
(defn handler [request] | |
{:status 200 | |
:headers {"Content-Type" "text/plain"} | |
:body (str "REQ: " (prn-str request))}) |
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
(require '[grafter.rdf.io :as gio]) | |
(defn every-quad-valid? | |
"Test coercing quads to sesame statements, raises an exception with | |
a very useful error message if it fails." | |
[quads] | |
(every? gio/IStatement->sesame-statement quads)) |
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
(defmulti foo identity) | |
(defmethod foo :foo [_] :foo) | |
(defmethod foo :bar [_] :bar) | |
(derive :foo-child :foo) | |
(derive :bar-child :bar) | |
(defn supported-parameter? |
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
(def h (atom (make-hierarchy))) | |
(defmulti foo identity :hierarchy h) | |
(defmethod foo :foo [_] :foo) | |
(defmethod foo :bar [_] :bar) | |
(swap! h derive :foo-child :foo) | |
(swap! h derive :bar-child :bar) |
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
node { | |
checkout scm | |
stage('Test') { | |
sh 'pwd' | |
sh 'pwd > pwd-out' | |
sh 'lein test' | |
} | |
stage('Install') { |
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 specing.uri | |
(:require [clojure.spec :as s])) | |
;; crude specing of URI/URL objects - rules are actually more complex & nuanced | |
;; than this ... just experimenting with clojure.spec rather than adding it for | |
;; real... though when I do it will probably be in grafter.url / core.rdf | |
(def domain? string?) |
NewerOlder