Skip to content

Instantly share code, notes, and snippets.

View jesserobertson's full-sized avatar
🐍
geopythonining

Jess Robertson jesserobertson

🐍
geopythonining
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jesserobertson on github.
  • I am jessrobertson (https://keybase.io/jessrobertson) on keybase.
  • I have a public key ASD_4QhDJ-LfxNAGMMvnfQlBOtfqGNV4xGWGZ_w2TfOUTgo

To claim this, I am signing this object:

@jesserobertson
jesserobertson / hashicorp
Last active June 13, 2018 03:40
Installer script for hashicorp tools
#!/usr/bin/env bash
# file: hashicorp.sh
# author: Jess Robertson, CSIRO Mineral Resources
# date: March 2017
#
# description: Download and install Hashicorp products from their
# release server. Note that this assumes that Hashicorp doesn't change
# their release URLS.
#
# Requires gnupg and openssl (see `install_dependencies`)
@jesserobertson
jesserobertson / jupyter_logging.py
Created June 13, 2018 03:37
Enable logging to a Jupiter notebook by module namespace
import logging, sys
def log_to_notebook(module=None, level='INFO'):
"""
Sets up logging to stdout so we can capture it in the notebook
Parameters:
module - the module to log from. To log only certain submodules
do something like `module='placer.stream'`. If None, default is
to get the root logger which logs everything.
@jesserobertson
jesserobertson / instance_role.json.tftpl
Created August 30, 2018 04:18
ECS Instance role template for terraform
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ses:SendEmail",
"ses:SendRawEmail"
],
"Effect": "Allow",
"Resource": "*"
@jesserobertson
jesserobertson / main.tf
Created August 30, 2018 04:22
Rendering template file
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}"
@jesserobertson
jesserobertson / wcs.py
Created October 4, 2018 23:04
mucking around with wcs requests
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 / 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}" ]
@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 / 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 / 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