Skip to content

Instantly share code, notes, and snippets.

View soxofaan's full-sized avatar

Stefaan Lippens soxofaan

View GitHub Profile
@soxofaan
soxofaan / Issue107-graph-merging.ipynb
Created February 10, 2020 11:17
openeo python client issue #107 example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / openeo-mask-example.ipynb
Last active March 27, 2020 08:08
openeo-mask-example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / ensure_pyspark_executor_logging.py
Created April 7, 2020 08:54
Decorator based trick to enable Python logging from PySpark executors
import functools
import logging
import pyspark
from typing import Callable
LOG_FORMAT = "[P%(process)s/%(name)s] %(levelname)s: %(message)s"
def ensure_executor_logging(
f=None, *,
@soxofaan
soxofaan / ignore_order.py
Last active November 3, 2020 11:10
Order ignoring list/tuple comparison asserts for pytest
from typing import Union
class IgnoreOrder:
"""
pytest helper to test equality of lists/tuples ignoring item order
E.g., these asserts pass:
>>> assert [1, 2, 3, 3] == IgnoreOrder([3, 1, 2, 3])
>>> assert {"foo": [1, 2, 3]} == {"foo": IgnoreOrder([3, 2, 1])}
@soxofaan
soxofaan / dict_item.py
Created October 28, 2020 11:50
Python descriptor for attribute-like access in dict subclasses
class dict_item:
"""
Create an attribute in a custom dict subclass that accesses
the dict value keyed by the attribute's name:
>>> class UserInfo(dict):
>>> name = dict_item()
>>> age = dict_item()
>>> user = UserInfo(name="John")
>>> print(user.name)
@soxofaan
soxofaan / README.md
Last active February 15, 2021 11:06
Poor man's jq

jq is a command line tool to process JSON documents with loads of features.

If you just want quick (re-)indentation, use one of these Python powered poor man's alternatives:

python -c "import json,sys;json.dump(json.load(sys.stdin),sys.stdout,indent=2)" < data.json

python -c "import json,sys,pprint;pprint.pprint(json.load(sys.stdin))" < data.json
@soxofaan
soxofaan / sdiff.txt
Created February 3, 2022 15:30
EP-4150 default vs stitched
$ sdiff -t tile0000-remake.tiff.txt tile0000-remake-stitch.tiff.txt
Driver: GTiff/GeoTIFF Driver: GTiff/GeoTIFF
Files: tile0000-remake.tiff | Files: tile0000-remake-stitch.tiff
Size is 1827, 1024 | Size is 1827, 880
Coordinate System is: Coordinate System is:
PROJCRS["WGS 84 / UTM zone 31N", PROJCRS["WGS 84 / UTM zone 31N",
BASEGEOGCRS["WGS 84", BASEGEOGCRS["WGS 84",
DATUM["World Geodetic System 1984", DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563, ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]], LENGTHUNIT["metre",1]]],
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@soxofaan
soxofaan / README.md
Last active June 2, 2022 12:03
Flask view decorator for injecting Cache-Control headers

POC decorator for flask fiew functions to inject Cache-Control headers in a response.

Instructions to run example

Set up env, for example:

python -m venv venv
. venv/bin/activate

pip install flask

@soxofaan
soxofaan / example03.ipynb
Created September 1, 2022 10:14
openEO Platform forum 412 example 3
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.