Skip to content

Instantly share code, notes, and snippets.

View autodidacticon's full-sized avatar

Richard Moorhead autodidacticon

View GitHub Profile

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@autodidacticon
autodidacticon / states.json
Last active August 29, 2015 14:03
Bounding coordinates of US states, json, minified
{"WA":[{"y":"-123.32","x":"49.00"},{"y":"-123.03","x":"49.00"},{"y":"-122.06","x":"49.00"},{"y":"-121.74","x":"48.99"},{"y":"-121.59","x":"48.99"},{"y":"-119.60","x":"49.00"},{"y":"-118.03","x":"49.00"},{"y":"-117.03","x":"48.99"},{"y":"-117.04","x":"47.96"},{"y":"-117.03","x":"46.50"},{"y":"-117.03","x":"46.42"},{"y":"-117.06","x":"46.34"},{"y":"-117.02","x":"46.33"},{"y":"-116.98","x":"46.28"},{"y":"-116.95","x":"46.23"},{"y":"-116.96","x":"46.20"},{"y":"-116.92","x":"46.17"},{"y":"-116.93","x":"46.14"},{"y":"-116.95","x":"46.10"},{"y":"-116.97","x":"46.07"},{"y":"-116.94","x":"46.05"},{"y":"-116.91","x":"45.99"},{"y":"-118.03","x":"46.00"},{"y":"-118.98","x":"45.99"},{"y":"-119.13","x":"45.93"},{"y":"-119.17","x":"45.92"},{"y":"-119.25","x":"45.94"},{"y":"-119.30","x":"45.93"},{"y":"-119.36","x":"45.92"},{"y":"-119.43","x":"45.91"},{"y":"-119.48","x":"45.90"},{"y":"-119.57","x":"45.92"},{"y":"-119.60","x":"45.91"},{"y":"-119.67","x":"45.85"},{"y":"-119.80","x":"45.84"},{"y":"-119.90","x":"45.82"},{"y":"-11
sudo install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
sudo sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
@autodidacticon
autodidacticon / vim.rb
Last active August 29, 2015 14:15 — forked from mgrouchy/vim.rb
require 'formula'
class Vim < Formula
homepage 'http://www.vim.org/'
url 'https://vim.googlecode.com/hg/', :revision => 'eaf81729ef02'
version '7.4'
def features; %w(tiny small normal big huge) end
def interp; %w(lua mzscheme perl python python3 tcl ruby) end
#!/usr/bin/env bash
# save your battery, fix settings for apps that default to use the discrete gpu
# http://answers.microsoft.com/en-us/mac/forum/macoffice2011-macoutlook/office-for-mac-mavericks-high-performance-gpu/e1a6aff0-e36e-40ae-ab62-aa7e3e0c6b10
# http://blog.her.se/2014/03/increase-battery-performance-in-your.html
fix_app_gpu_defaults() {
[[ -d "$1" ]] || { echo "App not found: $1" >&2; return 1; }
defaults write "$1/Contents/Info.plist" 'NSSupportsAutomaticGraphicsSwitching' -bool true
// create the root namespace and making sure we're not overwriting it
var MYAPPLICATION = MYAPPLICATION || {};
// create a general purpose namespace method
// this will allow us to create namespace a bit easier
MYAPPLICATION.createNS = function (namespace) {
var nsparts = namespace.split(".");
var parent = MYAPPLICATION;
// we want to be able to include or exclude the root namespace
@autodidacticon
autodidacticon / redshift.sql
Last active July 25, 2016 14:42
Redshift cheat sheet
-- see current table locks
select s.schema, l.lock_owner_pid, s.table from svv_table_info s, stv_locks l where l.table_id = s.table_id;
-- see current queries
select * from stv_recents where status = 'Running';
-- kill process
select pg_terminate_backend(pid);
-- table size on disk
# see also https://github.com/wrobstory/pgshift
import gzip
from io import StringIO, BytesIO
from functools import wraps
import boto
from sqlalchemy import MetaData
from pandas import DataFrame
from pandas.io.sql import SQLTable, pandasSQL_builder
@autodidacticon
autodidacticon / docker-compose.yml
Last active May 19, 2017 10:53
docker - zookeeper, kafka, kafka-manager
zookeeper:
image: wurstmeister/zookeeper
ports:
- "32772:2181"
kafka:
image: wurstmeister/kafka:latest
ports:
- "9092"
links:
- zookeeper:zk
@autodidacticon
autodidacticon / pg_index_utilization.sql
Created June 3, 2016 15:12
pg_index_utilization.sql
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans