Skip to content

Instantly share code, notes, and snippets.

View cblanc's full-sized avatar
🐇

Christopher Blanchard cblanc

🐇
View GitHub Profile
@cblanc
cblanc / outcodes_and_parliamentary_constituencies.csv
Created November 13, 2015 13:55
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
AB10 Aberdeen North,Aberdeen South
AB11 Aberdeen North,Aberdeen South
AB12 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB13 Aberdeen South,West Aberdeenshire and Kincardine
AB14 Aberdeen South,West Aberdeenshire and Kincardine
AB15 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB16 Aberdeen North
AB21 Aberdeen North,Gordon,West Aberdeenshire and Kincardine
AB22 Gordon
AB23 Aberdeen North,Gordon
@cblanc
cblanc / outcodes_and_parliamentary_constituencies.csv
Created November 13, 2015 13:55
select outcode, array_to_string(array_agg(distinct parliamentary_constituency),',') from postcodes group by outcode
AB11 Aberdeen North,Aberdeen South
AB12 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB13 Aberdeen South,West Aberdeenshire and Kincardine
AB14 Aberdeen South,West Aberdeenshire and Kincardine
AB15 Aberdeen North,Aberdeen South,West Aberdeenshire and Kincardine
AB16 Aberdeen North
AB21 Aberdeen North,Gordon,West Aberdeenshire and Kincardine
AB22 Gordon
AB23 Aberdeen North,Gordon
@cblanc
cblanc / postalCounties.json
Created May 24, 2017 13:15
List of Postal Counties
[
"Aberdeenshire",
"Kincardineshire",
"Banffshire",
"Hertfordshire",
"West Midlands",
"Warwickshire",
"Worcestershire",
"Staffordshire",
"Somerset",

Keybase proof

I hereby claim:

  • I am cblanc on github.
  • I am cablanchard (https://keybase.io/cablanchard) on keybase.
  • I have a public key ASBldidyjn7X2MmOTNq50qQs-Hb-uYObpbBBZ-PuCyMlbAo

To claim this, I am signing this object:

@cblanc
cblanc / hulls.sql
Created August 4, 2017 13:55
Computing Hulls from a List of Geometries
-- Compute Convex Hull for a list of geolocations matching the outcode 'SW1A'
SELECT
ST_AsText(ST_ConvexHull(ST_Collect(location::geometry))) AS hull
FROM
postcodes
WHERE
outcode = 'SW1A';
-- Compute Concave Hull for a list of geolocations matching the outcode 'SW1A'
-- Little bit more expensive but the polygons are a "tighter fit", the more you increase the second parameter the "tightness" increases but so does computational work required
@cblanc
cblanc / outcodes.csv
Created March 28, 2018 16:02
UK Outcodes - Feb 2018
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
AB10
AB11
AB12
AB13
AB14
AB15
AB16
AB21
AB22
AB23
const callbackifyPromiseWithTimeout = function(promise, callback) {
if (callback) {
// Ensure callback is called outside of promise stack.
return promise.then(function(res) {
setTimeout(function() { callback(null, res) }, 0);
}, function(err) {
setTimeout(function() { callback(err, null); }, 0);
});
}
@cblanc
cblanc / extraction.sh
Created January 7, 2019 08:39
Extract NL streetnames / postcodes
# Get raw dataset
wget https://s3.amazonaws.com/data.openaddresses.io/runs/554587/no/countrywide.zip
unzip countrywide.zip
# Extract street and postcode from CSV, get unique elements and stream to file
awk -F "\"*,\"*" '{print $4,$9}' countrywide/nl/countrywide.csv | uniq > nl-postcodes.txt
@cblanc
cblanc / postcodesio.pl
Last active February 9, 2019 22:09
Postcodes.io - Perl Example Postcode Lookup
#!/usr/bin/perl
# Kindly provided by github/@digdilem
my $pc = "TQ13 9XT"; # Example postcode (Dartmoor National Park Visitor's Centre, Haytor)
use LWP;
use JSON qw( decode_json );
my $ll_url = "https://api.postcodes.io/postcodes/$pc";
@cblanc
cblanc / outcodes.bash
Last active February 11, 2019 10:55
UK Outcodes generated from postcodes.io
docker pull idealpostcodes/postcodes.io.db
docker run -p 5432:5432 idealpostcodes/postcodes.io.db
psql -h 0.0.0.0 --username=postgres postgres -c "COPY (SELECT outcode FROM outcodes ORDER BY outcode) TO STDOUT WITH CSV DELIMITER ','" | pbcopy