Skip to content

Instantly share code, notes, and snippets.

View matthewhochler's full-sized avatar

Matt H matthewhochler

View GitHub Profile
@matthewhochler
matthewhochler / omnifocus_bookmarklet.js
Last active August 29, 2015 13:56 — forked from al3xandru/gist:1169583
OmniFocus Generalized Bookmarklet
javascript:(function(){
var enc=encodeURIComponent,
w=window,
frames=w.frames,
d=document,
tn=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),
pu=w.location.href,
isGMail=w.location.host.match(/mail\.google\.com/),
tt=pt=d.title,
subjSpans=d.getElementsByClassName("hP"),i,url;

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/bash
# Setup deployment target for Nginx + Python/uWSGI + Supervisor + Git
# From: https://gist.github.com/1210041
function usage() {
cat << EOF
Usage: $0 PROJECT_NAME [DOMAIN] [OPTIONS]
Options:
-y No prompts, assume yes to all.
import sys
import tempfile
import hotshot
import hotshot.stats
from django.conf import settings
from cStringIO import StringIO
class ProfileMiddleware(object):
"""
Displays hotshot profiling for any view.
"""Run PEP8 on all Python files in this directory and subdirectories as part of the tests."""
__author__ = 'Christopher Swenson'
__email__ = 'chris@caswenson.com'
__license__ = 'CC0 http://creativecommons.org/publicdomain/zero/1.0/'
import os
import os.path
import unittest
@matthewhochler
matthewhochler / gist:bf36698f83eadf095269
Created October 30, 2015 15:57 — forked from joshuaflanagan/gist:7495006
Postgres extensions on Amazon RDS
name | default_version | installed_version | comment
------------------------+-----------------+-------------------+---------------------------------------------------------------------
pg_buffercache | 1.0 | | examine the shared buffer cache
earthdistance | 1.0 | | calculate great-circle distances on the surface of the Earth
pg_freespacemap | 1.0 | | examine the free space map (FSM)
intagg | 1.0 | | integer aggregator and enumerator (obsolete)
plperl | 1.0 | | PL/Perl procedural language
sslinfo | 1.0 | | information about SSL certificates
btree_gist | 1.0 | | support for indexing common datatypes in GiST
fuzzystrmatch | 1.0
@matthewhochler
matthewhochler / gist:9ba777e2bbc608278f83
Created November 17, 2015 19:19 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

OS X Preferences


most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
@matthewhochler
matthewhochler / command.js
Last active January 1, 2016 08:09 — forked from JoelBesada/README.md
Bookmark current URL in Pinboard, with pop-up window. Custom bookmarklet for Backtick (http://backtick.io/).
javascript:q=location.href;if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;void(open('https://pinboard.in/add?url='+encodeURIComponent(q)+'&description='+encodeURIComponent(d)+'&title='+encodeURIComponent(p),'Pinboard','toolbar=no,width=700,height=350'));
@matthewhochler
matthewhochler / add_to_omnifocus-oneliner.js
Last active January 4, 2016 01:29 — forked from al3xandru/gist:1169583
Add to OmniFocus Bookmarket
javascript:(function(){var enc=encodeURIComponent,w=window,frames=w.frames,d=document,tn=w.getSelection?w.getSelection():(d.getSelection)?d.getSelection():(d.selection?d.selection.createRange().text:0),pu=w.location.href,isGMail=w.location.host.match(/mail\.google\.com/),tt=pt=d.title,subjSpans=d.getElementsByClassName("hP"),i,url;if(isGMail){if(subjSpans){tt=subjSpans[0].innerText}else{tt=d.title.substring(d.title.indexOf("-")+1,d.title.lastIndexOf("-")).replace(/^ +/,"").replace(/ +$/,"")};if(tn!="")tn+="\n\n";tn+="From email subject:("+tt+")\n"+pu;pu="https://mail.google.com/mail/u/0/?qs=true&search=query&q=subject:("+enc(tt)+")"};url='omnifocus:///add?note='+enc(tn+"\n"+pu)+'&name='+enc(tt);w.location.href=url})();
@matthewhochler
matthewhochler / post-merge
Created January 29, 2016 20:04 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed. In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed. Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"