Skip to content

Instantly share code, notes, and snippets.

View mnemnion's full-sized avatar

Sam Atman mnemnion

  • Eastern Standard Tribe
View GitHub Profile
@mnemnion
mnemnion / gist:5315689
Created April 5, 2013 00:33
An invocation that gives a solid visual warning when you run under root in Terminal. Add to .profile in ~
export PS1="\u:\W 🔒 "
export SUDO_PS1="\u:\W ‼🔓 ‼ "
S = AB*
AB = A B
A = 'a'+
B = 'b'+
@mnemnion
mnemnion / caseify
Last active December 16, 2015 06:39
A bit of Clojure to make case-insensitive token match rules in ANTLR
(defn caseify [string]
(apply str (map (fn [foo] (apply str ["(" "'" (upper-case foo) "'" "|" "'" foo "'" ")"]))
(rest (split string #"")))))
(defn caseify [string]
(💬 (apply str (🌍 (fn [foo] (str "(" "'" (upper-case foo) "'" "|" "'" foo "'" ")"))
(rest (split string #""))))))
@mnemnion
mnemnion / jumpy.sh
Created August 18, 2013 00:18
A fancy little jumper script for bash. Easy keystroke access to frequent directories. jump/jp: go to a directory mark: make an alias unmark: delete an alias
# Fancy jump script
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2> /dev/null || echo "No such mark: $1"
}
function jp {
cd -P $MARKPATH/$1 2> /dev/null || echo "No such mark: $1"
}
function mark {
pat pan par pag
pit pin pir pig
pot pon por pog
put pun pur pug
mat man mar mag mit min mir mig
@mnemnion
mnemnion / init-stuff.el
Created September 27, 2013 21:00
some useful init.el
;;The User Button
(setq ns-function-modifier 'hyper) ; Jedi Superpowers activate
(setq max-specpdl-size 100000
max-lisp-eval-depth 100000) ;give your lisp a brain
(add-to-list 'load-path "~/.emacs.d/el-get/el-get")
@mnemnion
mnemnion / seq-string.clj
Created October 16, 2013 17:28
seq-string turns a string into a seq on the characters.
(defn seq-string
"make a string seqable by character"
[split-me]
(seq (drop 1 (clojure.string/split split-me #""))))
@mnemnion
mnemnion / dt.sh
Created July 16, 2016 02:25
Simple Bash functions: file -> .file, and .file -> file
#lazyfuncs for dotting and undotting stuff
function dt {
for file in "$@"; do
if [[ ${file:0:1} != "." ]]
then mv $file ".$file"
else echo "$file is already dotted"
fi
done
}
@mnemnion
mnemnion / jump.sh
Last active July 16, 2016 02:30
The essential 'jump' family of bash functions
#Essential jump code
export MARKPATH=$HOME/.marks
#jump to a directory
function jump {
cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
}
#mark the current directory as a jump destination
function mark {