Skip to content

Instantly share code, notes, and snippets.

@johnhw
johnhw / custom.css
Last active October 3, 2018 07:19
CSS for jupyter cell highlight
div.cell.text_cell.rendered.selected
{
border: 4px solid orange;
}
div.cell.code_cell.rendered.selected
{
border: 4px solid orange;
}
@johnhw
johnhw / umap_sparse.py
Last active January 6, 2024 16:09
1 million prime UMAP layout
### JHW 2018
import numpy as np
import umap
# This code from the excellent module at:
# https://stackoverflow.com/questions/4643647/fast-prime-factorization-module
import random
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
p |link_ptr|name_ptr|class_ptr|doc_ptr|data_words...
execute:
mov x1, x0+D_DATA
ldr x0, [x0+D_CLASS]
b x0
bytecode:
mov x0, [IP]
@johnhw
johnhw / stitches.py
Created July 8, 2018 19:50
stitches.py
import matplotlib.pyplot as plt
import numpy as np
import fractions
def lcm(a,b):
return abs(a * b) / fractions.gcd(a,b) if a and b else 0
def hex_rgb_to_float(hex):
r = int(hex[0:2],16)/255.0