Skip to content

Instantly share code, notes, and snippets.

View msharp's full-sized avatar

max sharples msharp

  • Melbourne, Australia
View GitHub Profile

tmux cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@msharp
msharp / file_sampler.py
Last active August 29, 2015 14:01
File Sampler - sample every n rows from a file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
class FileSampler:
def __init__(self):
self.parse_args(sys.argv)
/*
Taken and cribbed from blog.datalicious.com/free-download-all-australian-postcodes-geocod
May contain errors where latitude and longitude are off. Use at own non-validated risk.
*/
SET NAMES utf8;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
DROP TABLE IF EXISTS postcodes_geo;
@msharp
msharp / boxen.py
Last active August 29, 2015 14:23
Box plots in 538 style
# Pylab BOXPLOTS in 538 style
import matplotlib.pyplot as plt
import itertools
def box_plot(boxes, figsize=(5,4), ymax=None, title=None, xlabels=[]):
def setBoxColors(bp):
colours = ["#30a2da","#6d904f","#8b8b8b","#fc4f30","#e5ae38"]
n_boxes = len(bp['boxes'])
fte = list(itertools.islice(itertools.cycle(colours), n_boxes))
#############################
#
# Appends the camera model,
# extracted from the EXIF data
# to the file name.
#
# RAW file support comes via
# a Perl command-line tool
# called `exiftool`
#
@msharp
msharp / aws-lambda-unzipper.py
Created February 6, 2017 22:52
unzip archive from S3 on AWS Lambda
import os
import sys
import re
import boto3
import zipfile
def parse_s3_uri(url):
match = re.search('^s3://([^/]+)/(.+)', url)
if match:
return match.group(1), match.group(2)