Skip to content

Instantly share code, notes, and snippets.

@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()
@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
"""
Nested Imports Mechanism, a la Java
===================================
Usage::
import nimp
nimp.install()
# also, nimp.uninstall()
@tomerfiliba
tomerfiliba / gist:1152878
Created August 17, 2011 23:09
My first Haskell program
{- learning haskell by "porting" Construct from python -}
import Data.Int
import Data.Word
import qualified Data.ByteString.Lazy as LBS
import Data.Char
import Control.Monad
import Data.Binary.Get
data Packer t = Packer {
@tomerfiliba
tomerfiliba / gist:1239758
Created September 24, 2011 19:41
Foxx0rz
o
(s
);
P(c);
N();;
exe(p); //
typedef //u
/*jj>*/ /*op
*/ unsigned char
nf ; main(){ char ch[
from utils import singleton
from monads import monadic, MonadRunner
class Text(object):
def __init__(self, text):
self.text = text
class Input(object):
def __init__(self, label):
self.label = label
{-# LANGUAGE ScopedTypeVariables #-}
--module Construct where
import Prelude hiding (const, repeat)
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Word (Word8, Word16, Word32, Word64)
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Binary as BIN
import Data.Bits (Bits, bitSize, shiftR)
@tomerfiliba
tomerfiliba / tailcal.py
Created January 25, 2012 15:03
Tail call optimization
#
# By Nimrod Aviram and Eyal Lotem
#
import functools
class TailCallFunc(object):
def __init__(self, func):
self.func = func
@tomerfiliba
tomerfiliba / gist:2693796
Created May 14, 2012 12:56
The most efficient way to compute powers of two!
>>> x=""
>>> for i in range(25):
... print i, len(x)
... x = repr(x)
...
0 0
1 2
2 4
3 8
4 16
@tomerfiliba
tomerfiliba / gist:3773288
Created September 23, 2012 22:33
mumble
import threading
MAPPINGS = {
"&" : "&",
"'" : "'",
'"' : """,
"<" : "&lt;",
">" : "&gt;",
}