Skip to content

Instantly share code, notes, and snippets.

View jczaplew's full-sized avatar

John J Czaplewski jczaplew

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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 September 22, 2021 16:43
tqdm with multithreading
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)
@jczaplew
jczaplew / cancelable.js
Created June 4, 2018 20:21
Cancelable async
class Cancelable {
constructor() {
this.canceled = false
}
count(val) {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve(val*val)
}, 1000)
@jczaplew
jczaplew / test.sql
Created December 14, 2017 22:06
PostGIS Multipolygon Join
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;
SET idle_in_transaction_session_timeout = 0;
@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 / setup.sh
Created January 25, 2017 23:51
Install mapnik 3.+ on Ubuntu 14.04 Trusty
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
@jczaplew
jczaplew / keybase.md
Created January 17, 2017 18:49
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:

'''
Adapted from http://stackoverflow.com/a/1881201/1956065 and http://stackoverflow.com/a/25304159/1956065
12 January 2017
John J Czaplewski
[email protected]
'''
def xProduct(v0, v1, v2):
dx1 = v1[0] - v0[0]
dy1 = v1[1] - v0[1]
@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):