Skip to content

Instantly share code, notes, and snippets.

View mnewt's full-sized avatar

Matthew Newton mnewt

View GitHub Profile
@mnewt
mnewt / calendar.js
Last active March 23, 2017 22:56
Print a simple HTML calendar using javascript with no dependencies (except pure.css)
String.prototype.format = function() {
var args = arguments;
return this.replace(/{(\d+)}/g, function(match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
@mnewt
mnewt / bash_prompt.pure.sh
Created August 4, 2016 14:58
clean and simple bash prompt
#!/usr/bin/env bash
# Cygwin is special
if [ -z "${OSTYPE}" ]; then
case $(uname) in
"CYGWIN*") export OSTYPE='CYGWIN' ;;
'Darwin') export OSTYPE='Darwin' ;;
'Linux') export OSTYPE='Linux' ;;
esac
fi
#!/bin/bash
brew_command=/usr/local/bin/brew
brew_cask_command="$brew_command cask"
echo '#!/bin/bash'
echo ''
echo 'trap ctrl_c INT'
echo 'function ctrl_c() {'
echo 'echo "** Trapped CTRL-C"'
@mnewt
mnewt / plus_equals.fish
Created May 28, 2016 17:13
add numerical value to variable, like +=
function plus_equals --no-scope-shadowing
set -l __fish_value $$argv[1]
set $argv[1] (math $__fish_value + $argv[2])
end
@mnewt
mnewt / cljfmt.clj
Last active April 17, 2016 20:56 — forked from bartojs/build.boot
command line formatter for clojure using cljfmt
#!/usr/bin/env boot
;; Format files using cljfmt (https://github.com/weavejester/cljfmt)
(set-env! :dependencies '[[cljfmt "0.5.2"]])
(require '[cljfmt.core :as fmt]
'[clojure.java.io :as io])
(def help-text
"cljfmt: Format files using cljfmt (https://github.com/weavejester/cljfmt)
<?xml version="1.0" encoding="UTF-8"?>
<ulexpd:doPublish
xmlns:ulex="http://ulex.gov/ulex/2.0"
xmlns:ulexpd="http://ulex.gov/publishdiscover/2.0"
xmlns:ulexcodes="http://ulex.gov/codes/2.0"
xmlns:ulexlib="http://ulex.gov/library/2.0"
xmlns:j="http://niem.gov/niem/domains/jxdm/4.1"
@mnewt
mnewt / testing.clj
Created February 11, 2016 03:15
clj-xpath map issue with namespaces removed
(ns testing
(:require [clj-xpath.core :as xp]))
(def ^:dynamic xml-doc
(slurp "xml-test.xml"))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(xp/$x "//Person" xml-doc))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
@mnewt
mnewt / test.clj
Last active February 11, 2016 01:31
clj-xpath namespace map issue
(ns testing
(:require [clj-xpath.core :as xp]))
(def ^:dynamic xml-doc
(slurp "xmlns-test.xml")
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
(xp/$x "//lexsdigest:Person" xml-doc))
(xp/with-namespace-context (xp/xmlnsmap-from-root-node xml-doc)
@mnewt
mnewt / pw
Created April 17, 2015 03:49
Fun Password Generator
#!/usr/bin/env python3
"""
Generate random passwords. Mainly useful for copying and pasting
into password managers
"""
import argparse, random, string, sys, unicodedata, re
@mnewt
mnewt / JSONHighlight.css
Last active October 11, 2017 03:19
pretty print and syntax highlight javascript object
pre {outline: 1px solid #ccc; padding: 5px; margin: 5px; }
.string { color: green; }
.number { color: darkorange; }
.boolean { color: blue; }
.null { color: magenta; }
.key { color: red; }