Skip to content

Instantly share code, notes, and snippets.

View tjmw's full-sized avatar

Tom Wey tjmw

View GitHub Profile
@tjmw
tjmw / gist:5390765
Last active December 16, 2015 06:19
Show (up to a max of) 5 most recently checked out branches in Git
git reflog \
| awk '{ print $3, $NF }' \
| grep "^checkout:" \
| awk '{ print $2 }' \
| egrep -v '^([0-9a-f]{40}|[0-9a-f]{7}$)' \
| perl -ne 'print unless $a{$_}++' \
| head -5
@tjmw
tjmw / gist:6113202
Last active January 10, 2021 18:03
Migrate a MySQL DB to Postgres on Heroku

Migrating a MySQL DB to a Heroku Postgres Instance

1. Create a MySQL Dump

mysqldump -h<host> --compatible=postgresql -u<user> -p <database_name> > /tmp/my_dump.sql

2. Import MySQL dump locally

cat my_dump.sql | mysql -h<host> -u<user> -p <database_name>
@tjmw
tjmw / gist:6993247
Created October 15, 2013 15:17
Base64 encoded string representation of an image file
ruby -rbase64 -e "File.open(ARGV[0], 'r') {|file| puts Base64.encode64(file.read) }" <file>
@tjmw
tjmw / gist:52d6f2c21c06e4a2c080
Last active January 4, 2016 19:09
Upgrading Postgres from 9.2 to 9.3 on OS X Mavericks with Homebrew

Upgrade Postgres

$ brew update
$ brew upgrade brew upgrade postgresql

Migrate Existing data files

Move old data files out of the way

$ mv /usr/local/var/postgres /usr/local/var/postgres-9.2.x

@tjmw
tjmw / gist:ee66b025612c2b3c3ca7
Last active August 29, 2015 14:10
Installing an Android APK

Prerequisites

$ brew install android android-sdk

List devices

$ adb devices

List packages

@tjmw
tjmw / gist:f3c2c9663cd2a038cbce
Last active August 29, 2015 14:11 — forked from cloud8421/gist:5510765
Whippet (https://github.com/tjmw/whippet) vim configuration
let g:whippet_path = '/path/to/whippet'
let g:ctrlp_use_caching = 0
let g:whippet_exclude_paths = ".git,.svn,tmp,log,.bundle"
let g:ctrlp_user_command = g:whippet_path." --exclude=".g:whippet_exclude_paths
let g:ctrlp_match_func = { 'match': 'Whippet' }
function Whippet(items, str, limit, mmode, ispath, crfile, regex)
let cmd = g:whippet_path.' --exclude='.g:whippet_exclude_paths
@tjmw
tjmw / app.js
Last active August 29, 2015 14:18 — forked from mbostock/.block
D3 Projections
var width = 960,
height = 500;
var projection = interpolatedProjection(
d3.geo.orthographic()
.rotate([10, -10])
.center([-10, 10])
.scale(240)
.translate([width / 2, height / 2]),
d3.geo.equirectangular()
@tjmw
tjmw / README.md
Last active August 29, 2015 14:18 — forked from mbostock/.block
@tjmw
tjmw / gist:73d36d0528884e60d4a6
Last active August 29, 2015 14:19
Misc Ubuntu Server Setup

Add new user with home dir

useradd -m USERNAME
passwd USERNAME

Add to sudoers

@tjmw
tjmw / debouncer.js
Created September 4, 2015 20:28
Javascript Debouncer
var debounce = function(fn) {
var timeout;
var debouncedFn = function() {
clearTimeout(timeout);
timeout = setTimeout(fn.apply.bind(fn, this, arguments), 500);
};
return debouncedFn;
};