Skip to content

Instantly share code, notes, and snippets.

Avatar

James Harrison JamesHarrison

View GitHub Profile
@JamesHarrison
JamesHarrison / open-roads-prep.sql
Last active Mar 9, 2021
Using OS Open Roads in PostGIS (from Geopackage)
View open-roads-prep.sql
-- All credit to Marcus Young for the bulk of this:
-- https://www.marcusyoung.co.uk/using-pgrouting-with-the-os-open-roads-dataset
-- However, OS now provide Open Roads as a Geopackage dataset.
-- Don't use shapefile! Avoids classes of problems - no merge-and-dedupe needed, no rewriting column names, etc.
-- We import directly from Geopackage with the following command (using ogr2ogr from GDAL):
-- ogr2ogr -lco SCHEMA=os -F PostgreSQL PG:"your-connection-params" oproad_gb.gpkg
-- Only noteworthy thing - this creates an id column and a fid column. id is basically serial; fid is OS' reference.
-- In some cases it may be preferable to drop id, rename fid to id, etc - we keep both.
CREATE INDEX roadnode_fid_idx ON os.roadnode USING btree (fid);
View osoml-create-tables.sh
#!/bin/bash
# Set PGPASSWORD envvar if you don't want to be typing in your password all day
for tile in {TV,TR,TQ,TM,TL,TG,TF,TA,SZ,SY,SX,SW,SV,SU,ST,SS,SR,SP,SO,SN,SM,SK,SJ,SH,SE,SD,OV,NZ,NY,NX,NW,NU,NT,NS,NR,NO,NN,NM,NL,NK,NJ,NH,NG,NF,ND,NC,NB,NA,HZ,HY,HX,HW,HU,HT,HP}
do
for layer in {Building,ElectricityTransmissionLine,Foreshore,FunctionalSite,Glasshouse,ImportantBuilding,MotorwayJunction,NamedPlace,RailwayStation,RailwayTrack,RailwayTunnel,Road,RoadTunnel,Roundabout,SurfaceWater_Area,SurfaceWater_Line,TidalBoundary,TidalWater_Line,Woodland}
do
shp2pgsql -s 27700 -p -I "OSOpenMapLocal (ESRI Shape File) $tile/data/${tile}_${layer}.shp" "OSOML_$layer" | psql -h your-host -U username -d database
done
done
@JamesHarrison
JamesHarrison / theme-machine-kitty.reg
Last active Nov 29, 2019
Theme Machine. Person of Interest colours for your terminal.
View theme-machine-kitty.reg
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\9bis.com\KiTTY\Sessions\theme-machine]
"Colour0"="191,196,206"
"Colour1"="191,196,206"
"Colour2"="14,15,18"
"Colour3"="14,15,18"
"Colour4"="14,15,18"
"Colour5"="191,196,206"
"Colour6"="0,0,0"
View MultiWiiConfig.pde
import processing.serial.Serial; // serial library
import controlP5.*; // controlP5 library
import processing.opengl.*;
import java.lang.StringBuffer; // for efficient String concatemation
import javax.swing.SwingUtilities; // required for swing and EDT
import javax.swing.JFileChooser; // Saving dialogue
import javax.swing.filechooser.FileFilter; // for our configuration file filter "*.mwi"
import javax.swing.JOptionPane; // for message dialogue
//Added For Processing 2.0.x compabillity
View nginx-ssl.conf
server {
listen 443 ssl;
listen [::]:443 ipv6only=on ssl;
# .. other stuff like your ssl config here
location / {
add_header Strict-Transport-Security "max-age=3600";
# ABOVE FOR TESTING ONLY - once you're happy, use a longer policy time eg
# add_header Strict-Transport-Security max-age=86400;
proxy_set_header "X-Forwarded-For" $proxy_add_x_forwarded_for;
proxy_set_header "X-Forwarded-Proto" https;
View keybase.md

Keybase proof

I hereby claim:

  • I am JamesHarrison on github.
  • I am jamesharrison (https://keybase.io/jamesharrison) on keybase.
  • I have a public key whose fingerprint is 130E 52A1 DC1B 3B17 8AD9 87D4 D4F2 6072 FC76 6A7D

To claim this, I am signing this object:

View gist:3891494
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Linux version 3.2.27+ (dc4@dc4-arm-01) (gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) ) #160 PREEMPT Mon Sep 17 23:18:42 BST 2012
[ 0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[ 0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[ 0.000000] Machine: BCM2708
[ 0.000000] Memory policy: ECC disabled, Data cache writeback
[ 0.000000] On node 0 totalpages: 49152
[ 0.000000] free_area_init_node: node 0, pgdat c050d508, node_mem_map c05b5000
[ 0.000000] Normal zone: 384 pages used for memmap
[ 0.000000] Normal zone: 0 pages reserved
@JamesHarrison
JamesHarrison / recursive_optim.rb
Created Jun 7, 2012
A simple script that optimises images in the current folder using optipng, gifsicle and jpegoptim, plus exiftool for metadata
View recursive_optim.rb
#!/usr/bin/env ruby
# Recursively optimises in-place all images in a directory tree, starting in the current folder or a folder specified on the command line
# Dependencies:
# * optipng
# * gifscicle
# * jpegoptim
# * exiftool
# Recursively optimises a given path
def recursively_optimise(path,dt,depth=0)
View loquaciousd.py
#!/usr/bin/env python
# This is the loquacious daemon. It is designed to record audio clips from JACK upon noticing the microphones are on via Redis (simply use scripts to set the redis key 'mics' to 'on' or 'off').
# Uses JACK Timemachine in console mode in the background to handle the actual work of recording audio.
# Once it's done grabbing audio it pushes the filename (full path) to a Redis list. You can then write code to deal with new entries to the list and retrieve them; for instance, in our system we log each new recording as an Aircheck, and after each show, generate a podcast from the recorded data.
# Note you will need to cull old files on your own - the script does not deal with this. Something like:
# 0 * * * * find /home/insanity/loquaciousd/ -mtime +1 -delete
# in your crontab will do the job (removing all airchecks older than a day).
View gist:2211855
var now = new Date();
var future = new Date(2012, 3, 30, 12);
now.getTime()
1332814128628
future.getTime()
1335783600000
future - now