Skip to content

Instantly share code, notes, and snippets.

@scoffey
scoffey / peg.py
Created August 13, 2018 18:23
Peg solitaire solver (using depth-first search)
#!/usr/bin/env python2.7
import sys
# Global constants
SIZE = 7
FINAL_BOARD = 1 << 24 # 1 << ((SIZE * SIZE - 1) / 2)
def solve(board):
explored = set()
@scoffey
scoffey / keybase.md
Last active January 28, 2017 07:33
Keybase proof

Keybase proof

I hereby claim:

  • I am scoffey on github.
  • I am scoffey (https://keybase.io/scoffey) on keybase.
  • I have a public key whose fingerprint is 07AD 476D D09D 192E 8B38 1BAD CB3E C9E4 FF13 0596

To claim this, I am signing this object:

@scoffey
scoffey / webtail.py
Created January 15, 2012 20:04
HTTP server that provides a web interface to run "tail" on a file, like the Unix command
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
HTTP server that provides a web interface to run "tail" on a file,
like the Unix command.
This is a standalone script. No external dependencies required.
How to invoke:
@scoffey
scoffey / microformats.py
Created May 4, 2011 01:22
Python microformats parser that supports hCard, hCalendar, hResume and rel-tag and provides an extensible model for other microformats.
# -*- coding: utf-8 -*-
#!/usr/bin/env python
"""
Model for microformat properties and parsers. A microformat parser can
parse an HTML element into a dictionary of properties, whose keys are
strings and whose values are strings or other dictionary of properties.
As an example, the main program of this script parses an hResume from
given URL.
@scoffey
scoffey / pytunes.py
Created November 25, 2010 04:49
Sorts a given iTunes playlist according to the least played tracks in each album
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This script implements an algorithm for sorting a given iTunes playlist
according to the least played tracks in each album.
It aims to identify the tracks that were played the least and to show
how many times they should be played in order to reach the same playcount
as the most played track in the album they belong to.