Skip to content

Instantly share code, notes, and snippets.

@jul
jul / www.py
Created August 29, 2012 13:54
begining flask + md à la dokuwiki
from flask import Flask, flash, redirect, url_for
from flask import render_template, safe_join
from flask import Markup
from patch import Proxied
import os
_cdir="content"
conf={
'_cdir' : "content"
}
@jul
jul / named_arg_deco.py
Created September 3, 2012 09:44
brouillon de décorateur générique pour argument nommés ... brouillon ... brouillon ... DRAFT ... ACHTUNG .. danger
#!/usr/bin/env python
# -*- coding: utf8 -*-
class decorate(object):
def __init__(self,name="must have key",hook=None, api_hook=None,):
self.hook=hook
self.name=name
self.api_hook=api_hook
def __call__(self,*pos,**named):
@jul
jul / bench_op.py
Created September 8, 2012 12:08
testing float vs int speed for mul, pow, xor
import sys
from time import clock
from random import randint as rand
from math import sqrt
sample = [ rand(0,(1<<16) - 1 ) for i in range(0,10000000 ) ]
fsample=map(lambda x : .0001 *x, sample)
def time_me(sample, tag,op):
start=clock()
@jul
jul / median_vs_arma.py
Created September 27, 2012 15:06
finding a probable needle in a big haystack
#!/usr/bin/python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from scipy.signal import medfilt
import numpy as np
NOISE_AMPLITUDE = 4.0
PERIOD = 200
PRESENCE_PROBABILITY = .4
@jul
jul / heapify.py
Last active July 20, 2023 15:54
Exact translation of an heap obfuscated algorithm
"""A heap is a recipie to represent an array as a
binary tree.
A binary tree is a convenient structure for
manipulating ordered data.
Said simply:
we implement a binary tree abstraction on top of an array.
this tree as the following properties:
any child value is smaller than its parent's value
left child is greater than right child.
@jul
jul / pyco_translate.py
Created October 21, 2012 17:44
light trad system with serialized dict (any format that serialize dicts
import os
import codecs
import json
""" $ cat *json
{"welcome": { "fr": "bienvenue", "es": "holla " }}
"""
class Translator(object):
def __init__(self,path=".",_format="json"):
try:
@jul
jul / testing_signal.py
Created October 25, 2012 13:52
using signals as wire
#!/usr/bin/env python3.3
import signal as s
from time import sleep
import fcntl
from time import asctime as _asctime
from random import randint
import os,sys
asctime= lambda : _asctime()[11:19]
@jul
jul / wire_signal.c
Created November 1, 2012 16:01
signal in C
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <bits/signum.h>
int val=0;
int pipefd[2];
#define RPIPE 0
@jul
jul / signal2.c
Created November 2, 2012 00:58
grrr
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <bits/signum.h>
#include <string.h>
int pipefd[2];
#define RPIPE 0
@jul
jul / signal2.py
Created November 5, 2012 00:34
signal as wired select version
#!/usr/bin/env python3.3
import signal as s
from time import sleep
import fcntl
import select
from time import asctime as _asctime
from random import randint
import os,sys
asctime= lambda : _asctime()[11:19]