Skip to content

Instantly share code, notes, and snippets.

View ChrisBeaumont's full-sized avatar

Chris Beaumont ChrisBeaumont

View GitHub Profile
@ChrisBeaumont
ChrisBeaumont / custom.css
Last active June 22, 2022 15:20
Demystifying Python Descriptors
<style>
@font-face {
font-family: "Computer Modern";
src: url('http://mirrors.ctan.org/fonts/cm-unicode/fonts/otf/cmunss.otf');
}
div.cell{
width:800px;
margin-left:16% !important;
margin-right:auto;
}
@ChrisBeaumont
ChrisBeaumont / wheel.py
Created February 17, 2016 01:35
wheel of infinite fortune
import os
import pickle
from collections import defaultdict
from random import choice
import requests
from soupy import Soupy, Q
ROM = open('wheel.nes', 'rb').read()
CLUESET_PATH = 'clues.pickle'
@ChrisBeaumont
ChrisBeaumont / example2.py
Created August 30, 2012 16:18
In-process IPython Qt Widget. Take 2
"""
An attempt to embed an IPython Qt Terminal widget in-process
Current Behavior
----------------
1) Multiple widgets can be instantiated
2) Each widget shares the same namespace (and underlying kernel)
@ChrisBeaumont
ChrisBeaumont / brain.py
Created May 29, 2014 15:32
MRI Glue demo
# -*- coding: utf-8 -*-
"""
This script loads a Brain Tumor DICOM dataset into Glue.
The data comes from http://www.osirix-viewer.com/datasets/DATA/BRAINIX.zip
To run this locally, download and unzip that file, and run this script
from the directory that you dowloaded the ZIP file to
This requires the dicom library, which you can install via

Keybase proof

I hereby claim:

  • I am chrisbeaumont on github.
  • I am chrisbeaumont (https://keybase.io/chrisbeaumont) on keybase.
  • I have a public key ASDB4h57GMHDCGEVEyzsGBh1IDft6ve0ZDdxfnCyBhLkhwo

To claim this, I am signing this object:

# add to /opt/retropie/configs/nes/emulators.cfg
wheel="python3.4 /home/pi/wheel.py && /opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-fceumm/fceumm_libretro.so --config /opt/retropie/configs/nes/retroarch.cfg /home/pi/RetroPie/roms/nes/Wheel2.nes"
hexdump -C wheel.nes | less
...
00014220 52 53 41 d2 d9 54 4f 54 41 cc 45 43 4c 49 50 53 |RSA..TOTA.ECLIPS|
00014230 45 20 4f c6 54 48 45 20 53 d5 ce 46 49 52 53 54 |E O.THE S..FIRST|
00014240 20 44 41 d4 c5 53 54 41 54 45 20 4f c6 54 48 45 | DA..STATE O.THE|
00014250 20 55 4e 49 4f ce 41 44 44 52 45 d3 d3 4d 4f 56 | UNIO.ADDRE..MOV|
import requests
from soupy import Soupy, Q
URL = "https://sites.google.com/site/wheeloffortunepuzzlecompendium/home/compendium/season-%i-compendium"
def scrape():
for i in range(1, 31):
dom = Soupy(requests.get(URL % i).text, 'html5')
def encode(clue):
"""Encode a plaintext clue into wheelscii."""
result = []
for c in clue:
if c == '\n':
result[-1] |= 0x80
else:
result.append(ord(c))
result[-1] |= 0x80
result[-2] |= 0x80
def parse_clues(data):
"""
Traverse a block of wheelscii-encoded puzzles,
yielding each decoded puzzle in ascii
"""
word = []
for pos, char in enumerate(data):
# check for signal character
if char & 0x80: