Skip to content

Instantly share code, notes, and snippets.


Mikko Ohtamaa miohtama

View GitHub Profile
miohtama / Plone developer tutorial.rst
Created Jul 24, 2011
How to start developing plone
View Plone developer tutorial.rst

Sauna Sprint 2011 head first group 2011-07-24

How to start developing Plone - from the scratch approach.

Use man pages, info pages and commandline help before asking others, please.

Install virtualenv

miohtama / zope-startup-fork.txt
Created Jul 26, 2011
How Zope starts up and where to fork
View zope-startup-fork.txt
Zope start process
Zope2.__init__ contains ZopeStarter
def prepare(self):
# Start ZServer servers before we drop privileges so we can bind to
miohtama / parse-hash-bang-arguments-in-javascript.js
Created Jan 6, 2012
Parse hash bang HTTP GET query style arguments from an URL using Javascript
View parse-hash-bang-arguments-in-javascript.js
* Parse hash bang parameters from a URL as key value object.
* For repeated parameters the last parameter is effective.
* If = syntax is not used the value is set to null.
* #x&y=3 -> { x:null, y:3 }
* @param aURL URL to parse or null if window.location is used
miohtama /
Created Jan 23, 2012
Testing Three.js 3d rendered with Selenium + Python
See that rendering Javascript loads jobs properly.
Skeleton based on
miohtama /
Created Apr 24, 2012
Wrap Python print statement to breakpoint when something prints by catching output
import sys
old_f = sys.stdout
BAD_OUTPUT = "hospitalArrival_dateTimeStrokeOnSet"
class F:
def write(self, x):
if x == BAD_OUTPUT:
import pdb ; pdb.set_trace()
miohtama / gist:2727891
Created May 18, 2012
Create HTML5 <audio> compatible files out of MP3 using ffmpeg
View gist:2727891
# -*- coding: utf8 -*-
import os
import subprocess
def create_prelisten_ogg(mp3, ogg):
Run en-code for a single file
Do 48 kbit files for prelisten.
miohtama /
Created May 20, 2012
Python 2.6 compatible OrderedDict
# Python 2.6 compatible ordered dict
# NOTE: API is not 1:1, but for normal dict access of
# set member, iterate keys and values this is enough
# Add odict egg to your project
from collections import OrderedDict
except ImportError:
from odict import odict as OrderedDict
miohtama / gist:2788628
Created May 25, 2012
Throttle Javascript events so that the same event doesn't fire twice in the timeframe
View gist:2788628
* Kindly ask to redraw the one frame preview.
* This function has throttling support so you can
* fire this from mouse move events (color picking) safely.
* XXX: Make sure all the fonts are loaded in this point or the
* first round of text rendering fails. See hidden font preloader in
miohtama / gist:2821586
Created May 28, 2012
Parsing European day.month.year date in Python
View gist:2821586
import datetime
string = "1.1.2012"
date = datetime.datetime.strptime(string, '%d.%m.%Y').date()
miohtama / gist:2821647
Created May 28, 2012
Sorted datetime objects with Python
View gist:2821647
# The trick is to pass timedelta object as a sort key and not to use cmp() function
import datetime
def date_key(a):
a: date as string
a = datetime.datetime.strptime(a, '%d.%m.%Y').date()
return a