Skip to content

Instantly share code, notes, and snippets.

@bmorwood
bmorwood / start-simple-python-server.sh
Last active August 29, 2015 13:57
start a simple Python web server
# Python 2.x:
python -m SimpleHTTPServer
#Python 3.x:
python -m http.server
@bmorwood
bmorwood / search-for-word.sh
Created March 13, 2014 19:29
search for words in files in current directory.
$ grep -ri "word" .
@bmorwood
bmorwood / clamp.js
Created March 14, 2014 01:28 — forked from kujon/clamp.js
/**
* Clamps a number. Based on Zevan's idea: http://actionsnippet.com/?p=475
* params: val, min, max
* Author: Jakub Korzeniowski
* Agency: Softhis
* http://www.softhis.com
*/
(function(){Math.clamp=function(a,b,c){return Math.max(b,Math.min(c,a));}})();
@bmorwood
bmorwood / keyboard-character-shortcuts.txt
Last active August 29, 2015 13:57
keyboard character shortcuts
alt+2=™ / ™
alt+r=® / ®
alt+g=© / ©
– / –
— / —
[alias]
lg1 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(green)%s%C(reset) %C(bold green)— %an%C(reset)%C(bold red)%d%C(reset)' --abbrev-commit --date=relative
lg2 = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(bold white)— %an%C(reset)' --abbrev-commit
lg = !"git lg1"
delete-merged-branches = "!f() { git checkout --quiet develop && git branch --merged | grep --invert-match '\\*' | xargs -n 1 git branch --delete; git checkout --quiet @{-1}; }; f"
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
@bmorwood
bmorwood / remove-white-space-line-breaks.js
Created July 30, 2014 12:28
replace whitespace and line breaks from string
String.replace(/(\r\n|\n|\r)/gm,"").replace(/\s+/g," ");
@bmorwood
bmorwood / git.txt
Created September 9, 2014 14:23
git prune - update the local branch information with remote branch informtion.
git remote prune -n
@bmorwood
bmorwood / love-your-terminal.sh
Created November 24, 2014 19:43
love-your-terminal.sh
# search your command-line history
history | grep 'querySelector'
# copy to clipboard
echo 'Hello World!' | pbcopy
# unzip an archive to the current directory
unzip -l images.zip
# find out what process are taking up the most memory
@bmorwood
bmorwood / gist:c11202cc081a54695f2a753efc3dfabb
Created April 26, 2016 01:12
Canadian province list; alphabetical, includes abbreviations, plain text and HTML versions
// Small version
var provinces = [
{plain:"Alberta",name:"Alberta",abbr:"AB"},
{plain:"British Columbia",name:"British Columbia",abbr:"BC"},
{plain:"Manitoba",name:"Manitoba",abbr:"MB"},
{plain:"New Brunswick",name:"New Brunswick",abbr:"NB"},
{plain:"Newfoundland &amp; Labrador",name:"Newfoundland &amp; Labrador",abbr:"NL"},
{plain:"Northwest Territories",name:"Northwest Territories",abbr:"NT"},
{plain:"Nova Scotia",name:"Nova Scotia",abbr:"NS"},
{plain:"Nunavut",name:"Nunavut",abbr:"NU"},