Skip to content

Instantly share code, notes, and snippets.

View stuartlangridge's full-sized avatar

Stuart Langridge stuartlangridge

View GitHub Profile
@stuartlangridge
stuartlangridge / unsong-initials-lcs.py
Created May 7, 2017 13:38
Calculate longest subsequences from Unsong's chapter initials to get a hint about what, if anything, it's a notarikon for
#!/usr/bin/env python3
"""Parses the text of Unsong, and the list of chapter initials, and finds
longest common subsequences. The idea here is that if the notarikon formed
by the first letter of each chapter conceals a secret message, then perhaps
parts of that message have already been revealed in the book... so if there
were "NIEAC" is somewhere in the list of chapter initials, then that probably
stands for "Nothing Is Ever A Coincidence", as per the many times that phrase
is mentioned. Idea from 75thTrombone at
https://www.reddit.com/r/unsong/comments/69k1im/preemptive_final_exam_suggestion/
This script calculates those substrings. The answers are not all that promising.

Keybase proof

I hereby claim:

  • I am stuartlangridge on github.
  • I am sil (https://keybase.io/sil) on keybase.
  • I have a public key ASDGq9mbJlRG62EgMM5EdILRa4w4G3NimkeoCWxL6bQbQwo

To claim this, I am signing this object:

@stuartlangridge
stuartlangridge / danmessages.py
Created March 9, 2017 21:33
Simple example of running a background thread to print things to output, a foreground thread to receive messages, and a queue to communicate
# Import standard python modules.
import sys
import time
import threading
import os
import queue
# Import Adafruit IO MQTT client.
from Adafruit_IO import MQTTClient
@stuartlangridge
stuartlangridge / Wallpaperify
Created March 29, 2016 22:41
Simple Nautilus wallpaperify script, as per https://plus.google.com/u/0/+joeysneddon/posts/a3i2L9dyESp. (Save as $HOME/.local/share/nautilus/scripts/Wallpaperify.)
#!/bin/bash
file --brief --mime-type "$1" | grep "^image/"
if [ $? != 0 ]; then
zenity --error --text="'$1' does not seem to be an image file."
exit 1
fi
if ! hash convert 2>/dev/null; then
@stuartlangridge
stuartlangridge / deredact.py
Created March 12, 2016 21:58
Deredact stuff in the "redact" font
import sys
# call as
# python deredact.py "$(python redact.py hello world)"
instr = " ".join(sys.argv[1:]).replace(".", "").replace(",", "")
fp = open("/usr/share/dict/words")
words = [x.lower() for x in fp.read().split("\n")]
fp.close()
@stuartlangridge
stuartlangridge / icloud-cal.php
Created January 26, 2016 22:49
PHP to fetch a calendar from iCloud with authentication and CalDAV
<?php
// get this data by logging into icloud.com on the calendars page and looking at the dev tools
// as per https://translate.google.com/translate?sl=de&tl=en&js=y&prev=_t&hl=de&ie=UTF-8&u=http%3A%2F%2Fnico-beuermann.de%2Fblogging%2Farchives%2F115-Zugriff-auf-iCloud-Kalender-mit-Thunderbird.html&edit-text=&act=url
$account = array(
'server' => '', // note, this will be p12 or something, not P0; see the server that iclod.com serves json from
'icloudid' => '', // the "dsid"
'appleid' => '', // your Apple ID; will be an email address
'pass' => '', // password for your Apple ID
'calid' => '' // the "pGuid"
Verifying I am +sil on my passcard. https://onename.com/sil
@stuartlangridge
stuartlangridge / pelican-webmentions.py
Created November 29, 2014 17:24
Pelican plugin for webmentions. This will not work out of the box for you; it's too kryogenix.org-specific. But it may help.
from pelican import signals
import json, urllib, urlparse, datetime, html5lib, os, codecs
LIVESITEURL = ""
WM_CACHE_PATH = None
WM_CACHE = {
"domains": {},
"pinged": {}
}
@stuartlangridge
stuartlangridge / gist:4d66733dde499a49203b
Created June 11, 2014 23:06
Multiple async tests against multiple objects with any JS test runner.
"use strict";
/*global process, console */
function Thingy() {}
Thingy.prototype.returns5 = function(cb) { process.nextTick(function() { cb(null, 5); }); };
Thingy.prototype.returns8 = function(cb) { process.nextTick(function() { cb(null, 8); }); };
var thingy1 = new Thingy(),
thingy2 = new Thingy(),
@stuartlangridge
stuartlangridge / Dalekfile.json
Created January 28, 2014 11:42
Dalekfile.json showing how to make dalekjs start Chrome in incognito mode
{
"browsers": [{
"chrome": {
"chromeOptions": { "args": ["--incognito"] }
}
}]
}