Skip to content

Instantly share code, notes, and snippets.

View pbabik's full-sized avatar

Michał Mackiewicz pbabik

View GitHub Profile
@pbabik
pbabik / track2geojson.py
Created October 28, 2016 13:09
Dashboard Cam to GeoJSON converter
#!/usr/bin/python
import json
import sys
args = sys.argv
if len(args) != 3:
print """Usage: track2geojson.py <input>.json <output>.json"""
exit()
@pbabik
pbabik / kv_battle.py
Created November 3, 2015 20:33
Key-value stores battle: Redis versus UnQLite
#!/usr/bin/python
# -*- coding: utf-8 -*-
import redis
import random
import json
import time
import hashlib
from unqlite import UnQLite
@pbabik
pbabik / csv2tabson.py
Created April 9, 2015 11:55
Script to convert standard comma-separated CSV to TabSON format
#!/usr/bin/python
# -*- coding: utf-8 -*-
import csv
import sys
import re
import json
args = sys.argv
ZEROLENGTH_AS_NULL = False
@pbabik
pbabik / legends.py
Last active September 4, 2015 04:57
Generate PNG symbols for every layer in QGIS project
from PyQt4.QtCore import QSize
layers = QgsMapLayerRegistry.instance().mapLayers()
for name,layer in layers.iteritems():
counter = 0
symbols = layer.rendererV2().symbols()
for symbol in symbols:
img = symbol.asImage(QSize(16,16))
filename = '/home/user/%s_%s.png' % (name,str(counter))
counter = counter + 1
img.save(filename)
@pbabik
pbabik / getfeature2.php
Created October 25, 2014 16:01
PHP PostGIS to GeoJSON - using JSON functions
<?php
/** Super Lazy PHP PostGIS to GeoJSON
* @originalAuthors Leo Hsu and Regina Obe
* @url http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html
* @phpImplementation pbabik <https://github.com/pbabik>
* @license WTFPL 2 <http://www.wtfpl.net/txt/copying/>
* @requires PostgreSQL 9.3 && PostGIS 2.1 or higher
**/
@pbabik
pbabik / getfeature.php
Created March 21, 2012 10:22 — forked from bmcbride/postgis_geojson.php
PHP PostGIS to GeoJSON - with BBOX query
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $bbox Bounding box of request *REQUIRED*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*