Skip to content

Instantly share code, notes, and snippets.

Avatar
🤗

Daniel J. H. daniel-j-h

🤗
View GitHub Profile
@daniel-j-h
daniel-j-h / Map.kt
Last active Jun 18, 2022
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
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
daniel-j-h / input-gdalinfo.txt
Created Sep 3, 2020
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 =
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["unnamed",6378137,298.25722356049,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
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
daniel-j-h / crdts.py
Created Mar 19, 2019
Conflict-free replicated data type (CRDT) counters - strong eventual consistency in a distributed system https://en.wikipedia.org/wiki/Conflict-free_replicated_data_type
View crdts.py
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 Jul 10, 2018
Test-time augmentation utility helper for https://github.com/mapbox/robosat
View tta.py
#!/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 Feb 3, 2022
Tiles GeoTIFF for zoom level
View tiler.py
#!/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
daniel-j-h / build_tf_1_4_0.sh
Created Jan 5, 2018
Builds architecture optimized TensorFlow from source, for https://news.ycombinator.com/item?id=16071001
View build_tf_1_4_0.sh
#!/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.
@daniel-j-h
daniel-j-h / bk.cc
Last active May 1, 2017
BK-Tree for nearest neighbor queries in metric spaces
View bk.cc
#include <climits>
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
@daniel-j-h
daniel-j-h / app.py
Created Mar 5, 2017
q-gram inverted lists index for fuzzy autocompletion - works surprisingly well already
View app.py
#!/usr/bin/env python3
import sys
import argparse
import collections
import curses
import curses.textpad
#python3 -m venv --system-site-packages venv