Skip to content

Instantly share code, notes, and snippets.

View jnicho02's full-sized avatar

Jez Nicholson jnicho02

View GitHub Profile
@jnicho02
jnicho02 / osm_station_tags
Created October 27, 2012 09:12
What other OSM tags do train stations have
SELECT
tag.k, count(*)
FROM
public.node_tags tag
WHERE
tag.node_id in
(SELECT
node_id
FROM
public.node_tags t2
@jnicho02
jnicho02 / gist:4008095
Created November 3, 2012 17:45
OSM train stations that are buildings
SELECT
t1.way_id, name_tags.v AS name
FROM way_tags AS t1
INNER JOIN way_tags AS t2 ON (t1.way_id = t2.way_id
and t2.k = 'railway' and t2.v in ('station','train_station','railway_station','railway station','train_station;bus_station','train station','underground_station','rail_station','trian station')
)
LEFT OUTER JOIN way_tags AS name_tags ON (t1.way_id=name_tags.way_id AND name_tags.k='name')
WHERE t1.k = 'building' and t1.v in ('yes','true')
UNION
@jnicho02
jnicho02 / gist:5467350
Created April 26, 2013 13:20
writes out ruby code that can be fed in to Trimble Sketchup
require 'OSM/API'
@api = OSM::API.new
db = @api.get_bbox(-5.2134537,50.040992,-5.0993322,50.2582661)
puts 'require \'sketchup.rb\''
puts 'model = Sketchup.active_model'
db.ways.each { |way|
prev = nil
way[1].node_objects.each { |node|
if (prev)
@jnicho02
jnicho02 / UK hill figures.geojson
Last active March 8, 2023 12:21
Locations of (often) chalk hill figures in the UK
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
contract jtoken {
mapping (address => uint) public balances;
address public admin;
uint tax;
function jtoken()
{
balances[msg.sender] = 1000;
admin = msg.sender;
tax = 1;
@jnicho02
jnicho02 / renewables.rb
Created October 20, 2015 13:03
converting government renewable energy planning permission csv to geojson
require 'csv'
require 'rgeo'
require 'proj4'
require 'rgeo/geo_json'
require 'json'
csv_text = File.read('Public_Database_-_Sept_2015.csv')
csv = CSV.parse(csv_text, :headers => true)
features = []
coder = RGeo::GeoJSON::Coder.new
@jnicho02
jnicho02 / Gemfile
Last active April 8, 2016 17:19
matching Leeds Data Mill blue plaques to Open Plaques
source "https://rubygems.org"
gem 'ckan', github: 'fishpercolator/CKAN'
gem 'open_uri_redirections'
@jnicho02
jnicho02 / heroku-live-to-local.sh
Created March 3, 2017 13:19
a really useful script for Heroku + Rails. Generate a db backup, download it, create a new db, import data, update database config to point at it
heroku pg:backups capture --app open-plaques-beta
curl -o db/db.dump `heroku pg:backups --app open-plaques-beta public-url`
createdb openplaques_$(date +'%Y-%m-%d')
pg_restore -d openplaques_$(date +'%Y-%m-%d') db/db.dump
sed -iE "s/openplaques_[0-9|-]*/openplaques_$(date +'%Y-%m-%d')/g" config/database.yml
@jnicho02
jnicho02 / gist:0884f366eff8d64d165c2e1fd99e870b
Last active July 6, 2017 10:05
Cloud9 Rails5 Heroku update
Cloud9.io has a Rails template project, but it is Rails 4
Check that it is still Rails 4:
$ rails -v
Rails 5 needs ruby 2.2.2 minimum, but I belive that Cloud9 has 2.3.0p0....just check:
$ ruby -v
Update the rails installation to 5:
$ gem install rails