Skip to content

Instantly share code, notes, and snippets.

View nicholasRutherford's full-sized avatar

Niko Rutherford nicholasRutherford

View GitHub Profile
@nicholasRutherford
nicholasRutherford / horse_model.py
Created March 7, 2024 21:43
Manifold horse race model
import numpy as np
import pymc as pm
# Race times for 6 racers doing 3 races
race_times = np.array([
[30,20,22], # Lane 1
[27,27,28], # Lane 2
[25,29,28], # Lane 3
[25,23,23], # Lane 4
[24,24,25], # Lane 5
@nicholasRutherford
nicholasRutherford / comparison.js
Last active November 24, 2023 23:15
lokijs vs js array
var loki = require('lokijs');
var BTree = require('sorted-btree').default
var baseRecordCount = 10000000;
var newRecordCount = 10000;
function generateRandomId() {
var max = 10000000;
return Math.floor(Math.random() * max) + 1;
}
@nicholasRutherford
nicholasRutherford / app.py
Created October 8, 2015 23:40
Example of Flask-breadcrumbs using MethodViews and blueprints
from flask import Flask, render_template, Blueprint
from flask.ext import breadcrumbs
from flask.views import MethodView
app = Flask(__name__)
breadcrumbs.Breadcrumbs(app=app)
bp = Blueprint('bp', __name__,)
class LevelOneView(MethodView):
@nicholasRutherford
nicholasRutherford / ppmFile.py
Created October 7, 2015 04:55
Generating a ppm p6 file in python
# Define screen size
DISPLAY_WIDTH = 32 * 1 #32 pixels x 1 displays
DISPLAY_HEIGHT = 16
# Define a screen that has (width X height) numbers of 'pixels'. Each pixel is an RGB triplet
# with max value of 255. Even though our actual screen is 2-D it is stored as a 1-D array. Pixels
# 0 - 31 are the first row, 32 - 63 are the second row, etc.
screen = [[0,0,0] for x in xrange(self.DISPLAY_WIDTH*self.DISPLAY_HEIGHT)]