Skip to content

Instantly share code, notes, and snippets.

View evilsneer's full-sized avatar
🥭

evilsneer

🥭
View GitHub Profile

edit deploy repositories in defproject

  :plugins [[org.apache.maven.wagon/wagon-ssh-external "2.6"]]
  :deploy-repositories ^:replace [["releases" "scp://[email protected]/root/rel/"]
                                  ["snapshots" "scp://[email protected]/root/snap/"]]

and above defproject

(defn exit-function
[]
(println "\n\nShutting down leveldb-store\n\n")
(release leveldb-store))
(defn shutdown-hook
[fn]
(let [shutdown-thread (new Thread fn)]
(.. Runtime (getRuntime) (addShutdownHook shutdown-thread))))
@evilsneer
evilsneer / persistents.clj
Created May 14, 2019 10:32
persistents for Clojure
(ns module.persistents
(:require [clojure.java.io :as io]))
(defn >disk [location data]
(spit location (pr-str data)))
(defn <disk [location]
(if (.exists (io/file location))
(read-string (slurp cache-file))))
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %-5p - %m%n
site uri
(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})
# cd /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/lib/security
cd /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre/lib/security
keytool -importcert -alias amber -keystore cacerts -file ~/c.cer -trustcacerts -storepass changeit
for i in $(docker images -a | grep '<none>' | awk '{print $3}');do docker rmi -f $i;done
(defn nil-response->bad-request-response [handler]
(fn [& args]
(let [resp (apply handler args)]
(if (some? resp)
resp
responses/bad-request))))
(defn csv-data->maps [csv-data]
(map zipmap
(->> (first csv-data) ;; First row is the header
(map keyword) ;; Drop if you want string keys instead
repeat)
(rest csv-data)))
(defn transpose [m]
@evilsneer
evilsneer / to-csv.clj
Created April 8, 2021 10:58
Clojure seq of maps -> csv
(defn write-csv [writer row-data]
(let [columns (->>
row-data
first
(into (sorted-map))
keys)
headers (map name columns)
rows (->> row-data
(map (comp vals #(into (sorted-map) %))))]
(csv/write-csv writer (lazy-seq (cons headers rows)))))