Skip to content

Instantly share code, notes, and snippets.

View stuartlangridge's full-sized avatar

Stuart Langridge stuartlangridge

View GitHub Profile
@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(),
Verifying I am +sil on my passcard. https://onename.com/sil
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Pure CSS toggle switch</title>
<style>
body {
font-size: 2em;
}
input { position: absolute; opacity: 0 }
@stuartlangridge
stuartlangridge / gist:5799474
Created June 17, 2013 19:14
Initial cut of Ubuntu webapps script for Discourse. To be called in discourse/app/views/common/_discourse_javascript.html.erb, after Discourse.start().
// ==UserScript==
// @author Stuart Langridge <sil@kryogenix.org>
// ==/UserScript==
if (external.getUnityObject) {
window.Unity = external.getUnityObject(1.0);
// use the Apple touch icon as icon
var icnsize=0, icnurl;
Array.prototype.slice.call(document.querySelectorAll("link[rel='apple-touch-icon']")).forEach(function(icn) {
@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"] }
}
}]
}
@stuartlangridge
stuartlangridge / TypeFileOut.py
Created January 9, 2014 16:11
Sublime Text 2 Python plugin to "type" the file that's currently being edited, character by character, for screencasts.
import sublime, sublime_plugin
BLOCKLEN = 4
class TypeFileOutCommand(sublime_plugin.TextCommand):
def nextchar(self):
if self.body:
totype = []
while 1:
try:
@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 / 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 / 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

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: