Skip to content

Instantly share code, notes, and snippets.

View evilsneer's full-sized avatar
🥭

evilsneer

🥭
View GitHub Profile
@evilsneer
evilsneer / count-distinct-csv.bb
Last active April 15, 2022 09:53
bb csv count distinct fields
(require '[clojure.data.csv :as csv]
'[clojure.tools.cli :refer [parse-opts]])
(def cli-options
;; An option with a required argument
[["-f" "--file FILE" "File path"
; :default 80
; :parse-fn #(Integer/parseInt %)
:validate [string? "Must be a string"]]
["-h" "--help"]])
@evilsneer
evilsneer / wget-site-get.sh
Created December 24, 2021 15:32
wget download full site
wget --recursive --no-clobber --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains "proekt.media,proektmedia-stat.ams3.digitaloceanspaces.com" --mirror -U "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)" www.proekt.media
@evilsneer
evilsneer / clojure sh.clj
Last active April 18, 2021 18:47
clojure sh utils
(defn- -l [host port path]
{:post [(= 0 (:exit %))]}
(->> (sh "ssh" (str user "@" host)
"-p" port
"cd" path
"&&"
"ls -l")))
(defn l-humanize [user host port path]
@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)))))
(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]
(defn nil-response->bad-request-response [handler]
(fn [& args]
(let [resp (apply handler args)]
(if (some? resp)
resp
responses/bad-request))))
for i in $(docker images -a | grep '<none>' | awk '{print $3}');do docker rmi -f $i;done
# 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
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,})
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