Skip to content

Instantly share code, notes, and snippets.

View mangosmoothie's full-sized avatar

Nathan Lloyd mangosmoothie

View GitHub Profile
@mangosmoothie
mangosmoothie / pretty git log
Created November 20, 2017 22:10
pretty git log for .*rc file
alias lg="git log --color --pretty=format:'%C(auto)%h %Cred %<(10,trunc)%an %Creset%C(auto)%s %Cgreen(%cr,%ar) %Creset%C(auto)%d'"
@mangosmoothie
mangosmoothie / bash-log-wrapper.sh
Last active September 22, 2017 22:05
function to log & print output of bash commands while preserving exit codes
#!/bin/bash
# function to wrap a command with logging that also returns
# the status code of the command
function run() {
echo "running $@" |& tee -a out.log
eval $@ > >(tee -a out.log) 2> >(tee -a out.log)
return $?
}
//counts instances of words that start with EDRIVE. stripping ; or ) off the end
grep -re 'EDRIVE\.' * |sed -e 's/.* \(EDRIVE\.[^ \);]*\).*/\1/' |sort |uniq -c
@mangosmoothie
mangosmoothie / nested-map-destructuring.clj
Last active April 2, 2019 14:20
clojure nested map destructuring
;;input [:app :env config-{}]
(defn download-archive
[app env
{:keys [build-number build-name workdir]
{:keys [base-url archive-api archive-type archive-input-regex user pass]} :artifactory
{{{:keys [regex]} app} env} :deploy}]
(write-stream {:in (io/input-stream
(get-archive-response-body
{:uname user
@mangosmoothie
mangosmoothie / decode_base64.clj
Last active January 4, 2018 21:57
Clojure decode Base64 string
;; requires >= jdk 1.8
(defn decode-base64 [to-decode]
(String. (.decode (java.util.Base64/getDecoder) to-decode)))
@mangosmoothie
mangosmoothie / encode_base64.clj
Last active January 4, 2018 21:56
Clojure encode Base64
;; requires >= jdk 1.8
(defn encode-base64 [to-encode]
(.encodeToString (java.util.Base64/getEncoder) (.getBytes to-encode)))
@mangosmoothie
mangosmoothie / untar.clj
Created July 25, 2016 21:51
clojure untar
(ns untar
(:import (org.apache.commons.compress.archivers.tar TarArchiveInputStream)
(java.io File)
(java.io FileOutputStream)
(java.io FileInputStream)))
(defn untar-file
"untar file and save to location - preserving filenames"
[zipfile outdirpath]
(let [buffer (byte-array 1024)