Skip to content

Instantly share code, notes, and snippets.

@PM2Ring
PM2Ring / fano_plane.svg
Created October 2, 2017 12:19
The usual projection of the Fano plane. Hover over a node to see the nodes on the line dual to that node.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / fano_disc2.svg
Created October 2, 2017 11:33
The Fano plane as a disc
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@PM2Ring
PM2Ring / algorithmx_spotit.py
Created September 27, 2017 11:12
SpotIt Stuff
#!/usr/bin/env python3
''' algorithmx_spotit
Generate small Spot-It decks by brute force searching for
the exact cover of pairs of cards which share a symbol.
Uses Knuth's Algorithm X for the exact cover problem.
The Algorithm X code, using dicts instead of doubly-linked
circular lists was written by Ali Assaf.
@PM2Ring
PM2Ring / case_insensitive_string.py
Created July 23, 2017 12:52
Case-insensitive string class
#!/usr/bin/env python3
''' Case-insensitive string class
A string class that uses lower-case hashing and comparisons.
It also uses case-insensitive comparison when compared with
normal `str` strings.
CIStr defines all 6 rich comparison methods, although only
the `__eq__` method is needed for dictionary and set use.
@PM2Ring
PM2Ring / tk_viewer_simple.py
Created July 18, 2017 20:05
A Tkinter viewer for named PIL Images
#!/usr/bin/env python3
''' A Tkinter viewer for named PIL Images
Image windows can be iconified / deiconified individually via buttons
in the main viewer window, or iconified / deiconified en masse by
iconifying / deiconifying the main viewer window.
Written by PM 2Ring 2017.07.16
'''
@PM2Ring
PM2Ring / PIL_bitmap_bug.py
Created July 14, 2017 17:30
Demonstrate the PIL .fromarray bitmap bug
#! /usr/bin/env python3
''' Demonstrate the PIL .fromarray bitmap bug
PIL's Image.fromarray function has a bug with mode '1' images
See
https://stackoverflow.com/questions/2761645/error-converting-pil-bw-images-to-numpy-arrays
Written by PM 2Ring 2017.06.26
@PM2Ring
PM2Ring / packbits_speed_test.py
Created June 29, 2017 16:26
Bit packing speed tests: Numpy vs pure Python 3.
#!/usr/bin/env python3
''' Test speeds of several bit packing algorithms
Written by PM 2Ring 2017.06.29
'''
import numpy as np
from timeit import Timer
@PM2Ring
PM2Ring / parse_SO_chat.py
Created June 20, 2017 14:13
Display a Stack Overflow chat room transcript in the shell, with ANSI color codes. Work in progress.
#!/usr/bin/env python3
''' "Simple" parser to extract & print the messages from
an SO chat room transcript file or URL
Work in progress, but usable. I think. :)
Written by PM 2Ring 2017.06.20
'''
@PM2Ring
PM2Ring / dump_html.py
Created June 20, 2017 14:00
Show the structure of an HTML file (or part thereof) in the shell
#!/usr/bin/env python3
''' Show HTML file structure
Written by PM 2Ring 2017.06.19
'''
import sys
from html.parser import HTMLParser
@PM2Ring
PM2Ring / batman1-GoLprinter.rle
Created June 17, 2017 11:36
Batman logo generated by a Game of Life pattern
x = 1968, y = 926, rule = B3/S23
1046b2o$1046bo$1038bo5bobo$1038bobo3b2o$1021bo17bobo$1021b2o16bo2bo$
1012b2o2b2o4b2o15bobo$1012b2o2b2o4b3o13bobo5b2o12b2o$1016b2o4b2o7bobo
4bo7bo13b2o$1021b2o9b2o10bobo13b2o$1021bo10bo11b2o14bo$1059bobo$1059bo
bo$1039b2o19bo$1038bobo$1040bo$1057b2o3b2o$1057bobobobo57b2o$1058b5o
58bo$1028bo7b2o21b3o51bo5bobo$1028b2o6b2o22bo52bobo3b2o$1027bobo66bo
17bobo$1096b2o16bo2bo$1087b2o2b2o4b2o15bobo$1087b2o2b2o4b3o13bobo5b2o
12b2o$1091b2o4b2o7bobo4bo7bo13b2o$1096b2o9b2o10bobo13b2o$1020b2o35bobo
36bo10bo11b2o14bo$1021b2o34b2o75bobo$1020bo37bo75bobo$1114b2o19bo$
1047b2o64bobo$1047b2o12b3o51bo$1060bo3bo67b2o3b2o$1013bo37bo7bo5bo66bo