Skip to content

Instantly share code, notes, and snippets.

@dbr
dbr / strava_challenge_lister.py
Created May 27, 2013 12:53
Strava challenge lister
import urllib
import logging
from BeautifulSoup import BeautifulSoup as BS
log = logging.getLogger(__name__)
class NoSuchChallenge(Exception):
pass
@dbr
dbr / nuke_duplicate_node.py
Created April 17, 2013 00:38
Duplicate a Nuke node
import nuke
def duplicate_node(node, to_file = None):
"""Slightly convoluted but reliable(?) way duplicate a node, using
the same functionality as the regular copy and paste.
Could almost be done tidily by doing:
for knobname in src_node.knobs():
from PySide import QtGui, QtCore
def findDagWidget():
stack = QtGui.QApplication.topLevelWidgets()
while stack:
widget = stack.pop()
if widget.windowTitle() == 'Node Graph':
# You should probably be a little safer with this return, but the actual DAG widget
# seems to be here consistently... if not, it should be the only child of 'widget'
set cut_paste_input [stack 0]
version 6.3 v5
push $cut_paste_input
Dot {
name Dot1
label "CineStyle image,\nwith 'raw' checkbox enabled"
selected true
xpos 295
ypos -218
}
"""Exports a Nuke ColorLookup node as a 1D CSP
The "master" curve becomes the prelut curve, and the red/green/blue curves
are the R/G/B curves
All curves are linearly sampled between 0 and 1
"""
import nuke
"""Inspired by https://github.com/timbowman/blackbody
..this creates a Nuke ColorLookup node, which maps from Kelvin to xyY values,
using code from https://github.com/dbr/colourstuff
"""
def cie1931_standard_observer_rawdata(two_degree = False, ten_degree = False):
"""Returns dictionary with three keys: x, y and z. Each key contains
a dictionary mapping wavelength to value
Created using the from_txt_to_python function
@dbr
dbr / graphite_pingtime.py
Created December 29, 2012 03:22
Script to ping a bunch of hosts, and send the resolve/ping time to Graphite
#!/usr/bin/python
import time
import subprocess
import socket
class CannotResolve(Exception):
pass
@dbr
dbr / coc_calcuation.py
Last active December 10, 2015 05:28
Camera near and far limit formula
from math import sqrt
# Camera parameters
focal = 25 #mm
fstop = 2.8 # f number
focus_distance = 5 # Unsure of unit? Probably mm, maybe metre?
# Circle of confusion diameter limit, as per
# http://en.wikipedia.org/wiki/Zeiss_formula (with modern 1500 constant)
filmback_width = 35
@dbr
dbr / gist:4250269
Created December 10, 2012 12:24
List of all Strava challenges as of 2012-12-10
http://app.strava.com/challenges/1 (Rapha Festive 500)
http://app.strava.com/challenges/2 (Strava Ride Base Mile Blast)
http://app.strava.com/challenges/3 (Strava Run Base Mile Blast)
http://app.strava.com/challenges/4 (Ride Hard to Breathe Easy)
http://app.strava.com/challenges/5 (A Classic Challenge from Specialized)
http://app.strava.com/challenges/6 (24 Hours of the Old Pueblo - Gasline)
http://app.strava.com/challenges/7 (24 Hours of the Old Pueblo- Grind)
http://app.strava.com/challenges/8 (24 Hours of the Old Pueblo - Traditional Lap)
http://app.strava.com/challenges/9 (24 Hours of the Old Pueblo - Bypass Lap)
http://app.strava.com/challenges/10 (GU 100,000 Mile Challenge)
@dbr
dbr / locale_test.c
Created November 19, 2012 10:57
Impact of locale on sscanf
/*
$ gcc locale_test.c
$ ./a.out
Got floats: 0.10 0.20 0.30
$ LANG="de_DE" ./a.out
Got floats: 0,00 0,00 0,00
*/
#include <stdio.h>
#include <locale.h>