This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import warnings | |
from functools import wraps | |
def ignore_warnings(f): | |
@wraps(f) | |
def inner(*args, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CLEAR='\033[0m' | |
RED='\033[0;31m' | |
function usage() { | |
if [ -n "$1" ]; then | |
echo -e "${RED}👉 $1${CLEAR}\n"; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from pathlib import Path | |
import pandas as pd | |
import geopandas as gpd | |
def stratified_sample(df: pd.DataFrame, groupby_column: str, sampling_rate: float = 0.01) -> pd.DataFrame: | |
assert 0.0 < sampling_rate <= 1.0 | |
assert groupby_column in df.columns | |
num_rows = int((df.shape[0] * sampling_rate) // 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from pathlib import Path | |
import sys | |
import warnings | |
smk = snakemake # type: ignore | |
logging.basicConfig(filename=Path(str(smk.log)), level=smk.params.get('logLevel', logging.INFO)) | |
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout)) # Log to stdout as well |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import pyproj | |
import h3.api.basic_int as h3 | |
# A window_transformation is the affine transformation of a window, see https://rasterio.readthedocs.io/en/latest/topics/windowed-rw.html?highlight=window_transform#window-transforms | |
# Transformer | |
transformer = lambda s_srs, t_srs: pyproj.Transformer.from_proj(pyproj.Proj(s_srs), pyproj.Proj(t_srs), always_xy=True) | |
# Row/column conversion to lon, lat; given a window transformation and pyproj.Transformer | |
rc2lonlat = lambda r, c, window_transformation, transformer: transformer.transform(*(window_transformation * (c, r))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update wallpaper every 15 minutes | |
15 * * * * /bin/bash /home/richard/scripts/set-wallpaper.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cartopy | |
import shapely.geometry as sgeom | |
class NZTM(cartopy.crs.TransverseMercator): | |
def __init__(self): | |
''' | |
https://epsg.io/2193 | |
https://www.linz.govt.nz/data/geodetic-system/datums-projections-and-heights/geodetic-datums/new-zealand-geodetic-datum-2000-nzgd2000 | |
''' | |
inverse_flattening = 298.257222101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const replacerWrapper = val => val.replace(/\"\[/g, '[').replace(/\]\"/g,']') | |
const replacer = (name, val) => { | |
console.log({name, val}) | |
if (name === 'coordinates' && Array.isArray(val)) { | |
val = JSON.stringify(val) | |
} | |
return val | |
} | |
module.exports = { | |
replacer, replacerWrapper, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . | |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
@prefix foaf: <http://xmlns.com/foaf/0.1/> . | |
@prefix rel: <http://vocab.org/relationship/> . | |
@prefix wikipedia: <http://en.wikipedia.org/wiki/> . | |
@prefix dc: <http://purl.org/dc/elements/1.1/> . | |
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> . | |
@prefix bio: <http://vocab.org/relationship/> . | |
<me> a foaf:PersonalProfileDocument ; |
NewerOlder