Skip to content

Instantly share code, notes, and snippets.

View mnewt's full-sized avatar

Matthew Newton mnewt

View GitHub Profile
function levenshtein(s1, s2) {
// http://kevin.vanzonneveld.net
// + original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com)
// + bugfixed by: Onno Marsman
// + revised by: Andrea Giammarchi (http://webreflection.blogspot.com)
// + reimplemented by: Brett Zamir (http://brett-zamir.me)
// + reimplemented by: Alexander M Beedie
// * example 1: levenshtein('Kevin van Zonneveld', 'Kevin van Sommeveld');
// * returns 1: 3
@mnewt
mnewt / conf.nmap
Created February 19, 2013 05:30 — forked from sygo/conf.hexdump
# ip number
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
colours=bold yellow
======
# list header
regexp=(PORT|STATE|SERVICE|REASON|VERSION)
colours=bold white
======
# open
regexp=open
@mnewt
mnewt / grist.json
Last active December 13, 2015 19:28
blog.mnewton.com comments index
{ "localhost:3000/index.jade": 4963044 }
@mnewt
mnewt / Preferences.sublime-settings
Last active December 11, 2015 22:28 — forked from benatkin/Global.sublime-settings
tell Sublime Text to ignore files/directories matching these strings
{
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"]
}
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@mnewt
mnewt / merge.sh
Created January 22, 2013 20:30
How to Merge Folders on a Mac (copied from http://the.taoofmac.com/space/HOWTO/Merge%20Folders)
#!/bin/sh
# How to Merge Folders on a Mac
# (copied from http://the.taoofmac.com/space/HOWTO/Merge%20Folders)
# The standard UNIX way
cp -R -v source/. destination
# The geeky UNIX way (restartable)
rsync -vaEW source/ destination
# The OSX "easy" way
@mnewt
mnewt / zimbra.sh
Created January 1, 2013 06:29
zimbra reference
# zimbra should be administered using the zimbra user account
sudo su - zimbra
#re-run zimbra setup
/opt/zimbra/libexec/zmsetup.pl
# service status
zmcontrol status
# start services
@mnewt
mnewt / print_dom_tree1.js
Created December 18, 2012 20:12
print dom tree
<SCRIPT LANGUAGE="JavaScript">
<!--
// F. Permadi 2005.
// (C) F. Permadi
// Print DOM tree
////////////////////////////////////////////
// This function traverses the DOM tree of an element and prints the tree.
// This function called recursively until the DOM tree is fully traversed.
//
// Parameters:
@mnewt
mnewt / emacs.css
Created December 10, 2012 00:37 — forked from themactep/formtocookie.js
How to save form to cookies, restore form from cookies. Requires jQuery and jQuery Cookie plugin.
.highlight .hll { background-color: #ffffcc }
.highlight { background: #f8f8f8; }
.highlight .c { color: #008800; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #AA22FF; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .cm { color: #008800; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #008800 } /* Comment.Preproc */
.highlight .c1 { color: #008800; font-style: italic } /* Comment.Single */
.highlight .cs { color: #008800; font-weight: bold } /* Comment.Special */
@mnewt
mnewt / prose-vcprompt-virtualenv.sh
Created December 9, 2012 00:46
modified version of prose theme prompt for zsh/oh-my-zsh
# virtualenv
VIRTUAL_ENV_DISABLE_PROMPT="true"
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function vcprompt_info {
vcprompt --format-git "on ± %{$fg[magenta]%}%b%{$reset_color%}%{$fg[green]%}%u%m%a%{$reset_color%}" \
--format-hg "on ☿ %{$fg[magenta]%}%b%{$reset_color%}%{$fg[green]%}%u%m%{$reset_color%}" \
--format "on %s %{$fg[magenta]%}%b%{$reset_color%}%{$fg[green]%}%u%m%{$reset_color%}"