Skip to content

Instantly share code, notes, and snippets.

/*
* We don't want to log each fetching of a value from a sequence,
* so we pre-log a few fetches in advance. In the event of
* crash we can lose (skip over) as many values as we pre-logged.
*/
#define SEQ_LOG_VALS 32
@petehamilton
petehamilton / postfacto.js
Last active June 2, 2017 16:28
Postfacto -> Paper
// Copy the below into the browser's console on a Postfacto archive screen
(() => {
let components = [
`## Postfacto archive: ${window.location}`,
];
components = components.concat(
[
{ title: 'It wasn\'t so great that...', points: $$('.column-sad .item-text').map((el) => el.innerText) },
(() => {
const groups = [].slice.apply(document.querySelectorAll('.issueContainer'))
.map((node) => {
return {
link: node.querySelector('.issue-info a').getAttribute('href'),
id: node. querySelector('.issueId').textContent.trim(),
title: node.querySelector('.issue-summary').textContent.trim(),
priority: node.querySelector('[title^="Priority: "]').textContent.trim(),
type: node.querySelector('[title^="Type: "]').textContent.trim(),
};
@petehamilton
petehamilton / plot-data.r
Last active February 8, 2018 17:43
Plot GoCardless Customers by Location
# Execute with: R --slave -f draw.r
library(maps)
library(mapdata)
library(foreach)
library(doParallel)
# Use the GoCardless font
par(family="Gotham-Book")
@petehamilton
petehamilton / openssl-encrypt.sh
Last active March 5, 2016 09:26
Example of Encrypting File with OPENSSL. Based on http://www.czeskis.com/random/openssl-encrypt-file.html
#! /usr/bin/env bash
set -e
set -u
PRIVATE_KEY='private-key.pem'
PUBLIC_KEY='public-key.pem'
KEY_FILE="key.bin"
KEY_FILE_ENCRYPTED="key.bin.enc"
CSV_FILE='fixture-secret.txt'

Keybase proof

I hereby claim:

  • I am petehamilton on github.
  • I am petehamilton (https://keybase.io/petehamilton) on keybase.
  • I have a public key whose fingerprint is 7809 8DC6 825F 4184 8139 C43B 0621 AE2E 2952 C17E

To claim this, I am signing this object:

var app = angular.module('testapp', ['ngRoute']);
app.config(function ($locationProvider) {
// $locationProvider.html5Mode(true);
})
app.controller('MainCtrl', function ($scope, $location, $route) {
// Example URLs which should work on refresh
//
@petehamilton
petehamilton / README.md
Last active December 19, 2015 17:39
FlatUI Radio Button Directive for AngularJS

FlatUI RadioButton AngularJS Directive

This means you can ignore the "flatui-radio.js" file and just use plain angular. Not had any problems so far.

screen shot 2013-07-14 at 07 07 19

@petehamilton
petehamilton / are_exam_results_up_yet.sh
Last active December 19, 2015 07:09
Are exams results online yet?
#!/bin/bash
EXAMS_URL="https://exams.doc.ic.ac.uk/"
echo "##############################################"
echo "# Exam Results Checker"
echo "##############################################"
echo -ne "Username: "
read username
stty -echo