Skip to content

Instantly share code, notes, and snippets.

@ping13
ping13 / .emacs
Created December 9, 2012 20:26
My $HOME/.emacs file
; I use Emacs on three different platforms and I want to use the same init file.
; So, this file lives as $HOME/.emacs and is just a pointer to an init file in my Dropbox.
; The machine specific automatic customizations are saved here nonetheless.
; The real dot-emacs file is in ~/Dropbox/myemacs/init.el
(setq my-emacs-root (expand-file-name "~/Dropbox/myemacs/"))
(add-to-list 'load-path my-emacs-root)
(load-file (concat my-emacs-root "init.el"))
; automatic customization
;; call howdoi, https://github.com/gleitz/howdoi
(defvar howdoi-history nil "History for howdoi lookups, see `howdoi'")
(defun howdoi ()
"Interactive function for howdoi queries. It takes the current
word and invokes a minibuffer where the user can accept or change
the query."
(interactive)
(shell-command
(concat "howdoi "
(read-from-minibuffer "howdoi: "
@ping13
ping13 / geobeer_counter.py
Last active December 23, 2015 17:09
Simple counter script for http://geobeer.ch
#!/usr/local/bin/python2.7
import gspread
import json
import httplib
import urllib2
import urllib
import re
import os
import datetime
@ping13
ping13 / argparse_verbose.py
Last active August 29, 2015 13:56
How to set verbosity level based on command line flag
import argparse
import logging
logging.basicConfig()
logger = logging.getLogger()
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", const = 1, default = 0,type = int, nargs="?",
help="increase verbosity: 0 = only warnings, 1 = info, 2 = debug. No number means info. Default is no verbosity.")
@ping13
ping13 / simple_worker.py
Last active August 29, 2015 14:00
Simple example for a set of workers in Python using a function with multiple arguments (even named ones)
# Simple example for a set of workers in Python using a function with multiple
# arguments (even named arguments)
# Sources of information:
# - https://docs.python.org/2/library/multiprocessing.html
# - http://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments/5443941#5443941
from multiprocessing import Pool, freeze_support
import itertools
@ping13
ping13 / decode_base64.py
Last active August 29, 2015 14:06
Simple example on how to decode a base64 encoded data string and save it as an image file.
# Simple example on how to decode a base64 encoded data string and save it as an image file.
# Stephan Heuel, Ernst Basler + Partner
import re
# our base64-encoded image
s = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAADLElEQVR4nO2Zv2vbQBTHX0qK6WBMHKw6EOIhdvEi8I8EPByleKr3GLoFCqFbxsyeOnTsZjx5K/gPcKFUZLghkEQpeHGxPVgEGmywWzwU45Z0qE+V5ZMl3Q81gz+gwdJZel+99+7eO23c338Fv4TVBl51fdIqI57xLDzivQENN8N5x9PYYPEIebiSS5q/B3p3acykVUZejPyvHrE/3CqKNm7SKiMllwTrIRKhoeUmhjZelKBNIXexISJU/MLlkVk+DrN8HHr1LOrVs2igd11FzPLxpXP7xzfcyc4sZO/9N/PhxBCvIsgLEAmTEPtMlHi16+l/xumOtJBjyhEllwS4vgMSSsXmEBebQ6yVYlRDi80hNXRm+Tg8vr5jMWEJ30JIGFnzQSvFUEU3cEU3cCW3hwAAKrphMf6JEGNX4WtBJCHllAsV3cAvd6cAAPDxNvTv/FwcwGJu2b3Rq2eZQ8+3ELeEvhh0MABAQUk5jiNiRArxFVqi1gdaXvwtcbLM9xReNBaUFHoW+Q2jaZt7bfCDlOqXQMLMDVJw8lTBzNWvB4hR1HDcP77BThUzy8OkemQO9S3TRPAgUwgih9eQ4ZlMmIV4MW6e8J4aK94ZkbtDdJr7w2oD969UyFQj8OXND/N84qAlpcxn9ghpiGieGU3buH+lQuKgBeMahmgobRq+dYIWVndRMAshntg6WXy5YbWBM9UIRENpZA2ZI20bjrRtswIWseFghbuxAlhujMa1ZRsvz87h8uzc8TovXEKM0x2UTG0u9CN2
@ping13
ping13 / license.txt
Created July 9, 2015 09:56
License file for Swisstopo's Swissnames 3D dataset, http://data.geo.admin.ch/ch.swisstopo.swissnames3d/
Lizenz für die kostenlosen Geodaten des Bundesamtes für Landestopografie swisstopo
1. Grundsatz
Der vorliegende öffentlich-rechtliche Vertrag im Sinne von Artikel 12 Absatz 1 Buchstabe b des Bundesgesetzes über Geoinformation vom 5. Oktober 2007 (GeoIG) regelt an Stelle einer Verfügung den Zugang zu und die Nutzung von Geobasisdaten des Bundesrechts.
Durch den Vertragsabschluss anerkennt der Lizenznehmer sämtliche Vertragsbestimmungen – insbesondere den Umfang der Lizenz und die vertraglichen Verpflichtungen – sowie das Geoinformationsrecht der Schweiz.
Der Lizenznehmer anerkennt mit dem Vertragsabschluss weiter das ausschliessliche Recht des Lizenzgebers, über den Zugang zu und die Nutzung der Geobasisdaten des Bundesrechts zu bestimmen. Er nimmt zur Kenntnis, das Geobasisdaten urheberrechtlich geschützt sein können und anerkennt das ausschliessliche urheberrechtliche Verwertungsrecht des Lizenzgebers an den Daten.
2. Lizenztyp
Mit dem vorliegenden Vertrag wird die folgende Lizenz eingeräumt:
Lizenz für ko
@ping13
ping13 / check_services.py
Last active December 7, 2015 14:53
short script to check compliance of WFS,WMS,WMTS,CSW services with eCH-0056
# short script to check compliance with eCH-0056
# http://www.ech.ch/vechweb/page?p=dossier&documentNumber=eCH-0056&documentVersion=1.00
# module ows_checker: https://github.com/gjn/mf-chsdi/tree/master/ows_checker
import ows_checker
esri_services = {
"CSW" : "http://gptogc.esri.com/geoportal/csw",
"WMS" : "http://example.com/arcgis/services/Beispiel/Infrastruktur/MapServer/WMSServer",
"WFS" : "http://example.com/arcgis/services/Beispiel/Infrastruktur/MapServer/WFSServer",
@ping13
ping13 / example_rest_calls.py
Last active February 23, 2017 10:15
Example REST calls with python aund urllib
import urllib
import urllib2
import json
# GET
params = urllib.urlencode({'hi':'andre', 'foo': 'bar'})
response = urllib2.urlopen('http://httpbin.org/get?' + params)
result = json.loads(response.read())
print json.dumps(result, indent=2)
@ping13
ping13 / map.geojson
Last active December 11, 2019 13:10
GeoHash Codes for Bern
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.