Skip to content

Instantly share code, notes, and snippets.

David Winterbottom codeinthehole

Block or report user

Report or block codeinthehole

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@codeinthehole
codeinthehole / test_commits.py
Created Oct 11, 2019
Sample test module for validating the commits messages on a PR branch
View test_commits.py
import re
import subprocess
import pytest
@pytest.mark.parametrize(
"subject, error_msg",
[
("WIP: working on something", "is a WIP commit"),
View .vimrc
" ============= " VIMRC file for David Winterbottom (@codeinthehole) " ===========
" Inspiration {{{
" -----------
" Videos:
" - http://www.youtube.com/watch?v=aHm36-na4-4
"
" Articles:
" - http://alexpounds.com/blog/2014/06/06/the-vimrc-antiques-roadshow
" - http://stevelosh.com/blog/2010/09/coming-home-to-vim/
@codeinthehole
codeinthehole / client.py
Last active Dec 15, 2019
Sample Python client for working with the Octopus Energy REST API
View client.py
# Requires the requests library (install with 'pip install requests')
import requests
class APIClient(object):
BASE_URL = "https://api.octopus.energy/v1"
class DataUnavailable(Exception):
"""
Catch-all exception indicating we can't get data back from the API
@codeinthehole
codeinthehole / account_tweets.py
Created Nov 7, 2017
Python script for printing out an account's tweets
View account_tweets.py
"""
Script for printing out tweets from a given account
Sample usage:
python account_tweets.py qikipedia
"""
import twitter
import sys
@codeinthehole
codeinthehole / values.py
Created Jun 21, 2017
Example value objects using Python 3.6's typing.NamedTuple functionality
View values.py
import typing
import datetime
class Period(typing.NamedTuple):
"""
Value object representing a period in time
"""
start_dt: datetime.datetime # noqa (as flake8 doesn't support this syntax as of v3.3)
end_dt: datetime.datetime # noqa
View .bashrc
# ======
# PROMPT
# ======
# Set the prompt
# - Specify colors using \e[31;40m where 31 is the color and 40 is the background or
# - Select 1 for bold.
# - Wrap color specifiers in \[ and \] to ensure they don't affect word wrapping
# - Colours 30=black, 31=red, 32=green, 33=yellow, 34=blue, 35=purple, 36=teal, 37=white
@codeinthehole
codeinthehole / .gitconfig
Last active Dec 13, 2019
Git config - June 2016 version
View .gitconfig
[user]
name = David Winterbottom
email = david.winterbottom@gmail.com
[alias]
# SHORT VERSIONS
co = checkout
ci = commit
@codeinthehole
codeinthehole / boo
Created Apr 15, 2016
Notifier script to use with long-running commands
View boo
#!/usr/bin/env bash
#
# Show an OSX alert
#
# This is useful when used in conjunction with a long-running script. Use this script to
# get a notification when te long-running script finishes.
#
# Eg:
#
# $ ./someprocess ; boo
@codeinthehole
codeinthehole / userdata.sh
Created Feb 2, 2016
Terraform config for an EC2 instance with a replaceable EBS volume
View userdata.sh
#!/bin/bash
DEVICE=/dev/$(lsblk -n | awk '$NF != "/" {print $1}')
FS_TYPE=$(file -s $DEVICE | awk '{print $2}')
MOUNT_POINT=/data
# If no FS, then this output contains "data"
if [ "$FS_TYPE" = "data" ]
then
echo "Creating file system on $DEVICE"
You can’t perform that action at this time.