Skip to content

Instantly share code, notes, and snippets.

View jesserobertson's full-sized avatar
🐍
geopythonining

Jess Robertson jesserobertson

🐍
geopythonining
View GitHub Profile
@jesserobertson
jesserobertson / grd_to_tif.py
Last active May 23, 2023 07:07
Convert all Geosoft *.grd files to geotiff in a directory (recursively)
import pathlib
from itertools import product
from tqdm import tqdm
import rasterio
import geosoft
import geosoft.gxpy.gx as gx
import geosoft.gxpy.coordinate_system as gxcs
import geosoft.gxpy.grid as gxgrid
@jesserobertson
jesserobertson / data_explorer_validation_intro.ipynb
Last active June 14, 2021 15:06
Introduction notebook for competition
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jesserobertson
jesserobertson / pure-python.psm1
Last active September 7, 2020 22:46
Mod of posh pure theme to include conda env information in prompt (a bit slow but ¯\_(ツ)_/¯)
#requires -Version 2 -Modules posh-git
function Get-CondaEnv {
$condaEnvInfo = (
Invoke-Conda env list
| Select-String -Pattern '^(\w+)\s+\*\s+(.*)$' # name, then prefix
)
return $condaEnvInfo.matches.groups[1]
}
@jesserobertson
jesserobertson / activate-poetry.ps1
Last active September 1, 2020 22:57
Activate the default poetry environment using Powershell
<#
.Synopsis
Activates the current poetry environment
.Description
Run inside your project folder to activate the poetry environment in PowerShell
#>
function Start-PoetryEnv {
$env_folder = $( -split $(poetry env list --full-path) | Select-Object -Index 0)
@jesserobertson
jesserobertson / aggregate_pdfs.ps1
Last active January 23, 2020 00:31
Copy all PDFs recursively from a parent folder to the current folder in Powershell
# $data_dir is some gnarly collection of folders
Get-ChildItem -Recurse $data_dir |
Where-Object { $_.Extension -eq '.pdf' } |
Copy-Item -Destination .
@jesserobertson
jesserobertson / download_with_progress.py
Created March 26, 2019 02:03
Nice downloads in Python for largish files
""" file: download.py
author: Jess Robertson (@jesserobertson)
date: Tuesday, 26 March 2019
description: Download large files with requests and a tqdm progress bar.
Modified lightly from https://stackoverflow.com/questions/37573483
"""
import pathlib
from urllib.parse import urlparse
@jesserobertson
jesserobertson / optimist.csv
Created March 13, 2019 02:58
Demo submission files for explorer data-science stream. `pessimist.csv` asserts there are no deposits anywhere in any of our stamp areas, `optimist.csv` thinks there's a gold deposit at the centre of every stamp, and `super_optimist.csv` thinks there's a Cu-Au, Fe, PGE and Pb-Zn deposit in every stamp
stamp_id x y commodity
08182206 0 0 Au
33056140 0 0 Au
82675435 0 0 Au
75118621 0 0 Au
68158945 0 0 Au
78221409 0 0 Au
57745933 0 0 Au
89020571 0 0 Au
97892894 0 0 Au
@jesserobertson
jesserobertson / mase.py
Last active February 11, 2019 05:54
MASE scoring metric for Unearthed's Glencore Turn Up The Zinc Competition (https://unearthed.solutions/u/competitions/turn-zinc)
""" file: mase.py
author: Jess Robertson, jess@unearthed.solutions
date: Thursday, 31 January 2019
description: MASE scoring for Glencore competition (https://unearthed.solutions/u/competitions/turn-zinc)
"""
import numpy as np
def _mase_numeric_only(predicted, measured):
@jesserobertson
jesserobertson / homebrew-dynamodb-local.md
Created December 19, 2018 23:22 — forked from dgoguerra/homebrew-dynamodb-local.md
Install dynamodb-local through Homebrew (custom formula)

Install dynamodb-local through Homebrew

An official formula for dynamodb-local existed, but was removed since dynamodb-local is not open source and stopped having versions.

Now its available either through a Cask, or by installing it as a formula from an unofficial tap (third party repo).

When installed as a cask dynamodb-local cannot be exposed as a service, so here we are installing it as a formula. It has been forked from rjcoelho/homebrew-boneyard and updated to be a head-only formula, to avoid checksum erros on new versions. It is available at dgoguerra/homebrew-boneyard.

# dynamodb-local depends on Java 6+
@jesserobertson
jesserobertson / mount-bitlocker
Created November 21, 2018 08:54 — forked from dumbledore/mount-bitlocker
Mount/umount wrapper for dislocker on MacOS
#!/bin/bash
BITLOCKER_PARTITION="${1}"
BITLOCKER_PASSWORD="${2}"
function usage() {
echo "$(basename ${0}) <partition> <password>"
echo "Unlocks and mounts a bitlocker partition as read-only"
}
if [ -z "${BITLOCKER_PARTITION}" ]