Skip to content

Instantly share code, notes, and snippets.

View hamishmorgan's full-sized avatar

Hamish Morgan hamishmorgan

View GitHub Profile
@hamishmorgan
hamishmorgan / polyjson_Animal.java
Created November 15, 2014 10:34
Example of polymorphic JSON de/serialization in Jackson (1.5+?)
package hiam.polyjson;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({@JsonSubTypes.Type(Dog.class), @JsonSubTypes.Type(Cat.class)})
public abstract class Animal {
}
__author__ = 'hiam20'
import time
import collections
import threading
import concurrent.futures
INSTANTIATION_TIME = 0.5
EXECUTION_TIME = 0.002
@hamishmorgan
hamishmorgan / .gitattributes
Last active December 15, 2015 19:19
Git files
*.pbxproj -crlf -diff -merge
# Update your login script with some defaults
touch ~/.profile
chmod +x ~/.profile
echo "module load python/2.7.2" >> ~/.profile
echo "export PATH=$PATH:~/.local/bin" >> ~/.profile
~/.profile
# Install setup-tools locally
public class TestArrayListRemove {
public void testArrayListRemove() {
// First lets create an ArrayList contain some words that are awesome.
ArrayList<String> coolWords = new ArrayList<String>();
coolWords.add("Discombobulated");
coolWords.add("Shananigans");
coolWords.add("Fluffalufapotamus");
@hamishmorgan
hamishmorgan / gist:3844967
Created October 6, 2012 13:43
Dice Roller
import java.util.Random;
import static java.text.MessageFormat.format;
/**
* http://www.reddit.com/r/dailyprogrammer/comments/10pf0j/9302012_challenge_102_easy_dice_roller/
*/
public class Main {
@hamishmorgan
hamishmorgan / gist:3342260
Created August 13, 2012 16:14
A quick demo of how to produce a loglog histogram plot of very large amounts of data, by using log-histogram bins.
# A quick demo of how to produce a loglog histogram plot of very large
# amounts of data, by using log-histogram bins
import numpy as np
import matplotlib.pyplot as plt
import itertools as it
# We shall draw millions of samples from a Zipf distribution. Using linear
# bins this is too much data for a fast and attactive plot.