Skip to content

Instantly share code, notes, and snippets.

View giacecco's full-sized avatar

Gianfranco Cecconi giacecco

View GitHub Profile
DROP TABLE IF EXISTS temp_active_postcodes;
CREATE TABLE temp_active_postcodes AS (
SELECT DISTINCT id AS pcd
FROM os_open_names
WHERE local_type = 'Postcode' AND country IN ('England', 'Wales')
);
SELECT COUNT(pcd) FROM temp_active_postcodes;
DROP TABLE IF EXISTS temp_retired_postcodes;
CREATE TABLE temp_retired_postcodes AS (
SELECT DISTINCT pcd
FROM lr_9501_1504
WHERE pcd NOT IN (SELECT pcd FROM temp_active_postcodes)
);
SELECT COUNT(pcd) FROM temp_retired_postcodes;
.../OLAF-import-open_roads$ node import.js --in ~/Data\ archive/os/open-roads/1506120854/
Importing /Users/giacecco/Data archive/os/open-roads/1506120854/oproad_essh_gb.zip...
NOTICE: table "os_open_roads_roadnodes" does not exist, skipping
NOTICE: table "os_open_roads_roadlinks" does not exist, skipping
Shapefile type: Point
Postgis type: POINT[2]
ERROR: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
DETAIL: Key (typname, typnamespace)=(os_open_roads_roadnodes_gid_seq, 2200) already exists.
Shapefile type: Arc
Postgis type: MULTILINESTRING[2]
.../OLAF-import-open_roads$ node import.js --in ~/Data\ archive/os/open-roads/1506120854/
Importing /Users/giacecco/Data archive/os/open-roads/1506120854/oproad_essh_gb.zip...
Shapefile type: Point
Postgis type: POINT[2]
ERROR: column not found in geometry_columns table
CONTEXT: SQL statement "SELECT DropGeometryColumn('',$1,$2,$3)"
PL/pgSQL function dropgeometrycolumn(character varying,character varying,character varying) line 5 at SQL statement
ERROR: table "os_open_roads_roadnodes" does not exist
Done.
@giacecco
giacecco / gist:43c6b206239bfaa16f97
Created June 10, 2015 08:13
QGIS 2.9.3 on MacOS - Error: "This plugin is broken / cannot import name AlgorithmDecorator"
Couldn't load plugin 'processing' from ['/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/giacecco/.qgis2/python', '/Users/giacecco/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/C/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7/site-packages', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Python/2.7/site-packages/matplotlib-override', '/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7
@giacecco
giacecco / brew config
Created June 8, 2015 10:47
Homebrew incorrectly flags "dinkypumpkin/get_iplayer" as a private repository
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: ddba0eade696d61aec903cca0405a21aafccdb3b
Last commit: 18 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit haswell
OS X: 10.10.3-x86_64
Xcode: 6.3.2
CLT: 6.3.2.0.1.1431401888
@giacecco
giacecco / R interactive session
Last active September 9, 2016 14:53
Open Addresses UK - Basic inference example
> library(dplyr)
> # I read the ZE postcode area data from the Open Addresses UK 'split'
> # CSV distro
> oa <- read.csv("~/Downloads/2014-12-10-openaddressesuk-addresses-only-split.csv/ZE.csv", stringsAsFactors=FALSE)
> # I drop the addresses whose Primary Addressable Objects (PAO) can't be
> # interpreted as numbers
> oa$pao <- as.integer(oa$pao)
Warning message:
NAs introduced by coercion
> oa <- oa[!is.na(oa$pao),]
@giacecco
giacecco / example_of_full_provenance.json
Created November 21, 2014 12:48
Provenance scaffolding
{"saon":{"name":"823 SALISBURY HOUSE"},"paon":{"name":"29"},"street":{"name":"FINSBURY CIRCUS","geometry":{"type":"Point","coordinates":[532850,181571]}},"locality":{"name":null},"town":{"name":"LONDON"},"postcode":{"name":"EC2M 5QQ","geometry":{"type":"Point","coordinates":[532775,181588]}},"country":{"name":null},"provenance":{"activity":{"processing_scripts":"[LINK TO THE DISTILLER REPOSITORY **TREE** used for distillation]","executed_at":"2014-11-19T09:53:14.000Z","derived_from":[{"type":"Source","description_url":"http://download.companieshouse.gov.uk/en_output.html","url":["http://download.companieshouse.gov.uk/BasicCompanyData-2014-11-01-part1_5.zip","http://download.companieshouse.gov.uk/BasicCompanyData-2014-11-01-part2_5.zip","http://download.companieshouse.gov.uk/BasicCompanyData-2014-11-01-part3_5.zip","http://download.companieshouse.gov.uk/BasicCompanyData-2014-11-01-part4_5.zip","http://download.companieshouse.gov.uk/BasicCompanyData-2014-11-01-part5_5.zip"],"name":"Companies House's \"Free Comp
LOG FILE :
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex 2014.8.12) 14 AUG 2014 12:50
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test.tex
(./test.tex
LaTeX2e <2014/05/01>
Babel <3.9k> and hyphenation patterns for 78 languages loaded.
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/article.cls
@giacecco
giacecco / test.js
Created August 10, 2014 17:58
Can't throw errors in the callback
var CONNECTION_PARAMETERS = {
'host': 'datafeeds.networkrail.co.uk',
'port': 61618,
'connectHeaders': {
'host': '/',
'login': process.env.NROD_USERNAME,
'passcode': process.env.NROD_PASSWORD,
'client-id': ((process.env.DEBUG !== 'true') ? process.env.NROD_USERNAME : undefined),
}
},