Skip to content

Instantly share code, notes, and snippets.

import React, { Component } from 'react';
import './App.css';
import 'onsenui/css/onsenui.css';
import 'onsenui/css/onsen-css-components.css';
import 'react-select/dist/react-select.css';
import { Page } from 'react-onsenui';
import Select from 'react-select';
class App extends Component {
@drwelby
drwelby / waze_download.ps1
Last active January 17, 2017 20:14
Waze file backup using PowerShell
// Powershell script to download a file from a url
// and save a timestamped copy
//=================================================
// SETTINGS
//The url of the file you want to download
$fileURL = 'https://na-georss.waze.com/YOUR/ENDPOINT'
// The directory where you want to store your backup.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
var rs = {
"type": "FeatureCollection",
"features": [
{
"geometry": {
"type": "Point",
"coordinates": [
-105.0763865,
40.540992500000002
]
var rs = {"type": "FeatureCollection", "features": [{"geometry": {"type": "Point", "coordinates": [-105.0763865, 40.540992500000002]}, "type": "Feature", "properties": {"url": "http://www.feastingfortcollins.com/?cat=635", "reviews": [{"date": "2011-04-25", "rating": 3, "url": "http://www.feastingfortcollins.com/1109/3-margaritas/", "title": "3 Margaritas"}], "name": "3 Margaritas", "rating": 3}}, {"geometry": {"type": "Point", "coordinates": [-105.075092, 40.395771000000003]}, "type": "Feature", "properties": {"url": "http://www.feastingfortcollins.com/?cat=490", "reviews": [{"date": "2010-09-03", "rating": 4, "url": "http://www.feastingfortcollins.com/349/th-street-chophouse/", "title": "4th Street Chophouse"}], "name": "4th Street Chophouse", "rating": 4}}, {"geometry": {"type": "Point", "coordinates": [-105.07713099999999, 40.5849209]}, "type": "Feature", "properties": {"url": "http://www.feastingfortcollins.com/?cat=462", "reviews": [{"date": "2013-11-03", "rating": 0, "url": "http://www.feastingfortcoll
@drwelby
drwelby / gist:8137625
Created December 26, 2013 19:24
downloadelkodocs.js
javascript:var%20params={};function%20SaveToDisk(fileURL,fileName){var%20save=document.createElement('a');save.href=fileURL;save.target='_blank';save.download=fileName||'unknown';var%20event=document.createEvent('Event');event.initEvent('click',true,true);save.dispatchEvent(event);(window.URL||window.webkitURL).revokeObjectURL(save.href);}if(location.search){var%20parts=location.search.substring(1).split('&');for(var%20i=0;i<parts.length;i++){var%20nv=parts[i].split('=');if(!nv[0])continue;params[nv[0]]=nv[1]||true;}}var%20baseUrl="http://records.elkocountynv.net:5442/docs/";var%20docNum=params.DocNo;var%20pad="0000000";padDocNum=(pad+docNum).slice(-pad.length);var%20imgUrl=baseUrl+padDocNum+".TIF";SaveToDisk(imgUrl,""+docNum+".tif");
@drwelby
drwelby / bitbinsort.md
Last active October 8, 2019 15:21
Bitwise binary range tree sorting, a la SBN

The SBN spatial index is some sort of binary range tree. I've been pretty close in reproducing the indexing by using a tree method, where the input bounding box is sorted through a tree structure by alternately comparing min/max coordinate pair against each division.

However, it's always seemed like there would be some faster way to sort features based on looking at individual bits in the binary representation of the coordinate value.

For example, let's say we have a 4 bit index space ( a 16 x 16 grid). We're trying to bin a bounding box with a max coordinate of (11,9) and min of (8,7).

Using the tree method, we would first look at the first split which occurs at an x of 8. Since xmin is equal to or greater than 8 that would sort the bounding box into the right bin. Next we would look at a y value of 8 for the second division. In this case the y value splits the bounding box, so the box cannot be sorted further and remains in the third bin.

We can also do this bitwise. What we first do is reverse the bin

import subprocess
import sys
import os
'''usage: pgimport path/to/fgdb layername database schema.tablename host user pass
This lets you import fgdbs into postgis tables that have views on them.
Uses an intermediate table to minimize downtime'''
fgdb, layer, db, target, host, user, password = sys.argv[1:]
import subprocess
import sys
'''usage: pgimport [path/to/fgdb] [database] [schema.tablename] [host] [user] [pass]
This lets you import fgdbs into postgis tables that have views on them '''
fgdb, db, target, host, user, password = sys.argv[1:]
# truncate the target table
sqlcmd = "psql"
@drwelby
drwelby / EZri.py
Created March 31, 2013 16:32
Deal with funky ESRI Python Result objects that don't return sane types, namely getCount which returns not an integer, but a Result object that contains a string.
# Deal with funky python Result objects that don't return sane types
def EZri(result):
value = result.getOutput(0)
#is it numeric?
try:
numval = float(value)
except ValueError:
return value
# maybe it's an int?