Skip to content

Instantly share code, notes, and snippets.

Jesse Crocker JesseCrocker

View GitHub Profile
@JesseCrocker
JesseCrocker / gen_tm2source_yaml.py
Created Aug 22, 2014
Generate a .tm2source from a Postgres database. This is definitely alpha software that I will be improving as needed. You will need to edit the code to configure some things. The source this generates will almost certainly need significant editing, but if you've got 100+ tables, this is a much quicker way to get started than manually creating ea…
View gen_tm2source_yaml.py
#!/usr/bin/env python
from __future__ import print_function
import psycopg2
import bs4
import requests
import sys
from yaml import load, dump
@JesseCrocker
JesseCrocker / open_simulator.py
Created Sep 24, 2014
Show a menu to open the directory containing an iOS simulator app
View open_simulator.py
#!/usr/bin/env python
import sys
import plistlib
import re
import os
import subprocess
def simulator_name(arg):
match = re.match("[\w\-\/]+/CoreSimulator/Devices/[0-9A-F\-]+/", arg)
device_dir = match.group()
@JesseCrocker
JesseCrocker / MaplyQuadImageTilesLayerDebug.h
Created Nov 24, 2014
Debuging tile layer for WhirlyGlobe that overlays tile addresses and outlines on image tiles. Simply use MaplyQuadImageTilesLayerDebug instead of MaplyQuadImageTilesLayer
View MaplyQuadImageTilesLayerDebug.h
//
// MaplyQuadImageTilesLayerDebug.h
// TrailTracker
//
// Created by Jesse Crocker on 7/29/14.
//
//
#import "MaplyQuadImageTilesLayer.h"
/// A drop in replacement for MaplyQuadImageTilesLayer that outlines tiles, and overlays tile addresses
@JesseCrocker
JesseCrocker / tests.py
Last active Aug 29, 2015
Django testcase for finding missing includes and static files in your project
View tests.py
"""
The MIT License (MIT)
Copyright (c) 2014 Trailbehind inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@JesseCrocker
JesseCrocker / gist:53f2a711a2d4dc623c74
Last active Aug 29, 2015
Regular expression for s3 log format
View gist:53f2a711a2d4dc623c74
^([a-f0-9]+) ([a-zA-Z0-9\-\.]+) \[([^\]]+)\] (\d+\.\d+\.\d+\.\d+) (-|[\w:/]+) (\w+) ([A-Z\._]+) ([^ ]+) "?([^"]+)"? (\d+) (-|\w+) (-|\d+) (-|\d+) (-|\d+) (-|\d+) "?([^"]+)"? "?([^"]+)"? (-|\w+)$
View composite-watch-screenshot.sh
#!/bin/bash
USAGE="Usage: $0 frame-image.png watchScreenshot1.png watchScreenshot1.png ..."
if [ "$#" == "0" ]; then
echo "$USAGE"
exit 1
fi
frame=$1
shift
@JesseCrocker
JesseCrocker / gpx2csv.py
Created Mar 27, 2015
Covert a gpx file to a csv.
View gpx2csv.py
#!/usr/bin/env python
import csv
import gpxpy
import gpxpy.gpx
import logging
from optparse import OptionParser
import os
import sys
import srtm
@JesseCrocker
JesseCrocker / TBMemoryStealer.h
Created Mar 30, 2015
Allocate Memory in Objective-C to simulate out of memory conditions
View TBMemoryStealer.h
//
// TBMemoryStealer.h
// TrailTracker
//
// Created by Jesse Crocker on 3/30/15.
//
//
#import <Foundation/Foundation.h>
@JesseCrocker
JesseCrocker / gist:c099b846116aca082c5d
Last active Aug 29, 2015
gdal2tiles resampling speed
View gist:c099b846116aca082c5d
$ for i in average near bilinear cubic cubicspline lanczos antialias;do echo $i; time gdal2tiles.py -r $i PR_Corozal_20130920_TM_geo.pdf.tif tiles.$i; done
average
gdal2tiles.py -r $i PR_Corozal_20130920_TM_geo.pdf.tif tiles.$i 129.10s user 3.27s system 98% cpu 2:14.95 total
near
gdal2tiles.py -r $i PR_Corozal_20130920_TM_geo.pdf.tif tiles.$i 55.01s user 2.64s system 97% cpu 59.276 total
bilinear
gdal2tiles.py -r $i PR_Corozal_20130920_TM_geo.pdf.tif tiles.$i 99.11s user 4.06s system 97% cpu 1:45.64 total
@JesseCrocker
JesseCrocker / prepare_watch_icon.sh
Created May 6, 2015
Generate WatchKit app icons from a 1024px icon
View prepare_watch_icon.sh
for size in 24 27.5 29 40 44 86 98; do pixel_size=`echo $size \* 2 | bc`; convert -resize $pixel_size 1024-square.png icon-$size@2x.png; done
convert -resize $(expr 29 \* 3) 1024-square.png icon-29@3x.png
for i in icon-*.png ; do convert "$i" -background black -alpha remove -alpha off "${i}" ; done
/Applications/ImageOptim.app/Contents/MacOS/ImageOptim icon-*.png
You can’t perform that action at this time.