Skip to content

Instantly share code, notes, and snippets.


John J Czaplewski jczaplew

View GitHub Profile
jczaplew / gist:5799404
Last active Jul 19, 2021
502 Proxy Error with Apache, Node, and MySQL
View gist:5799404
Node running on :8080
Apache running on :80
Using Apache mod_proxy to forward application requests to :8080
On client:
1. Proxy Error
The proxy server received an invalid response from an upstream server.
jczaplew /
Last active Jun 6, 2021
Setting up a LaunchDaemon with pm2

Setting up a LaunchDaemon with pm2

If you have a Node.js app running on an OS X server, you probably:

  • Want it to start automatically when the system boots
  • Want to use something like pm2 or forever to monitor the status of the app, log errors, and make sure it stays up

While pm2 has the ability to generate startup scripts for use with Ubunutu, Centos, and systemd, it does not work with OS X. The best approach is to use launchd, an OS X-specific daemon manager that replaces cron. It uses XML-based files for configuration. This guide will walk you through the process. Note: "xyz" is used as a placeholder for the application name throughout this guide.


jczaplew /
Last active Apr 5, 2021
A tool for extracting data from PostGIS into GeoJSON and TopoJSON. UPDATE: Added a dedicated repo for contributions -
A simple tool for exporting from a PostGIS table to GeoJSON and TopoJSON. Assumes Python 2.7+,
psycopg2, and TopoJSON are already installed and in your PATH.
Adapted from Bryan McBride's PHP implementation
by John Czaplewski | | @JJCzaplewski
- Add argument for SRS
jczaplew / pgFormatDate.js
Created Apr 24, 2015
Javascript Date to Postgres-acceptable format
View pgFormatDate.js
// Convert Javascript date to Pg YYYY MM DD HH MI SS
function pgFormatDate(date) {
/* Via */
function zeroPad(d) {
return ("0" + d).slice(-2)
var parsed = new Date(date)
jczaplew /
Created Feb 4, 2014
PostGIS to MySQL



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


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

View github-print-bookmarklet
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,,%20%23last-edit,%20.actions,%20.header,.site-footer,.repository-sidebar,.file-navigation,.gh-header-meta,.gh-header-actions,#wiki-rightbar,#wiki-footer,.commit-tease').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D); var removeMe = document.getElementsByClassName("file-header")[0]; removeMe.parentNode.removeChild(r
jczaplew /
Last active Jan 22, 2021
Heroku + Github + Sensitive Data

Heroku + Github + Sensitive Data

Scenario: You deployed a Heroku project that contains sensitive data (password, API key, etc) but you want to share it on Github.

Problem: You need to commit all files necessary for the application to run on Heroku. However, pushing this to Github would reveal the sensitive info.

Solution: Have a production branch (for this example, master will be the production branch) and a Github branch. The latter contains a different .gitignore that ignores the sensitive files.

jczaplew /
Last active Jan 18, 2021
Geologic Time Scale
jczaplew / index.html
Created Aug 24, 2017
Supercluser + tilestrata + Mapbox GL JS
View index.html
<!DOCTYPE html>
<meta charset='utf-8' />
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src=''></script>
<link href='' rel='stylesheet' />
body { margin:0; padding:0; }
jczaplew /
Created Nov 28, 2016
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 =
cmd1 = "psql -U you dbname -c 'CREATE TABLE " + sys.argv[2] + " ("
for idx, column in enumerate(header_row):