Skip to content

Instantly share code, notes, and snippets.

"""Broken-but-maybe-informative version of code from
http://stackoverflow.com/questions/13124235/python-process-communications-via-pipes-race-condition#13124235
"""
import os
import string
def safe_write(*args, **kwargs):
while True:
try:
@dbr
dbr / AE-CMakeLists.txt
Created October 16, 2012 06:05
OCIO AE CMakeLists.txt stuff
# src/aftereffects/CMakeLists.txt
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -undefined dynamic_lookup")
endif()
#set(AE_SDK "${CMAKE_SOURCE_DIR}/ext/Adobe After Effects CS5 SDK")
set(AE_SDK "${CMAKE_SOURCE_DIR}/ext/aesdk")
message("Exteranl thing: ${EXTERNAL_INCLUDE_DIRS}")
@dbr
dbr / rps.py
Created October 14, 2012 10:40
Over-engineered Rock Paper Scissors game
#!/usr/bin/env python2.6
class RPSObject(object):
def __init__(self, name):
self.name = name
self.beats = []
self.loses_to = []
def against(self, opponent):
if opponent in self.loses_to:
@dbr
dbr / bil_parse.py
Created August 14, 2012 17:34
"Band interleaved by line" (BIL) parser
"""BIL parser to load elevation info from sites like
http://earthexplorer.usgs.gov/
Mostly based of:
http://stevendkay.wordpress.com/2010/05/29/parsing-usgs-bil-digital-elevation-models-in-python/
Documentation for the format itself:
http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=BIL,_BIP,_and_BSQ_raster_files
Documentation for the accompanying world files:
@dbr
dbr / utm_to_latlng.py
Created August 14, 2012 17:28
Universal Transverse Mercator coordinate system to lat long coordinates
import math
def utmToLatLng(zone, easting, northing, northernHemisphere=True):
"""Universal Transverse Mercator coordinate system to lat long coordinates
http://stackoverflow.com/a/344083/745
"""
if not northernHemisphere:
northing = 10000000 - northing
@dbr
dbr / livemap.py
Created August 9, 2012 14:24
Live Google Map marker update with Tornado
"""Playing with tornado.websocket, to add markers to a Google Map using WebSockets
$ pip install tornado
$ python livemap.py --port=8888
Open http://localhost:8888 in one window
Each time http://localhost:8888/ping is opened in a second window, a
new marker is added to the map (at a random location)
@dbr
dbr / gist:2925018
Created June 13, 2012 16:10
strava_multisegment.py output
# Output from https://github.com/dbr/stravathings/blob/c5d36c91be40b9dbeed44d6649a3535ad0a524ac/strava_multisegment.py
$ python strava_multisegment.py | tail -8
S Eastern Fwy Climb (11 times)
01:42, 02:33, 02:04, 02:03, 02:09, 01:51, 01:57, 02:10, 01:30, 01:45, 01:54
toll gate to bollards . start point bike sign at toll gate to the bollards Finnish point in 1meter up from bollards (11 times)
32:10, 43:03, 34:19, 34:20, 35:28, 33:37, 32:39, 37:34, 28:23, 32:13, 35:07
Under the Bridge To Bollards (11 times)
20:25, 27:45, 21:47, 22:18, 22:40, 20:49, 20:36, 23:54, 18:01, 19:45, 21:37
Tollgate to Dogs (12 times)
4. John Van Seters (253%)
The Basin, VIC, Australia
17. Guido G. (196%)
Perth, WA, Australia
21. Jason E. (188%)
Sydney, NSW, Australia
25. Ernie Pekar (175%)
Sydney, NSW, Australia
38. Roger Hawley (157%)
Jindalee, QLD, Australia
@dbr
dbr / iridas_look_to_csp.py
Created March 30, 2012 05:18
IRIDAS .look to .csp LUT
"""From the seemingly undocumented IRIDAS .look format to .csp
"""
import re
import os
import sys
import struct
import binascii
import xml.etree.ElementTree as ET
@dbr
dbr / gist:2184070
Created March 24, 2012 15:09
A chunk of Photoshop CS6's included LUTs
$ head -20 NightFromDay.CUBE
#Created by: Adobe Photoshop CS6
#Copyright: Copyright 2012 Adobe Systems Inc.
TITLE "Night from Day"
#LUT size
LUT_3D_SIZE 17
#data domain
DOMAIN_MIN 0.0 0.0 0.0