Skip to content

Instantly share code, notes, and snippets.

@PM2Ring
PM2Ring / leap-seconds.py
Created December 6, 2021 16:59
Parsing the leap-seconds.list file
# Fetch & parse leap-seconds.list
from datetime import datetime, timezone, timedelta
from hashlib import sha1
import requests
# Leap second data source
# url = 'https://www.ietf.org/timezones/data/leap-seconds.list'
url = 'https://raw.githubusercontent.com/eggert/tz/main/leap-seconds.list'
@PM2Ring
PM2Ring / Fenwick_demo.py
Created January 2, 2018 20:51
A Python version of the Fenwick tree demo code from the Wikipedia article.
#! /usr/bin/env python3
''' Demo of the Fenwick tree, aka Binary Indexed Tree
See https://en.wikipedia.org/wiki/Fenwick_tree
Converted from C to Python by PM 2Ring
'''
def LSB(i):
@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.