Skip to content

Instantly share code, notes, and snippets.

Avatar

John J Czaplewski jczaplew

View GitHub Profile
View out.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View test.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jczaplew
jczaplew / tqdm-multithreading.py
Last active Dec 25, 2019
tqdm with multithreading
View tqdm-multithreading.py
from tqdm import *
from queue import Queue
from threading import Thread
import time
THREADS = 4
class WorkerThread(Thread):
def __init__(self, queue):
Thread.__init__(self)
View cancelable.js
class Cancelable {
constructor() {
this.canceled = false
}
count(val) {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve(val*val)
}, 1000)
@jczaplew
jczaplew / test.sql
Created Dec 14, 2017
PostGIS Multipolygon Join
View test.sql
This file has been truncated, but you can view the full file.
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.4
-- Dumped by pg_dump version 9.6.4
SET statement_timeout = 0;
SET lock_timeout = 0;
@jczaplew
jczaplew / index.html
Created Aug 24, 2017
Supercluser + tilestrata + Mapbox GL JS
View index.html
<!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 / setup.sh
Created Jan 25, 2017
Install mapnik 3.+ on Ubuntu 14.04 Trusty
View setup.sh
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install git
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update && sudo apt-get install gcc-4.9 g++-4.9
rm /usr/bin/g++ && sudo ln -s /usr/bin/g++-4.9 /usr/bin/g++
wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.34.tar.bz2
View keybase.md

Keybase proof

I hereby claim:

  • I am jczaplew on github.
  • I am johnjcz (https://keybase.io/johnjcz) on keybase.
  • I have a public key whose fingerprint is 8FB0 0594 B47A F27F 890D 5EE6 969F F71E 2039 17F8

To claim this, I am signing this object:

View isConvex.py
'''
Adapted from http://stackoverflow.com/a/1881201/1956065 and http://stackoverflow.com/a/25304159/1956065
12 January 2017
John J Czaplewski
john@czaplewski.org
'''
def xProduct(v0, v1, v2):
dx1 = v1[0] - v0[0]
dy1 = v1[1] - v0[1]
@jczaplew
jczaplew / import_csv.py
Created Nov 28, 2016
Auto import csv to Postgres
View import_csv.py
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):
You can’t perform that action at this time.