Skip to content

Instantly share code, notes, and snippets.

View procrastinatio's full-sized avatar
💭
Post Tenebras Spero Lucem

Marc Mönneråt procrastinatio

💭
Post Tenebras Spero Lucem
View GitHub Profile
@procrastinatio
procrastinatio / index.html
Last active October 10, 2015 18:27
Most simple GeoAdmin possible example
<body onload="init();">
<div id="map"></div>
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js"></script>
<script type="text/javascript" src="simple.js"></script>
<link href="simple.css" />
</body>
@procrastinatio
procrastinatio / 0_reuse_code.js
Created October 25, 2013 08:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@procrastinatio
procrastinatio / gist:d9dc3431a2cc9dd92b96
Last active August 29, 2015 14:15
PyProj and NTv2 grid
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import os
import pyproj
DEBUG= False
@procrastinatio
procrastinatio / grid.py
Created May 11, 2016 10:03
Using Mapproxy for Grid operation
>>> from mapproxy.srs import SRS
>>> from mapproxy.grid import TileGrid, tile_grid
# Grid creation
>>> grid = TileGrid(SRS(21781),
... bbox=(20000,30000,900000,350000), origin='ul',
... res=[4000,3750,3500,3250,3000,2750,2500,2250,2000,1750,1500,1250,1000,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,0.5,0.25,0.1])
# Grid origin
>>> grid.origin
@procrastinatio
procrastinatio / test_wms.py
Created March 24, 2017 15:27
Testing Geneva's WMS services
#!/usr/bin/env python
import owslib
from owslib.wms import WebMapService
import requests
import lxml
urls= ['https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_01/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_02/MapServer/WMSServer',
'https://ge.ch/sitgags1/services/VECTOR/SITG_OPENDATA_03/MapServer/WMSServer',
@procrastinatio
procrastinatio / super_invalidation.sh
Created October 17, 2017 14:48
Script for tiles invalidations
#!/bin/bash
##### ch.swisstopo.pixelkarte-farbe-pk25.noscale - pk25_krel_20171012.geojson - 1000 0.1 #######
.venv/bin/python scripts/invalidate.py --profile ltmom_aws_admin --force --bucket bgdi-tod-cache-prod --layer ch.swisstopo.pixelkarte-farbe-pk25.noscale --timestamp current --extent 2812500.00074 1170000.00106 2830000.00075 1182000.00107 --resolutions 1000 0.1 --epsgs 21781 4326 2056 3857
.venv/bin/python scripts/invalidate.py --profile ltmom_aws_admin --force --bucket bgdi-tod-cache-prod --layer ch.swisstopo.pixelkarte-farbe-pk25.noscale --timestamp current --extent 2812500.00074 1158000.00106 2830000.00076 1170000.00107 --resolutions 1000 0.1 --epsgs 21781 4326 2056 3857
.venv/bin/python scripts/invalidate.py --profile ltmom_aws_admin --force --bucket bgdi-tod-cache-prod --layer ch.swisstopo.pixelkarte-farbe-pk25.noscale --timestamp current --extent 2777500.00072 1134000.00106 2795000.00074 1146000.00107 --resolutions 1000 0.1 --epsgs 21781 4326 2056 3857
.venv/bin/python scripts/inval
@procrastinatio
procrastinatio / haproxy_rate_limiting.md
Created October 25, 2017 06:04
Rate limiting with HAproxy

Introduction

So HAProxy is primalery a load balancer an proxy for TCP and HTTP. But it may act as a traffic regulator. It may also be used as a protection against DDoS and service abuse, by maintening a wide variety of statistics (IP, URL, cookie) and when abuse is happening, action as denying, redirecting to other backend may undertaken ([haproxy ddos config], [haproxy ddos])

@procrastinatio
procrastinatio / get_gwr_from_parcel.py
Last active February 20, 2020 17:46
Get all GWR addresses on a given parcel using api3.geo.admin.ch services
#!/usr/bin/env python
# Get all GWR (ch.bfs.gebaeude_wohnungs_register) on a given parcel (ch.kantone.cadastralwebmap-farbe)
import sys
import re
import requests
import json
import logging
@procrastinatio
procrastinatio / geodesy_format.py
Created November 19, 2020 08:56
Format for LTOP-EL
#!/usr/bin/python3
import sys
import csv
import random
import string
from datetime import datetime