Skip to content

Instantly share code, notes, and snippets.

View jczaplew's full-sized avatar

John J Czaplewski jczaplew

View GitHub Profile
@jczaplew
jczaplew / readme.md
Created February 4, 2014 19:17
PostGIS to MySQL

Postgres:

psql

   CREATE DATABASE federal lands; 
   \c federal lands;
   CREATE EXTENSION postgis;
   CREATE EXTENSION postgis_topology;

shell

shp2pgsql -s 4326 fedlanp020.shp | psql -h localhost -U john -d federal_lands

@jczaplew
jczaplew / README.md
Last active January 18, 2021 21:02
Geologic Time Scale
@jczaplew
jczaplew / index.html
Created August 24, 2017 17:03
Supercluser + tilestrata + Mapbox GL JS
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.39.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@jczaplew
jczaplew / import_csv.py
Created November 28, 2016 03:09
Auto import csv to Postgres
import csv
import sys
import subprocess
with open(sys.argv[1], 'rb') as csvfile:
reader = csv.reader(csvfile)
header_row = reader.next()
cmd1 = "psql -U you dbname -c 'CREATE TABLE " + sys.argv[2] + " ("
for idx, column in enumerate(header_row):
@jczaplew
jczaplew / typeahead.html
Last active April 23, 2020 18:21
A very simple example showing how to force the Bootstrap typeahead (http://twitter.github.io/bootstrap/javascript.html#typeahead) to match only the start of words. The default matcher function matches the user query to any part of the possible results, which is often times undesirable - for example, in the standard typeahead in the example below…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.no-icons.min.css" rel="stylesheet"/>
</head>
<body>
<div style="padding:20px;">
<p>Standard Bootstrap typeahead</p><input placeholder='Type a country' type='text' size='22' name='countries' data-provide='typeahead'/>
@jczaplew
jczaplew / index.html
Last active March 16, 2020 16:21
Using d3.behavior.drag with a map
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
height: 500px;
position: relative;
width: 960px;
}
#projection-menu {
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.
@jczaplew
jczaplew / census_places.py
Created April 27, 2015 21:15
US Census incorporated places in PostGIS
import urllib2
import sys, os
from StringIO import StringIO
from zipfile import ZipFile
import psycopg2
import subprocess
# Connect to Postgres
pg_conn = psycopg2.connect(dbname="database", user="you", host="localhost", port=5432)
pg_cur = pg_conn.cursor()