Skip to content

Instantly share code, notes, and snippets.

z0u /
Created September 2, 2016 14:39
Just like functools.lru_cache, but creates a new cache for each instance - which is more useful for methods.
def instance_method_lru_cache(*cache_args, **cache_kwargs):
Just like functools.lru_cache, but a new cache is created for each instance
of the class that owns the method this is applied to.
def cache_decorator(func):
def cache_factory(self, *args, **kwargs):
# Wrap the function in a cache by calling the decorator
instance_cache = lru_cache(*cache_args, **cache_kwargs)(func)
z0u /
Created December 1, 2015 23:10
SQLAlchemy workaround for PostgreSQL functions that produce columns
# Workaround for unusual PostgreSQL syntax, where functions act like columns.
# Recipe provided by zzzeek (Mike Bayer), author of SA.
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql import functions
from sqlalchemy.sql.elements import ColumnClause
z0u /
Last active November 24, 2022 21:50
Python script to create an executable game by combining a Blender file with the blenderplayer. Asset files can be included; these will not be combined with the executable, but included in the zip archive. The blenderplayer is sourced from a Blender release archive, so multiple platforms can be targeted. To get a release archive, go to: http://ww…
#!/usr/bin/env python3
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
<!doctype html>
<script src="lib/jquery/jquery.js"></script>
<script src="lib/jquery/jquery-ui.js"></script>
<script src="lib/jsplumb/jquery.jsPlumb.js"></script>
$(function() {
z0u /
Created February 4, 2012 22:43 — forked from neowulf/
Creates a patch file between svn branch and git branch
# git-svn-diff originally by (
# modified by
# modified by aconway@[redacted] - handle diffs that introduce new files
# modified by - fixes diffs that introduce new files
# modified by - fix sed syntax issue in OS X
# modified by - search for last SVN commit; allow diff
# against non-tracking branch; remove function names on @@ lines.