Skip to content

Instantly share code, notes, and snippets.

Jesse Crocker JesseCrocker

View GitHub Profile
@JesseCrocker
JesseCrocker / collage.py
Last active Apr 14, 2019
Create a collage of images, filling all space without cropping. Implements algorithm presented in https://www.crispymtn.com/stories/the-algorithm-for-a-perfectly-balanced-photo-gallery
View collage.py
#!/usr/bin/env python
from operator import itemgetter
from optparse import OptionParser
import logging
from PIL import Image
from math import ceil, floor
import sys
"""
@JesseCrocker
JesseCrocker / playback-gpx.py
Last active Mar 24, 2019
Use a GPX file to simulate locations in the Genymotion Android emulator. Requires gpxpy. `pip install gpxpy`
View playback-gpx.py
#!/usr/bin/env python
import sys
import logging
from optparse import OptionParser
import os
import gpxpy
import gpxpy.gpx
import time
from subprocess import check_output
import math
@JesseCrocker
JesseCrocker / build-gdal-combined-lib.sh
Last active Feb 20, 2019
Scripts for building Gdal into a static library for iOS, build-gdal-combined-lib.sh will build a single lib with armv7 armv7s arm64 and simulator slices
View build-gdal-combined-lib.sh
#!/bin/bash
PREFIX=`pwd`/install/
rm -rf $PREFIX
mkdir $PREFIX
LOG=./log
rm -rf $LOG
mkdir $LOG
if [ -e ${PREFIX} ]
then
@JesseCrocker
JesseCrocker / convert-geopdf.py
Last active Sep 1, 2018
A quick script for converting US Topo geoPDF maps to tiff. Based on code from Even Rouault at http://lists.osgeo.org/pipermail/gdal-dev/2013-January/035269.html
View convert-geopdf.py
#!/usr/bin/env python
#based on http://lists.osgeo.org/pipermail/gdal-dev/2013-January/035269.html
from osgeo import gdal, osr
import os
import sys
from optparse import OptionParser
import tempfile
from shapely import wkt
from shapely.geometry import mapping
from fiona import collection, crs
@JesseCrocker
JesseCrocker / aws.conf
Created Feb 15, 2016
How to install AWS CloudWatch Logs Agent to send logs from a docker container to AWS Cloudwatch, without using a linked container for logging.
View aws.conf
[plugins]
cwlogs = cwlogs
[default]
region = ap-southeast-2
@JesseCrocker
JesseCrocker / function.js
Created Apr 29, 2016
AWS lambda function for posting cloudwatch alarms to slack
View function.js
var AWS = require('aws-sdk');
var url = require('url');
var https = require('https');
var hookUrl, kmsEncyptedHookUrl, slackChannel;
kmsEncyptedHookUrl = ''; // Enter the base-64 encoded, encrypted key (CiphertextBlob)
slackChannel = '#alerts'; // Enter the Slack channel to send a message to
@JesseCrocker
JesseCrocker / bil-to-hgt.sh
Created Jul 28, 2015
Convert a directory of .bil files to .hgt
View bil-to-hgt.sh
#!/bin/bash
function gdal_pixel_count() {
if [ -z "$1" ]; then
echo "Missing arguments. Syntax:"
echo " gdal_extent <input_raster>"
return
fi
EXTENT=$(gdalinfo $1 |\
grep "Size is" |\
sed "s/Size is //g;s/,//;s/\n//")
@JesseCrocker
JesseCrocker / README.md
Last active May 21, 2018
Simple ECS service deploy script
View README.md

Deploy updates to aws ecs services based on github commits. Posts deploy notifications to slack.

Assumptions:

  • Task definitions map 1:1 with services, and they have the same name.
  • Code is stored on github
  • You want to deploy the latest commit in a branch
  • Docker images are tagged with commit SHA
  • Docker images are stored on AWS ECR
@JesseCrocker
JesseCrocker / cleanup.js
Created May 3, 2018
Aws lambda function that allows a user to hit a url and get added to an aws security group, and another function to cleanup old entries in the group
View cleanup.js
"use strict";
var AWS = require("aws-sdk");
var ec2 = new AWS.EC2();
var securityGroup = "sg-XXX";
exports.handler = (event, context, callback) => {
ec2.describeSecurityGroups({ GroupIds: [securityGroup] }, function(
err,
data
@JesseCrocker
JesseCrocker / publish_queue_size.py
Created Apr 8, 2016
Publish rabbitMQ queue depths as AWS cloudwatch metrics
View publish_queue_size.py
#!/usr/bin/env python
from __future__ import with_statement, print_function
from pyrabbit.api import Client
from boto.ec2.cloudwatch import CloudWatchConnection
import os
from time import sleep
def get_queue_depths(host, username, password, vhost):
cl = Client(host, username, password)
You can’t perform that action at this time.