Skip to content

Instantly share code, notes, and snippets.

Avatar
🐍
geopythonining

Jess Robertson jesserobertson

🐍
geopythonining
View GitHub Profile
@jesserobertson
jesserobertson / aggregate_pdfs.ps1
Last active Jan 23, 2020
Copy all PDFs recursively from a parent folder to the current folder in Powershell
View aggregate_pdfs.ps1
# $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 Mar 26, 2019
Nice downloads in Python for largish files
View download_with_progress.py
""" 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 Mar 13, 2019
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
View optimist.csv
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 / data_explorer_validation_intro.ipynb
Last active Jun 12, 2020
Introduction notebook for competition
View data_explorer_validation_intro.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jesserobertson
jesserobertson / grd_to_tif.py
Last active Feb 22, 2019
Convert all Geosoft *.grd files to geotiff in a directory (recursively)
View grd_to_tif.py
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 / mase.py
Last active Feb 11, 2019
MASE scoring metric for Unearthed's Glencore Turn Up The Zinc Competition (https://unearthed.solutions/u/competitions/turn-zinc)
View mase.py
""" 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 Dec 19, 2018 — forked from dgoguerra/homebrew-dynamodb-local.md
Install dynamodb-local through Homebrew (custom formula)
View homebrew-dynamodb-local.md

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 Nov 21, 2018 — forked from dumbledore/mount-bitlocker
Mount/umount wrapper for dislocker on MacOS
View mount-bitlocker
#!/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}" ]
@jesserobertson
jesserobertson / wcs.py
Created Oct 4, 2018
mucking around with wcs requests
View wcs.py
import requests
from lxml import etree
def hit(url, params):
"Hit a URL, parse the xml"
response = requests.get(url, params=params)
print(response.url)
if response.ok:
print(response.headers)
return etree.fromstring(response.content)
@jesserobertson
jesserobertson / main.tf
Created Aug 30, 2018
Rendering template file
View main.tf
data "template_file" "batch_policy_template" {
template = "${file("${path.module}/batch_ecs_instance_policy.json.tpl")}"
vars = {
bucket_name = "${module.email_storage.name}"
}
}
resource "aws_iam_role_policy" "test_policy" {
name = "test_policy"
role = "${aws_iam_role.aws_batch_service_role.id}"
policy = "${data.template_file.batch_policy_template.rendered}"
You can’t perform that action at this time.