Skip to content

Instantly share code, notes, and snippets.


Daniel J. H. daniel-j-h

View GitHub Profile
daniel-j-h /
Created February 21, 2023 21:36
LUCAS 2018 dataset as a GeoJSON file for simple and easy visualization -
#!/usr/bin/env python3
import sys
import csv
import json
import argparse
from pathlib import Path
def main(args):
daniel-j-h /
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 / Map.kt
Last active May 26, 2023 03:35
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 you will find an example for a Google Map
View Map.kt
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 / input-gdalinfo.txt
Created September 3, 2020 11:26
rasterio `rio convert` ground control point issue
View input-gdalinfo.txt
Driver: GTiff/GeoTIFF
Files: grd-vv-native.tif
Size is 26569, 16673
GCP Projection =
DATUM["World Geodetic System 1984",
View Dockerfile
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 /
Created March 19, 2019 23:18
Conflict-free replicated data type (CRDT) counters - strong eventual consistency in a distributed system
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 /
Last active July 10, 2018 12:34
Test-time augmentation utility helper for
#!/usr/bin/env python3
pip install tqdm pillow mercantile
Simple image rotation script for test-time augmentation.
daniel-j-h /
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
View initial-turn-restrictions.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
daniel-j-h /
Created January 5, 2018 22:04
Builds architecture optimized TensorFlow from source, for
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# Usage: ./ broadwell /tmp/wheel
# Builds TensorFlow 1.4.0 from source for a specific architecture.
# Assumes Ubuntu 16.04, installs dependencies and the bazel buildsystem.