Skip to content

Instantly share code, notes, and snippets.

View palfrey's full-sized avatar

Tom Parker-Shemilt palfrey

View GitHub Profile
@palfrey
palfrey / controls.html
Last active August 29, 2015 14:19
Dalek Controls
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!--skip-->
<title>Dalek Controls</title>
<script type="text/javascript" src="controls.js"></script>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="http://underscorejs.org/underscore-min.js"></script>
palfrey@mruppity:[~/src/docker.ubuntu] vagrant up ubuntu-1404 <=====
Bringing machine 'ubuntu-1404' up with 'virtualbox' provider...
==> ubuntu-1404: Importing base box 'ubuntu/trusty64'...
==> ubuntu-1404: Matching MAC address for NAT networking...
==> ubuntu-1404: Checking if box 'ubuntu/trusty64' is up to date...
==> ubuntu-1404: Setting the name of the VM: dockerubuntu_ubuntu-1404_1430132322706_97353
==> ubuntu-1404: Clearing any previously set forwarded ports...
==> ubuntu-1404: Fixed port collision for 22 => 2222. Now on port 2206.
==> ubuntu-1404: Clearing any previously set network interfaces...
==> ubuntu-1404: Preparing network interfaces based on configuration...
@palfrey
palfrey / dalek.js
Created June 25, 2015 22:38
Dalek Video files
"use strict";
var selfEasyrtcid = "";
var otherClients = [];
var state = "observer";
var calling = false;
function getClient(rtcid) {
if (!_.has(otherClients, rtcid)) {
otherClients[rtcid] = {"contacted" : null, state : null, id: rtcid, feed: null};
console.log("OtherClients (after add): " + _.keys(otherClients));
CmdUtils.CreateCommand({
names: ["isgd"],
author: {name: "Thomas Brownback", homepage: "http://thomasbrownback.com", blog: "http://theorybloc.com"},
contributors: ["Tom Parker"],
thanks: {first: "Aza Raskin", foremost: "Aza Raskin", honorableMention: "geero.net", lastAmpBangLeast: "users like you"},
license: "PUBLIC DOMAIN: Any and all rights herein are hereby donated to the commons.",
description: "Shortens a URL using is.gd.",
help: "Replaces a selection with (or simply inserts) a shortened URL from is.gd.",
arguments: [{role: "urlToShorten",
nountype: noun_arb_text,
// ==UserScript==
// @name Remove left blank in Google results
// @namespace http://tevp.net/projects/
// @description Remove left blank in Google results
// @include http://www.google.*/search*
// ==/UserScript==
function xpath(query) {
return document.evaluate(query, document, null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
@palfrey
palfrey / gist:629139
Created October 15, 2010 23:22
Artist/Album/Title search
artist(Name) ->
lastfm_call(artist.search, [{artist,Name}], ['artistmatches'], ['artist'], []).
album(Name) ->
lastfm_call(album.search, [{album,Name}], ['albummatches'], ['album'], ['artist']).
track(Name) ->
lastfm_call(track.search, [{track,Name}], ['trackmatches'], ['track'], ['artist','listeners']).
<DocumentElement>
<Table>
<Id>657</Id>
<WLo>0.11070013046264648</WLo>
<WLa>51.493020732623478</WLa>
<GZ>15</GZ>
<LN>Abbey Wd - Felixstowe Rd</LN>
</Table>
<Table>
<Id>139</Id>
@palfrey
palfrey / gist:761092
Created December 31, 2010 15:45
Robolectric test
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
private Activity activity;
private Button pressMeButton;
private TextView results;
@Before
public void setUp() throws Exception {
activity = new MyActivity();
activity.onCreate(null);
@palfrey
palfrey / ShadowMenuInflater.java
Created December 31, 2010 15:44
ShadowMenuInflater
package com.xtremelabs.robolectric.shadows;
import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import com.xtremelabs.robolectric.internal.Implementation;
import com.xtremelabs.robolectric.internal.Implements;
import static com.xtremelabs.robolectric.Robolectric.shadowOf;
# get all the open heads
heads = revs(repo, "head() & (! closed())")
# find the common ancestor of default and revision_number ...
ancestor = revs(repo, "ancestor(%d, default)"% revision_number )[0]
# ... then get the path of changes between the common ancestor
# and our original revision
path = revs(repo, "%d::%d"%(ancestor, revision_number))
# The above can also be done just as