Skip to content

Instantly share code, notes, and snippets.

View arichiardi's full-sized avatar

Andrea Richiardi arichiardi

View GitHub Profile
@arichiardi
arichiardi / profile.boot
Last active July 6, 2016 22:41
Profile.boot for postgres in a docker
(require '[boot.pod :as pod])
(def pod-deps '[[boot/core "2.6.0" :scope "test"]
[adzerk/env "0.3.0" :scope "test"]
[me.raynes/conch "0.8.0" :scope "test"]])
(deftask postgres
[t type VAL str "The build type as string"]
(let [pod (future (pod/make-pod (update-in (get-env) [:dependencies] into pod-deps)))]
(with-pass-thru _
@arichiardi
arichiardi / boot-rebase.clj
Last active September 29, 2016 21:46
Boot rebase task
;; https://github.com/boot-clj/boot/pull/398
(defn filter-tmpfiles
"Filter TmpFiles that match (a least one in) metadata-preds.
Metadata-preds is a set of functions which will receive a TmpFile and
tried not in a specific order. If no predicate in the set returns
true-y, the file is filtered out from the returned TmpFiles.
If invert is specified, the behavior is reversed."
([tmpfiles metadata-preds]
@arichiardi
arichiardi / boot-util.clj
Created January 29, 2016 21:08
Some util function for boot/files
(ns replumb.boot.util
(:require [clojure.java.io :as io]
[clojure.string :as string]
[boot.core :as core]
[boot.pod :as pod]
[boot.util :as util]
[clj-jgit.porcelain :as jgit])
(:import java.io.File
java.nio.file.Files
java.nio.file.attribute.FileAttribute

Keybase proof

I hereby claim:

  • I am arichiardi on github.
  • I am arichiardi (https://keybase.io/arichiardi) on keybase.
  • I have a public key ASBS7KDW38RUXMhxC2BOsMU5G9me2c2D119-vmmS8onFmwo

To claim this, I am signing this object:

@arichiardi
arichiardi / clojure_recur_sequences
Created April 13, 2015 11:38
Clojure partition w/ recur
(defn- part-iter
([n step step-coll part-coll i part parts]
(if (seq step-coll)
(if (and (seq part-coll) (< i n))
(recur n step step-coll (rest part-coll) (inc i) (cons (first part-coll) part) parts)
(let [nthrst (drop (int step) step-coll)]
(recur n step nthrst nthrst 0 nil (cons (reverse part) parts))))
(reverse (if (seq part)
(cons (reverse part) parts)
parts))))
@arichiardi
arichiardi / interop.clj
Last active July 26, 2016 15:33
Interop snippets
(ns
^{:author "Andrea Richiardi"
:doc "Bridge helpers between Clojure and Java."}
com.andrearichiardi.interop
(:require [clojure.reflect :refer [reflect]]
[clojure.string :refer [join]]))
(defn canonical-name
"Return the class' canonical name of an instance, or nil if the input is nil."
[^java.lang.Object instance]
@arichiardi
arichiardi / utils.clj
Last active August 29, 2015 14:04
Some snippet from my Clojure hacks.
(ns com.andrearichiardi.utils
(:require [clojure.java.io :as io]))
(defn make-file-from-resource [name] (io/file (io/resource name)))
(defn to-bit-representation [^java.lang.Double d]
(-> (Double/doubleToRawLongBits d) (java.lang.Long/toBinaryString)))
(defmacro with-private-fns [[ns fns] & tests]
"Refers private fns from ns and runs tests in context."