This file contains hidden or 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
;; add the latest git revision to the uberjar file name | |
(defproject foo "4.3" | |
;;.... | |
:uberjar-name ~(str | |
"foo-%s" | |
(try | |
(str "-" |
This file contains hidden or 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 [clojure.string :as s] | |
(defn print-logo | |
" Prints a Cool logo " | |
[] | |
(letfn [(fn-str [& args] (s/join \newline args))] | |
(print (fn-str | |
"" | |
"" | |
"" |
This file contains hidden or 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
#stop all containers: | |
docker kill $(docker ps -q) | |
#remove all containers | |
docker rm $(docker ps -a -q) | |
#remove all docker images | |
docker rmi $(docker images -q) | |
#remove intermediate containers, use "build --rm" to avoid them |
This file contains hidden or 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
;;include [clj-tagsoup "0.3.0"] | |
(require '[pl.danieljanus.tagsoup :as tags]) | |
;; each node's structure is as such | |
;; [:tag attr-map node node ....] | |
(defn flatten [x] | |
(tree-seq (comp keyword? first) (partial drop 2) x)) |
This file contains hidden or 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
# http://web.archive.org/web/20111224041840/http://www.techsupportteam.org/forum/digital-imaging-photography/1892-worlds-smallest-valid-jpeg.html | |
FF D8 FF E0 00 10 4A 46 49 46 00 01 01 01 00 48 00 48 00 00 FF DB 00 43 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF C2 00 0B 08 00 01 00 01 01 01 11 00 FF C4 00 14 10 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF DA 00 08 01 01 00 01 3F 10 | |
# Base64 Encoded | |
/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wgALCAABAAEBAREA/8QAFBABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQABPxA= |
This file contains hidden or 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 '[clojure.java.io :as io]) | |
(def fp "/path/to/file") | |
(defn stream->bytes [is] | |
(loop [b (.read is) accum []] | |
(if (< b 0) | |
accum | |
(recur (.read is) (conj accum b))))) |
This file contains hidden or 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
(->> (ClassLoader/getSystemClassLoader) | |
.getURLs | |
(map #(.getFile %))) | |
;; Add a filter | |
(->> (ClassLoader/getSystemClassLoader) | |
.getURLs | |
(map #(.getFile %)) | |
(filter #(clojure.string/includes? % "resources"))) |
This file contains hidden or 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 clean.json | |
(:require | |
[clojure.data.json :as json] | |
[clojure.string :as s]) | |
(:refer-clojure :exclude [read read-string])) | |
(defn key->keyword [key-string] | |
(-> key-string | |
(s/replace #"([a-z])([A-Z])" "$1-$2") | |
(s/replace #"([A-Z]+)([A-Z])" "$1-$2") |
This file contains hidden or 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
;;; http://srfi.schemers.org/srfi-26/srfi-26.html | |
(defn ^:private cut* | |
[[a f] form] | |
(cond | |
(nil? form) [a f] | |
(seq? (first form)) | |
(let [[arg-list xform] (cut* [[] '()] (first form))] | |
(recur [(reduce conj a arg-list) (concat f (list xform))] (next form))) |
This file contains hidden or 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
(defmacro def-curry-fn [name args & body] | |
{:pre [(not-any? #{'&} args)]} | |
(if (empty? args) | |
`(defn ~name ~args ~@body) | |
(let [rec-funcs (reduce (fn [l v] | |
`(letfn [(helper# | |
([] helper#) | |
([x#] (let [~v x#] ~l)) | |
([x# & rest#] (let [~v x#] | |
(apply (helper# x#) rest#))))] |