Skip to content

Instantly share code, notes, and snippets.

J. Richard Snape rsnape

  • De Montfort University
  • Leicester
Block or report user

Report or block rsnape

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

Keybase proof

I hereby claim:

  • I am rsnape on github.
  • I am snapey ( on keybase.
  • I have a public key whose fingerprint is 64BC F1D9 9DBE FFA0 2B10 9C22 19F0 B086 51E8 132F

To claim this, I am signing this object:

View common_comments_box.user.js
// ==UserScript==
// @name Common Comments Box (Stack Overflow)
// @namespace about:blank
// @include http*://*
// @version 1
// @grant none
// ==/UserScript==
var common_comments = [
"It looks like you want us to write some code for you. While many users are willing to produce code for a coder in distress, they usually only help when the poster has already tried to solve the problem on their own. A good way to demonstrate this effort is to include the code you've written so far, example input (if there is any), the expected output, and the output you actually get (console output, tracebacks, etc.). The more detail you provide, the more answers you are likely to receive. Check the [FAQ] and [ask].",
import timeit
def to_base_7(n):
Express an int as a base 7 string
If libraries are allowed - numpy.base_repr()
would almost certainly be faster
s, n = [], int(n)
while n > 7:
import wx
#from wx.lib.pubsub.core import Publisher #If you want to manage your own publisher use this
from wx.lib.pubsub import pub
import threading
class ParcelData(object):
def __init__(self,count,current,message):
self.parcel_count = count
self.current_parcel = current
self.message = message
rsnape /
Created Aug 27, 2015
Example of how the IncrementalPCA MemoryError failure can occur.
import numpy as np
from sklearn.utils import check_array
ut = np.memmap('D:\\my_array2.mmap', dtype=np.float16, mode='w+', shape=(140000,3504))
print repr(ut), ut.shape
res = check_array(ut)
print 'Memory check passed',repr(res),res.shape #This will print the same contents and shape as above
res = check_array(ut, dtype=np.float) # This is the actual line used in IncrementalPCA
from math import radians, sin, cos, sqrt, asin, factorial
from itertools import combinations, permutations
# by average circumference instead of authalic radius (assume planes)
# shouldn't actually matter for our purposes as we're using this to generate weights
# been nodes/vertices.
def haversine(lat1, long1, lat2, long2, planet_radius=EARTH_RADIUS_KM):
rsnape /
Last active Jan 26, 2017
Fixed up version of calendar plot for Stack overflow question
import pandas, pdb, os, csv, datetime, numpy, brewer2mpl
import matplotlib.pyplot as plt
import matplotlib.colorbar as cbar
from matplotlib import rcParams
import palettable
from dateutil import rrule
import matplotlib
import calendar
def set_matplotlib_params():
# Natural Language Toolkit: Clusterer Utilities
# Copyright (C) 2001-2014 NLTK Project
# Author: Trevor Cohn <>
# URL: <>
# For license information, see LICENSE.TXT
from __future__ import print_function, unicode_literals
import copy
from sys import stdout
You can’t perform that action at this time.