Skip to content

Instantly share code, notes, and snippets.

@tomerfiliba
tomerfiliba / __lazy__.py
Created June 16, 2011 22:29
__lazy__ importing
import sys
from types import ModuleType
__path__ = []
LAZY_PREFIX = "__lazy__"
class OnDemandModule(ModuleType):
def __init__(self, name):
ModuleType.__init__(self, name)
object.__setattr__(self, "__module", None)
"""
Nested Imports Mechanism, a la Java
===================================
Usage::
import nimp
nimp.install()
# also, nimp.uninstall()
@tomerfiliba
tomerfiliba / gist:961708
Created May 8, 2011 21:38
Simple Wiki Custom Filter
$filter = array(
'fid' => _customfilter_map_filter_id('2'),
'type' => base64_decode('bXl3aWtp'),
'name' => base64_decode('TXlXaWtp'),
'cache' => 1,
'description' => base64_decode('DQoqKmJvbGQqKg0KLy9pdGFsaWMvLw0KX191bmRlcmxpbmVfXw0KLS1kZWxldGVkLS0NCmBgbW9ub2BgDQpcKmVzY2FwZWRcXA0KPSBoMQ0KPT0gaDINCj09PSBoMw0KW1tjb2RlIExBTkddXS4uLltbL2NvZGVdXQ0KW1tsaW5rIFVSTF1dIHRleHQgW1svbGlua11dDQpbW2ltZyBVUkxdXSBhbHQgdGV4dCBbWy9pbWddXQ0K'),
'shorttip' => base64_decode('Kipib2xkKioNCi8vaXRhbGljLy8NCl9fdW5kZXJsaW5lX18NCi0tZGVsZXRlZC0tDQpgYG1vbm9gYA0KXCplc2NhcGVkXFwNCj0gaDENCj09IGgyDQo9PT0gaDMNCltbY29kZSBMQU5HXV0uLi5bWy9jb2RlXV0NCltbbGluayBVUkxdXSB0ZXh0IFtbL2xpbmtdXQ0KW1tpbWcgVVJMXV0gYWx0IHRleHQgW1svaW1nXV0NCg=='),
'longtip' => base64_decode('Kipib2xkKioNCi8vaXRhbGljLy8NCl9fdW5kZXJsaW5lX18NCi0tZGVsZXRlZC0tDQpgYG1vbm9gYA0KXCplc2NhcGVkXFwNCj0gaDENCj09IGgyDQo9PT0gaDMNCltbY29kZSBMQU5HXV0uLi5bWy9jb2RlXV0NCltbbGluayBVUkxdXSB0ZXh0IFtbL2xpbmtdXQ0KW1tpbWcgVVJMXV0gYWx0IHRleHQgW1svaW1nXV0NCltbcnRsXV0uLltbL3J0bF1dDQpbW2x0cl1dL
@tomerfiliba
tomerfiliba / gist:954045
Created May 3, 2011 19:36
construct ideas
from struct import Struct as _Struct
from io import BytesIO
from collections import OrderedDict
from types import GeneratorType
class Construct(object):
__slots__ = []
def parse(self, stream):
raise NotImplementedError()