Skip to content

Instantly share code, notes, and snippets.

@kdeloach
kdeloach / run.py
Created May 20, 2016 18:21
Run GWLF-E model from sparse dict
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import sys
import json
import logging
@kdeloach
kdeloach / hotfix1.12.1.md
Last active May 4, 2016 13:37
MMW hotfix 1.12.1

Steps we did to deploy the hotfix:

  • Branch off of master (hotfix/1.12.1)
  • Update and test code changes locally
  • Manually apply code changes to both app servers in production and restart gunicorn
  • Verify code changes in production
  • Push hotfix branch upstream
  • Build Jenkins jobs with paramaters (hotfix/1.12.1)
    • model-my-watershed-packer-app-and-worker
  • model-my-watershed-packer-tiler
@kdeloach
kdeloach / retry_backoff_test.py
Last active March 10, 2016 23:33
Find the optimal backoff ratio for retrying failed requests
from __future__ import division
# Usage:
# python retry_backoff_test.py | sort | uniq -c
def test(ratio, target):
timeout = 0.5
duration = timeout
tries = 0
@kdeloach
kdeloach / fix_elliot_quest.py
Created January 23, 2016 19:28
Elliot Quest reset to first level
import sqlite3
# Replace this with the path to your save file:
# Where are the save files located?
# https://steamcommunity.com/app/293440/discussions/0/624075374581106340/
path='C:\Users\xxx\AppData\Local\Elliot Quest\Local Storage\file__0.localstorage'
conn = sqlite3.connect(path)
c = conn.cursor()
[Test]
public void TestBindingsRead()
{
string oradb = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=LR14)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=pdborcl.internal.azavea.com)));;User Id=unittest;Password=***;";
string queryString = "SELECT SDE.ST_SRID(SHAPE) || ':' || SDE.ST_AsText(SHAPE) AS SHAPE FROM unittest.DOR_PARCEL_READ WHERE (unittest.DOR_PARCEL_READ.STATUS IN (1, 2))";
using (OracleConnection connection = new OracleConnection(oradb))
{
OracleCommand command = new OracleCommand(queryString, connection);
connection.Open();
OracleDataReader reader;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
import sys
import os.path
import subprocess
from PIL import Image, ImageOps
#!/usr/bin/env python
"""
Coalesce a single file containing multiple JS arrays (undelimited) into
one giant JS array.
Ex. "[{...}]\n[{..}]" becomes "[{...},{...}]
This assumes each JS array contains a list of JS object literals.
Usage:
@kdeloach
kdeloach / gist:3a55e69e7fe67d8da380
Created October 30, 2015 17:07
Display reprojected map bounds
map.on('moveend', function(e) {
var map = e.target;
var bounds = map.getBounds();
var topleft = bounds.getNorthWest();
var bottomright = bounds.getSouthEast();
var a = crs.project(topleft);
var b = crs.project(bottomright);
console.log({
@kdeloach
kdeloach / gist:92214a6ceff657eade09
Created October 28, 2015 18:36
vsicurl with signed url test
import boto3
from osgeo import gdal
gdal.UseExceptions()
client = boto3.client('s3')
uri = client.generate_presigned_url('get_object', {
'Bucket': 'raster-foundry-kdeloach',
'Key': '1-11cfbd00-fe9c-4dff-bcb8-695aebf756d5.tif',
})