Skip to content

Instantly share code, notes, and snippets.

View splaice's full-sized avatar

Sean Plaice splaice

  • San Francisco, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am splaice on github.
  • I am splaice (https://keybase.io/splaice) on keybase.
  • I have a public key ASBXr--_whPmAOQiyu_d5h72vf5frAlmeLqxIs26zIiHOwo

To claim this, I am signing this object:

@splaice
splaice / menu.py
Created February 20, 2017 01:37
Selectable menu in Python using blessed
#!/usr/bin/env python
from blessed import Terminal
menu = [["login to system"], ["create account"], ["disconnect"]]
def display_screen(selection):
term = Terminal()
print term.clear()
@splaice
splaice / yapf
Created April 5, 2015 06:48
yapf wrapper
#!/usr/bin/env bash
#
# put me in ~/bin and chmod +x me
#
PYTHONPATH=~/src/yapf python ~/src/yapf/yapf $@
@splaice
splaice / example.py
Last active August 29, 2015 14:06
ec2 interface example
from ec2 import Instance, SecurityGroup, VPC
instances = Instance.objects.all()
web0 = Instance.objects.filter(name='web0')
# creating instances could be tricky, does creating or saving an instance run it?
i = Instance(**kwargs)
i.save()
i = Instance.objects.create(**kwargs)
i, _ = Instance.objects.get_or_create(**kwargs)
i.delete()
@splaice
splaice / turbo_md_rebuild.py
Created May 8, 2014 18:43
Speed up md raid rebuilds
#!/usr/bin/env python
import argparse
import sys
MAX_FP = '/proc/sys/dev/raid/speed_limit_max'
MIN_FP = '/proc/sys/dev/raid/speed_limit_min'
MAX_DEFAULT=200000
MIN_DEFAULT=1000
MAX_TURBO = MAX_DEFAULT * 2
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundBlur</key>
<real>0.0</real>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NGMCAw
@splaice
splaice / osx.sh
Last active December 13, 2015 17:39
my .osx
#!/bin/bash
# ~/.osx — http://mths.be/osx
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
@splaice
splaice / check_postgres_replication.py
Created July 1, 2012 00:30 — forked from jacobian/check_postgres_replication.py
Nagios plugin to check PostgreSQL 9 streaming replication lag.
#!/usr/bin/env python
"""
Nagios plugin to check PostgreSQL 9 streaming replication lag.
Requires psycopg2 and nagiosplugin (both installable with pip/easy_install).
MIT licensed:
Copyright (c) 2010 Jacob Kaplan-Moss. All rights reserved.
@splaice
splaice / hack.sh
Created March 31, 2012 17:48 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
echo "Hide the dock"
@splaice
splaice / gist:1766244
Created February 8, 2012 07:04
PEP8 pre-commit hook in Python
#!/usr/bin/env python
from __future__ import with_statement
import os
import shutil
import subprocess
import sys
import tempfile
def system(*args, **kwargs):