Skip to content

Instantly share code, notes, and snippets.

#!/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:
# -*- 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[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;
@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()
@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 / 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 / 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 / utd_test.py
Created November 21, 2016 21:41
Urban Tree Database analysis
import csv
from modeling.run_model.GrowthModelUrbanTreeDatabase import _formulas
w = csv.writer(self.stdout)
results = []
for itree_region, otm_codes in _formulas.iteritems():
for otm_code, fn in otm_codes.iteritems():
key = '{} {}'.format(itree_region, otm_code)
#!/bin/bash
# Usage:
# ./find_merged_branches.sh 2>/dev/null | tee output.txt
TMPDIR="$PWD/tmp"
while read repo; do
rm -rf $TMPDIR
url="git@github.com:$repo.git"
git clone $url $TMPDIR 1>&2