This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
def group_by_months(since, until): | |
"""Group a datetime range into month-based ranges with breaks at midnight. | |
>>> a = datetime(2015,11,5,3,12,5) | |
>>> b = datetime(2016,3,7,4,32,10) | |
>>> for i, (since, until) in enumerate(group_by_months(a, b)): | |
... print i, | |
... print since.strftime('%Y.%m.%d %H:%M:%S'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with | |
numbers as | |
(select 10 as _top, 50 as num_of_subscriptions, 28404 as unique_subscribers, 290 as number_of_lists), | |
people as | |
(select st_point(random() * 99 + 1, random() * 99 + 1) as g, 'special subscribers'::text as ty | |
from numbers n, generate_series(1,n._top)), | |
unique_people as | |
(select st_point(random() * 99 + 1, random() * 99 + 1) as g, 'unique subscribers'::text as ty | |
from numbers n, generate_series(1,n.unique_subscribers-n._top)), | |
subs as |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import os | |
import requests | |
def get_prj_wkt(srid): | |
url = 'http://epsg.io/%s.wkt' % srid | |
r = requests.get(url) | |
r.raise_for_status() | |
return r.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from lxml import etree | |
def iter_path(path, ext): | |
"""Returns an iterator over files on path with a certain fileextension.""" | |
for dirname, paths, files in os.walk(path): | |
for _file in files: | |
_fname, _ext = os.path.splitext(_file) | |
if _ext.lower() == '.%s' % ext.lower(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
import shutil | |
from time import time | |
# absolute path to gwc dir, e.g '/opt/geoserver/data/gwc' or 'c:/geoserver/data_dir/gwc' | |
TILEPATH = '<path_to_geoserver_gwc_dir>' | |
# All zoomfolders in os.path.join(TILPATH, TILELAYER) path that should be scanned, | |
ZOOMFOLDERS = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace function array_format_as_range( | |
arr int[], step int default 1) | |
returns varchar | |
as | |
$$ | |
declare | |
l int=array_upper(arr,1); | |
hyphen varchar='-'; | |
comma varchar=', '; | |
prv int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import requests | |
from PIL import Image | |
from io import BytesIO | |
URL = 'http://localhost:8080/geoserver/test/ows?' | |
params = { | |
'service':'wms', | |
'request':'getmap', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Calculate a polygon "mesh" with left/right side properties in PostGIS | |
* ---------------------------------------------------------------------- | |
* Based on Estonian third level administrative units data downloaded | |
* from the Estonian Land Board's homepage (May 2018) @ | |
* https://geoportaal.maaamet.ee/eng/Maps-and-Data/Administrative-and-Settlement-Division-p312.html | |
* Direct link to the shapefile - https://geoportaal.maaamet.ee/docs/haldus_asustus/asustusyksus_shp.zip | |
* | |
* The following SQL code is published under the Unlicense. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Subdividing "emtpy" space by expanding polygons | |
* ----------------------------------------------- | |
* This is the code-companion that is used in | |
* https://tkardi.ee/writeup/post/2018/07/21/subdividing-space/ | |
* | |
* Input data includes shapefiles from the Estonian Land Board's homepage | |
* (downloaded May 2018): | |
* - Estonian third level administrative units (settlements) with coastline | |
* borders: "asustusüksus", available for download from | |
* https://geoportaal.maaamet.ee/docs/haldus_asustus/asustusyksus_shp.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flask app to run the `proxy.py` script. | |
# Run it on the path where both of the files are saved with | |
# (on Linux, for other systems plese see | |
# http://flask.pocoo.org/docs/1.0/quickstart/#a-minimal-application) | |
# | |
# $ export FLASK_APP=flaskapp.py | |
# $ flask run | |
# | |
# This will make the API available at http://127.0.0.1:5000/flightradar | |
# |
OlderNewer