Skip to content

Instantly share code, notes, and snippets.

@mozz100
mozz100 / fa-cup.js
Last active January 31, 2023 21:06
Visualise some FA cup fixtures... which one is the best one to go to?
'use strict';
var config = {
type: Phaser.WEBGL,
parent: 'phaser-example',
width: 500,
height: 500,
scene: {
preload: preload,
create: create
@mozz100
mozz100 / fa-cup.py
Last active January 24, 2023 22:18
Compute coefficients for FA Cup probability trees. See https://www.rmorrison.net/mnemozzyne/2023/01/24/optimising-the-fa-cup/
"""
Compute coefficients for FA Cup probability trees.
See https://www.rmorrison.net/mnemozzyne/2023/01/24/optimising-the-fa-cup/
"""
from typing import List
from dataclasses import dataclass
@dataclass
@mozz100
mozz100 / logging_webserver.py
Created October 7, 2014 20:37
Tiny python web server that just logs stuff
#!/usr/bin/env python
import tornado.ioloop
import tornado.web
import pprint
class MyDumpHandler(tornado.web.RequestHandler):
def post(self):
pprint.pprint("Request")
pprint.pprint(self.request)
@mozz100
mozz100 / runserver.py
Last active June 13, 2021 02:57
Change default port for django runserver
# Put this at <yourapp>/management/commands/runserver.py.
# Override the value of the constant coded into django...
import django.core.management.commands.runserver as runserver
runserver.DEFAULT_PORT="8197"
# ...and then just import its standard Command class.
# Then manage.py runserver behaves normally in all other regards.
from django.core.management.commands.runserver import Command
@mozz100
mozz100 / big-primes.ipynb
Created September 25, 2017 21:37
Prime numbers
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mozz100
mozz100 / pdf_magic.js
Last active July 27, 2017 00:48
Zendesk embedded PDF viewer via Google Docs
// add this javascript to your Zendesk Help Center pages
(function($) {
$(function() {
// for all attachment links whose URLs end with .pdf (case sensitive)...
var pdfs = $('.attachments a[href$=".pdf"]');
var eleBody = $('div.article-body');
if (pdfs.length > 0) {
@mozz100
mozz100 / xbee.js
Last active April 16, 2016 21:48
Node.js, xbee and promises
var SerialPort = require('serialport').SerialPort;
var xbee_api = require('xbee-api');
var C = xbee_api.constants;
var Q = require('q');
// following settings work for me on my Raspberry pi, your config may differ!
var xbeeAPI = new xbee_api.XBeeAPI({
api_mode: 1
});
var serialport = new SerialPort("/dev/ttyAMA0", {
@mozz100
mozz100 / semantic-pedantic.md
Last active January 8, 2016 14:19 — forked from jashkenas/semantic-pedantic.md
Why Semantic Versioning Isn't

Spurred by recent events (https://news.ycombinator.com/item?id=8244700), this is a quick set of jotted-down thoughts about the state of "Semantic" Versioning, and why we should be fighting the good fight against it.

For a long time in the history of software, version numbers indicated the relative progress and change in a given piece of software. A major release (1.x.x) was major, a minor release (x.1.x) was minor, and a patch release was just a small patch. You could evaluate a given piece of software by name + version, and get a feeling for how far away version 2.0.1 was from version 2.8.0.

Note: just a feeling. Feelings are human and can be erroneous

But Semantic Versioning (henceforth, SemVer), as specified at http://semver.org/, changes this to prioritize a mechanistic understanding of a codebase over a human one. Any "breaking" change to the software must be accompanied with a new major version number. It's alright for robots, but bad for us.

"Us" meaning who... users? I think version numbers

@mozz100
mozz100 / mozzicon.py
Last active December 26, 2015 10:09
Mozzicon: html/python implementation of https://github.com/cupcake/sigil
def mozzicon(md5):
# Inspired by (!) https://github.com/cupcake/sigil
# return a 5 by 5 grid of divs with horizontal plane of symmetry
# (css used to rotate by 90deg)
# md5 is a string like "9eadbe04ba0a832eecbd0a27f563e0a6"
# use first char of hash to pick a color from 7
colors = ('2d4fff', 'feb42c', 'e279ea', '1eb3fd', 'e84d41', '31cb73', '8d45aa', )
@mozz100
mozz100 / gmail_snooze.js
Created October 22, 2013 14:48
GMail snooze, with some mozz modifications
// see http://googleappsdeveloper.blogspot.co.uk/2011/07/gmail-snooze-with-apps-script.html
// Should be set to run every day at midnight, and moves emails one label 'nearer' to the inbox
var MARK_UNREAD = false;
var ADD_UNSNOOZED_LABEL = true;
function getLabelName(i) {
return "Snooze/Snooze " + i + " days";
}