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 / gobanrender.asy
Created March 27, 2010 23:31
Asymptote code that renders a Goban
// now a function, also, can draw to any picture not just currentpicture
void drawgoban(picture pic=currentpicture, int gobansize, int gobanlines=19) {
int gobancounter=gobanlines + 1;
unitsize(pic,gobansize/(gobancounter+1));
//Bounding Box and background
filldraw(pic,box((0,0),(gobancounter,gobancounter)),white,white);
@mnemnion
mnemnion / circles.html
Created January 25, 2013 23:58
A little ditty that renders a Chakra 12 board in canvas.
<html>
<head>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
var canvasWidth = parseInt(canvas.getAttribute("width"));
var canvasHeight = parseInt(canvas.getAttribute("height"));
var rds = canvasWidth/4;
@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 / e-tree-seq.clj
Last active November 3, 2020 18:32
a tree-seq function for enlive style trees or graphs in clojure. Made for instaparse, may not fit all cases.
(defn e-tree-seq
"tree-seqs enlive trees/graphs, at least instaparse ones"
[e-tree]
(if (map? (first e-tree))
(tree-seq (comp seq :content) :content (first e-tree))
(tree-seq (comp seq :content) :content e-tree)))
@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")