Skip to content

Instantly share code, notes, and snippets.

View stupidpupil's full-sized avatar
💭
I may be slow to respond.

A Watkins stupidpupil

💭
I may be slow to respond.
View GitHub Profile
@stupidpupil
stupidpupil / welsh_setup.sh
Last active December 19, 2015 12:03
Set of instructions to setup and import Welsh data into OpenPrescribing
python manage.py create_foreign_keys
python manage.py create_indexes
python manage.py create_matviews
python manage.py import_ccg_boundaries --filename data/org_codes/welsh_localities.kml
python manage.py import_welsh_local_health_board_names
python manage.py import_welsh_locality_names
python manage.py fetch_nwssp_prescribing
python manage.py import_nwssp_practices
@stupidpupil
stupidpupil / welshify_kml.rb
Created December 19, 2015 12:06
Reduces UA boundaries from http://idea.ed.ac.uk/data/kmz/ to only Wales and only Polygons
require 'nokogiri'
wales = Nokogiri::XML(File.read('GB.kml')) ; 1
las = {'6B1' => 'Anglesey',
'6C2' => 'Blaenau Gwent',
'6B3' => 'Bridgend',
'6B2' => 'Caerphilly',
'6A8' => 'Cardiff',
'6B7' => 'Carmarthenshire',
#include <stdio.h>
#include <krb5.h>
int main()
{
printf("krb5_principal: %zu chars\n", sizeof(krb5_principal)/sizeof(char));
printf("krb5_creds: %zu chars\n", sizeof(krb5_creds)/sizeof(char));
printf("krb5_verify_init_creds_opt: %zu ints\n", sizeof(krb5_verify_init_creds_opt)/sizeof(int));
return 0;
@stupidpupil
stupidpupil / keybase.md
Last active August 27, 2016 20:13
Keybase proof

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@stupidpupil
stupidpupil / pre-commit.sh
Last active September 1, 2016 00:32
Beancount git pre-commit hook
#!/bin/sh
git stash --quiet --keep-index --include-untracked
bean_check_err=`bean-check main.beancount 2>&1 >/dev/null`
git stash pop --quiet --index
error_lines=`printf "$bean_check_err" | wc -l | awk {'print $1'}`
if [ $error_lines -eq 0 ]; then
echo "\\033[32mBean-check passed! 💰\\033[0;39m"
@stupidpupil
stupidpupil / alfa.rb
Created January 10, 2017 22:33
A script for spelling out strings using macOS's `say` command
#!/usr/bin/env ruby
# A script for spelling out strings using macOS's `say` command.
# Uses the NATO/ICAO spelling alphabet, mostly.
# Mapped to spellings that produce the desired effect, specifically with the Fiona voice.
# Didn't use phonemes as these are not reliably available for recent (Nuance) voices.
# TODO: Use ICU to get Unicode character names
mapping = {
'a' => 'alfa',
function plotIsOnAnIsland(pPlot)
local canGoOnLand
canGoOnLand = function (pStartingPlot, iDirection, iDistance, iDirectionConstraint)
if iDirectionConstraint == nil then
iDirectionConstraint = iDirection
end
local directionMeetsConstraint = function(dir)
@stupidpupil
stupidpupil / usr.sbin.hostapd
Last active September 12, 2017 00:04
hostapd Debian AppArmor profile
#include <tunables/global>
/usr/sbin/hostapd {
#include <abstractions/base>
#include <abstractions/nameservice>
capability net_admin,
capability net_raw,
network packet,
network raw,
@stupidpupil
stupidpupil / gist:83be3a5d0daf3db17b2b
Created April 16, 2015 23:59
FreeOTP Tokens.xml Exporter
#!/usr/bin/env ruby
module GoogleBase32
Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" #RFC4648
Digits = Alphabet.chars
Mask = Digits.length - 1
Shift = Digits.length.to_s(2).match(/0*\Z/)[0].length
def self.encode_array(array)
@stupidpupil
stupidpupil / bnf_name.peg
Last active August 8, 2018 19:33
BNF Name PEG
bnf_name <-
("Gppe " form "_" product_name_word (" "* (ratio / quantity / modifier / product_name_word))*) /
((product_name_word " "?)+ "_" (" "* (!form product_name_word))* " "* form (" "* (ratio / quantity / modifier))*)
;
product_name_word <- r'[^\s_]+' ;
ratio <- (quantity / number) ("/" / ";") (ratio / quantity / unit / number);