Skip to content

Instantly share code, notes, and snippets.

Making mountains out of mole hills

Matt Seymour mattseymour

Making mountains out of mole hills
View GitHub Profile
mattseymour /
Created Dec 30, 2019
Python timed logger decorator
import logging
import time
from functools import wraps
from typing import (
mattseymour / build-instructions
Created May 1, 2017
Build Python 3.6 from source for Ubuntu and Debian
View build-instructions
Prerequisties install:
- sudo apt-get install build-essential checkinstall
These are the dependancies required by python:
- sudo apt-get install libbz2-dev libc6-dev libgdbm-dev libncursesw5-dev libreadline-gplv2-dev libssl-dev libsqlite3-dev tk-dev
Download the tar source file from (at the time of writing 3.6.1 is the latest release):
- wget -O ~/Downloads/python3.6.1.tgz
Via command line navigate to the downloaded file directory:
mattseymour /
Created Mar 16, 2016
A small script to calculate energy costs per year
# Cost per units and standard day charge
ELEC_PKWH = 12.2
ELEC_DAILY = 11.420
GAS_PKWH = 2.973
GAS_DAILY = 12.910
# Number of units i use
View canvas cloud
canvas = document.getElementById('cloud');
var ctx = cloud.getContext("2d");
// left
ctx.fillStyle = "rgb(255,255,255)";
View Test pac file
function FindProxyForURL(url, host) {
if (dnsDomainIs(host, ".localhost"))
return "DIRECT";
if (url.substring(0, 6)=="https:")
return "DIRECT";
return "PROXY";
mattseymour /
Created Aug 5, 2015
Python XOR encryption
# Simple XOR encyption
def xor(self, string, key):
return ''.join(chr(ord(x) ^ ord(y)) for x, y in zip(string, cycle(key)))
mattseymour / gist:25d86505ff46729de5cf
Created Nov 22, 2014
Python - 100 lightbulbs problem
View gist:25d86505ff46729de5cf
This is a simple bit of code which solves the 100 lightbulbs problem.
Its not the most efficient but it does the job.
def switch(list_length, iterations):
switches_on = []
switches = { i:False for i in range(1,list_length+1)}
mattseymour / gunicorn-initd-script
Last active Aug 14, 2019
Debian gunicorn init.d script
View gunicorn-initd-script
# Provides: webapp
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: gunicorn init.d script for ubuntu and debian
# Description: gunicorn init.d script for running gunicorn on ubuntu or debian based systems
# start script using `/etc/init.d/webapp start`
mattseymour /
Last active Sep 8, 2022
Django secret key generator
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
import string
import random
from __future__ import print_function