Skip to content

Instantly share code, notes, and snippets.

View daniel-j-h's full-sized avatar
🤗

Daniel J. H. daniel-j-h

🤗
  • Berlin, Germany
  • 07:21 (UTC +01:00)
View GitHub Profile
@daniel-j-h
daniel-j-h / lucas2018-to-geojson.py
Created February 21, 2023 21:36
LUCAS 2018 dataset as a GeoJSON file for simple and easy visualization - https://esdac.jrc.ec.europa.eu/content/lucas-2018-topsoil-data
#!/usr/bin/env python3
import sys
import csv
import json
import argparse
from pathlib import Path
def main(args):
@daniel-j-h
daniel-j-h / readme.md
Created November 5, 2022 17:56
Re-key your encrypted volumes

Re-key your encrypted volumes

When you encrypt volumes like your laptop's SSD or USB sticks on Linux there's a high chance you're using Linux Unified Key Setup (LUKS) in the background. To decrypt volumes, LUKS uses your secret passphrase and puts it through a function to derive the actual volume decryption key. The key derivation function is supposed to be expensive to compute so that brute-force attacks are hard to pull off.

There are three problems with the LUKS setup in practice

  1. The key derivation function gets benchmarked and tuned to your system to keep the decryption process short e.g. below a second because no one wants to wait too long
  2. Therefore, if you encrypt volumes with a weak device like a laptop, the key derivation function will we weak
  3. If you encrypted a device in the past and are still using its volume, you will not benefit from more recent key derivation function algorithms which have stronger guarantees against brute force attacks e.g. using GPUs

That's why you should re-key y

@daniel-j-h
daniel-j-h / Map.kt
Last active June 16, 2023 07:37
Adapting an imperative map (Google Map, Mapbox Map, etc.) for a declarative UI such as Android Compose; below shows an example for a Mapbox map, in https://github.com/android/compose-samples/tree/e6994123804b976083fa937d3f5bf926da4facc5/Crane#crane-sample you will find an example for a Google Map
package com.example.view
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleEventObserver
import com.mapbox.geojson.Point
@daniel-j-h
daniel-j-h / input-gdalinfo.txt
Created September 3, 2020 11:26
rasterio `rio convert` ground control point issue
Driver: GTiff/GeoTIFF
Files: grd-vv-native.tif
Size is 26569, 16673
GCP Projection =
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["unnamed",6378137,298.25722356049,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
FROM ubuntu:20.04
ENV LANG="C.UTF-8" LC_ALL="C.UTF-8" PATH="/home/python/.poetry/bin:/home/python/.local/bin:$PATH" PIP_NO_CACHE_DIR="false"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
python3 python3-pip python-is-python3 curl ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN groupadd --gid 1000 python && \
useradd --uid 1000 --gid python --shell /bin/bash --create-home python
@daniel-j-h
daniel-j-h / crdts.py
Created March 19, 2019 23:18
Conflict-free replicated data type (CRDT) counters - strong eventual consistency in a distributed system https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type
import random
class GrowCounter:
'''Convergent conflict-free replicated data type state based grow-only counter.
Guarantees strong eventual consistency.
'''
def __init__(self, n):
assert n > 0, 'at least one node in cluster'
@daniel-j-h
daniel-j-h / tta.py
Last active July 10, 2018 12:34
Test-time augmentation utility helper for https://github.com/mapbox/robosat
#!/usr/bin/env python3
'''
pip install tqdm pillow mercantile
'''
'''
Simple image rotation script for test-time augmentation.
Usage:
@daniel-j-h
daniel-j-h / tiler.py
Last active February 3, 2022 07:04
Tiles GeoTIFF for zoom level
#!/usr/bin/env python3
'''
pip install tqdm numpy pillow mercantile 'rasterio==1.0b1' 'rio-tiler==1.0a7'
'''
import os
import argparse
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@daniel-j-h
daniel-j-h / build_tf_1_4_0.sh
Created January 5, 2018 22:04
Builds architecture optimized TensorFlow from source, for https://news.ycombinator.com/item?id=16071001
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# Usage: ./build_tf_1_4_0.sh broadwell /tmp/wheel
#
# Builds TensorFlow 1.4.0 from source for a specific architecture.
# Assumes Ubuntu 16.04, installs dependencies and the bazel buildsystem.