Skip to content

Instantly share code, notes, and snippets.



View GitHub Profile
JamesChevalier /
Last active Jul 6, 2021
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:

The OSM relation ID can be seen in two places:

  • Visit and search for the city
  • Click on its entry and you will be taken to a 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
mdo /
Last active Jul 28, 2021
Instructions for how to affix an Ikea Gerton table top to the Ikea Bekant sit-stand desk frame.

Ikea Bekant standing desk with Gerton table top

kaitmorano /
Created Oct 20, 2015 — forked from TDahlberg/
GeoData Science Learning Resources

#“A data scientist is someone who knows more statistics than a computer scientist and more computer science than a statistician.” -Josh Blumenstock

#"A geo-data scientist is someone who knows more about GIS than either of those guys." -Tyler Dahlberg

#Going Geo Open Source In all likelihood a list like this has been written somewhere, by someone, for some reason. I know I'm not breaking any ground here; I'm just trying to organize on paper what's been going through my head ever since I got out of grad school.

ctrezevant / smokey.conf
Last active Dec 30, 2017
This bit of lighttpd configuration is what I use to stop image hotlinking, while also ensuring that search engines and social media can still access images.
View smokey.conf
###Hotlinking madness :^)
$HTTP["host"] =~ "charltontrezevant\.com" {
$HTTP["referer"] !~ "charltontrezevant|ctis\.me|google|bing|facebook|twitter|reddit|ycombinator|Skype|Slack" {
$HTTP["useragent"] !~ "Google|msnbot|FlipBoard|Bing|Yahoo|Facebook|Yandex|twitter|Slack|Skype" {
$HTTP["url"] =~ "\.jpeg|\.jpg|\.png|\.gif|\.bmp" {
$HTTP["url"] !~ "hotlinking\.png" {
url.redirect = ("" => "")
dapangmao /
Last active Apr 5, 2016
Spark example

###Transform RDD to DataFrame in Spark

from pyspark.sql import Row
import os

rdd = sc.textFile('C:/Users/chao.huang.ctr/spark-playground//class.txt')
def transform(x):
    args = x.split()
    funcs = [str, str, int, float, float]
pbugnion /
Last active Jul 26, 2021
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

jbarratt / nbgrep
Last active Apr 26, 2020
'nbgrep', search the code of all your ipython notebooks
View nbgrep
# usage: nbgrep 'pattern'
# 'jq' technique lifted with gratitude
# from
# Break on newlines instead of any whitespace
vicapow /
Last active Dec 17, 2019
An example of creating a PNG from an SVG in D3.

This is an example of creating a PNG from an SVG. (You should notice that you're able to right click on the last image and save it as a PNG image.) It has been Tested in Firefox and Chrome but doesn't work in Safari as of 2014-07-20.

Normally, you'll create your SVG in D3 but to make the example a bit more readable, the SVG is already placed in the document. There are a few important points. Namely:

  1. All the styles of the SVG need to be self contained in side of the <defs> tags. (These styles should be escaped using the <![[CDATA[ ... ]] tag.)
  2. The SVG needs to have the proper namespaces and document types.
  3. The SVG needs to be saved to an image, then read from an canvas element, then saved to an image again.

Note: Portions of this demo where taken from The New York Times' excellent Crowbar SVG extractor.

soheilhy /
Last active Jul 29, 2021
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for,, and on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

# extracted from http//
# under public domain terms
country_bounding_boxes = {
'AF': ('Afghanistan', (60.5284298033, 29.318572496, 75.1580277851, 38.4862816432)),
'AO': ('Angola', (11.6400960629, -17.9306364885, 24.0799052263, -4.43802336998)),
'AL': ('Albania', (19.3044861183, 39.624997667, 21.0200403175, 42.6882473822)),
'AE': ('United Arab Emirates', (51.5795186705, 22.4969475367, 56.3968473651, 26.055464179)),
'AR': ('Argentina', (-73.4154357571, -55.25, -53.628348965, -21.8323104794)),
'AM': ('Armenia', (43.5827458026, 38.7412014837, 46.5057198423, 41.2481285671)),