Skip to content

Instantly share code, notes, and snippets.


Colin Caine cmcaine

  • Leeds Institute for Data Analytics, University of Leeds
  • Manchester
View GitHub Profile
cmcaine / alphametics.jl
Last active Nov 15, 2021
Brute force solver for alphametics
View alphametics.jl
# See also
using Combinatorics: permutations
using Test
function sum_expr(exprs)
if length(exprs) == 1
return only(exprs)
View couples.jl
using Combinatorics
using Random
couples = 1:8
possible_groups = combinations(couples, 3)
function doit(couples, possible_groups)
has_not_met = [couple => setdiff(couples, couple) for couple in couples]
selected_groups = []
View MultipleLinearRegressionDemo.jl
Learn a linear model for a linear relationship of three variables
module MultipleLinearRegressionDemo
using Flux: gradient, params
using Statistics: mean
function linreg(X, Y)
View fastb64.jl
using Base64: base64encode
# From Base64 but copied here for readability
const BASE64_ENCODE = [UInt8(x) for x in ['A':'Z'; 'a':'z'; '0':'9'; '+'; '/']]
encode(x::UInt8) = @inbounds return BASE64_ENCODE[(x & 0x3f) + 1]
encodepadding() = UInt8('=')
cmcaine / cruftless-webext-messaging.ts
Last active May 16, 2018
Is this as little cruft as possible?
View cruftless-webext-messaging.ts
* Class C is loaded in two contexts: content and background. The decorators
* @content and @background replace the decorated function with a call to a
* messaging library if the current context is not the desired context for the
* function.
* The intention is that a developer can write code that is split between the
* content and background without having to think too much about where it is:
* calls that pass through messaging just look like regular async function
* calls.
cmcaine / einsum-efficiency-problem.ipynb
Last active Jun 5, 2017
View einsum-efficiency-problem.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
cmcaine / justify-and-hyphenate.css
Last active Mar 23, 2017
Justify and hyphenate the web
View justify-and-hyphenate.css
div.thumbcaption /* wikipedia */ {
text-align: justify !important;
hyphens: auto !important;
cmcaine / defaultlang.js
Created Mar 23, 2017
Set default language to "en"
View defaultlang.js
// ==UserScript==
// @name Default language = en
// @namespace cmcaine
// @version 1
// @grant none
// ==/UserScript==
// So hyphens work better.
if (window.document.documentElement.lang == "") {

Keybase proof

I hereby claim:

  • I am cmcaine on github.
  • I am cmcaine ( on keybase.
  • I have a public key ASCOMPSgeIAYH7NhsSc63AVMLrYu0yfC81zQa2aR21iungo

To claim this, I am signing this object:

cmcaine / swap
Last active Oct 13, 2016
Swap two files reasonably safely
View swap
# Swap two files safely.
# Under normal circumstances, just do the right thing. Under unusual
# circumstances, give a reasonably helpful error message.
# This was an exercise in thinking about how generally reliable functions might
# fail and what to communicate to users.
# Copyright Colin Caine. License: GPLv2