Skip to content

Instantly share code, notes, and snippets.

View JamesChevalier's full-sized avatar

James Chevalier JamesChevalier

View GitHub Profile
@JamesChevalier
JamesChevalier / overpass_query_all_streets.md
Last active March 20, 2024 13:33
Overpass API query to retrieve all streets in a city

An area ID in Overpass is the OSM relation ID + 3600000000

This information is kind of buried in the Overpass API wiki page documenting the available filters: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29

The OSM relation ID can be seen in two places:

  • Visit https://www.openstreetmap.org and search for the city
  • Click on its entry and you will be taken to a https://www.openstreetmap.org/relation/SOME_NUMBER_HERE page
  • The relation ID is in the URL as "SOME_NUMBER_HERE" in the bullet point above
  • The relation ID will also be in parentheses next to the city name in the left column
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler/setup'
require 'nokogiri'
require 'json'
require 'ap'
# Small script for scraping POIs from JOSM (http://wiki.openstreetmap.org/wiki/JOSM_file_format).
class Parser
# Tags in data that we ignore.

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@JamesChevalier
JamesChevalier / update_all_docker_images.sh
Created January 18, 2017 18:43
Update all docker images, ignoring untagged images, and then remove dangling images
#!/bin/bash
# collect the list of docker images
images=$(docker images --format "{{.Repository}}:{{.Tag}}")
# iterate through each image
for image in $images
do
if [[ $image != *"<none>"* ]]; then
# the image is tagged, so pull the latest version
@JamesChevalier
JamesChevalier / benchmark.rb
Created December 14, 2016 14:59
Ruby benchmark to compare <<, push, and concat
require 'benchmark'
iterations = 100_000
array_one = []
array_two = []
array_three = []
Benchmark.bmbm do |bm|
bm.report('<<') do
iterations.times do
@JamesChevalier
JamesChevalier / uuid_example.md
Created November 8, 2016 17:11
Simple example of how to get Rails to use UUID as a primary key as well as with a relation

migration to enable uuid in postgres

class EnableUuidExtension < ActiveRecord::Migration[5.0]
  def change
    enable_extension 'uuid-ossp'
  end
end
@JamesChevalier
JamesChevalier / howto.md
Created October 13, 2016 21:19
How to create a new EC2 instance from an existing EC2 instance
  • select the existing instance in the Instances list
  • open the Actions menu
  • select Image -> Create Image
  • enter 'Interim AMI' for the Image name
  • enter 'Interim AMI' for the Image description
  • if you cannot accept downtime of the origin instance, check the box for No reboot
    • The No reboot option means that the new image is created without gracefully stopping the machine first.
    • This can be problematic for some things, like a database that's mid-write.
    • If you can handle downtime, don't check the No reboot box.
  • click the Create Image button
@JamesChevalier
JamesChevalier / info.md
Created October 7, 2016 15:13
Caveat with making strict has_one relations in Rails

Let's say you have a User with this relation:

has_one :item

The has_one relation disallows you from doing this:

first_user = User.first
first_user.item.create(field_one: value, field_two: value)
@JamesChevalier
JamesChevalier / NominatimOnEC2.md
Created September 21, 2016 02:43 — forked from econandrew/NominatimOnEC2.md
Instructions for installing an OpenStreetMap Nominatim geocoder instance on Amazon Linux / EC2 (Dec 2014)

Installing Nominatim on Amazon Linux / EC2

  1. Introduction

The official instructions for installing Nominatim are complete, but brief in places, and several steps must be changed in the Amazon Linux environment (which is roughly CentOS / Redhat). The steps below are rough record of what I did to get it working, but I didn't keep perfect track so you shouldn't rely on them as a shell script. Just follow each step, make sure it worked, and hopefully you'll need to adapt very little (version numbers, for one thing). (I also skip in and out of root, but you can be more careful if you like.)

  1. Setting up the EC2 instance

@JamesChevalier
JamesChevalier / readme.md
Created September 4, 2016 18:36
How to set up S3/CloudFront/SSL

Create an SSL Certificate for your website

  • In the Certificate Manager console, click the Request a certificate button
  • Enter the domain name in the field
  • Click the Review and request button
  • Click the button in the email that this request sends you to validate the request

Create the bucket for your website in S3

  • Create a new bucket in s3