Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Hutcheson whutch

View GitHub Profile
View .pythonrc
# vim: set ft=python :
from __future__ import print_function
import json
import sys
import datetime
from redis import StrictRedis as Redis
View genmap.py
"""Create a map and render it as a pgm image.
(see http://netpbm.sourceforge.net/doc/pgm.html)
"""
import sys
import math
import json
from functools import lru_cache
from noise import snoise2
@aleksandarristic
aleksandarristic / cached_property_descriptor.py
Created Sep 6, 2013
A CachedProperty descriptor; It receives an expensive getter function (& optional arguments for it). The __get__ runs the getter function with the object instance as the first argument (& optional arguments provided in __init__) and caches the result. The __set__ just changes the cache to the 'value', __delete__ removes the cache.
View cached_property_descriptor.py
class CachedProperty(object):
"""
A cached property; A bit specific, as
it runs the getter as an instance method
& forwards the instance & init args to it.
Uses python descriptors protocol
"""
def __init__(self, getter, *args):
self.getter = getter
self.args = args or None
@chanux
chanux / fixsrt.py
Created Mar 15, 2012
A simple python tool to fix time of srt files
View fixsrt.py
#!/usr/bin/env python
from sys import argv, exit
from os import path
import datetime
if len(argv) == 5:
(script, inputf, outputf, sign, msec) = argv
else:
print "fixsrt <input.srt> <output.srt> <+/-> <milli seconds>"
exit(1)
You can’t perform that action at this time.