Skip to content

Instantly share code, notes, and snippets.

View simonhayward's full-sized avatar

Simon Hayward simonhayward

View GitHub Profile
@simonhayward
simonhayward / gunicorn_settings.py
Created August 8, 2011 08:52
Gunicorn settings file
import multiprocessing
# The socket to bind.
bind = "127.0.0.1:8080"
# The maximum number of pending connections.
backlog = 2024
# The number of worker process for handling requests
workers = multiprocessing.cpu_count() * 2 + 1
# The type of workers to use. (sync|eventlet|gevent|tornado)
worker_class = 'gevent'
@simonhayward
simonhayward / matrix-least-recently-used.py
Created August 8, 2011 11:34
Least recently used matrix
#!/usr/bin/env python
import string
import sys
class LeastRecentlyUsedMatrix(object):
"""
Output matrix in table format
Return least recently used references
"""
MAX_MATRIX_SIZE = 70
@simonhayward
simonhayward / execute-file-if-modified.py
Created September 26, 2011 16:42
Run command + script as I make changes to file
import os
import sys
import subprocess
import time
def file_is_modified(filename):
""" Accepts & returns filename if it has been modified """
previous_st_mtime = 0
while True:
st_mtime = os.stat(filename)[8]
@simonhayward
simonhayward / rc.lua
Created November 16, 2011 12:03
awesome wm config
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
require("vicious")
-- Load Debian menu entries
from string import ascii_uppercase as uc, ascii_lowercase as lc, maketrans
def rot_func(text, encode=True, rotate=13):
letters = uc + lc
rot = "".join((x[:rotate][::-1] + x[rotate:][::-1])[::-1] for x in (uc,lc))
src, trg = (letters, rot) if encode else (rot, letters)
trans = maketrans(src, trg)
return text.translate(trans)
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
@simonhayward
simonhayward / prepare-commit-msg
Last active August 29, 2015 14:04
git-hooks-prepare-commit-msg
#!/bin/sh
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "master" ]; then
echo "[$BRANCH_NAME] $(cat $1)" > $1
fi
@simonhayward
simonhayward / vimrc
Last active July 22, 2016 14:39
vimrc
" filetype plugin on
" filetype indent on
" Pathogen load
filetype off
call pathogen#infect()
call pathogen#helptags()
filetype plugin indent on
syntax on
@simonhayward
simonhayward / .bashrc
Last active December 21, 2015 09:07
Welcome screen .bashrc
# UTF-8
export LC_ALL=en_GB.UTF-8
export LANG=en_GB.UTF-8
export LANGUAGE=en_GB.UTF-8
export EDITOR=/usr/bin/vim
# tailoring 'less'
#######################################################
alias more='less'
@simonhayward
simonhayward / .bashrc
Last active January 26, 2017 13:40
windows cygwin .bashrc - ssh-add
export SSH_AUTH_SOCK=/home/simon/.ssh-socket
ssh-add -l >/dev/null 2>&1
if [ $? = 2 ]; then
# No ssh-agent running
rm -rf $SSH_AUTH_SOCK
# >| allows output redirection to over-write files if no clobber is set
ssh-agent -a $SSH_AUTH_SOCK >| /tmp/.ssh-script
source /tmp/.ssh-script
echo $SSH_AGENT_PID >| ~/.ssh-agent-pid