Skip to content

Instantly share code, notes, and snippets.

View oleiade's full-sized avatar
🐫
OCamling

Théo Crevon oleiade

🐫
OCamling
View GitHub Profile
@oleiade
oleiade / rclean.py
Created July 8, 2011 09:32
Recursive clean script, removes every given -f option filetype from current base directory and in subdirectories
#!/usr/bin/python
import fnmatch, subprocess
import sys, os
import argparse
def generate_filename_pattern(pattern):
try:
if pattern[0] == '.':
#!/usr/bin/env python
import sys
import pprint
from time import sleep
import twitter
import redis
API_CREDENTIALS = {
@oleiade
oleiade / flies_will_fly.py
Created November 21, 2011 14:28
Flies will fly
#!/usr/bin/env python
import time
import random
import sys
import pygame
from pygame import gfxdraw
from pygame.time import Clock
from pygame import DOUBLEBUF, HWSURFACE
#include <iostream>
#include <fstream>
#include <string>
#include <boost/algorithm/string.hpp>
#include "dump.hh"
#include "constants.hh"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
@oleiade
oleiade / pre-commit.py
Created February 23, 2012 17:47
requirements.txt package blacklisting git pre-commit hook
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
MANUAL_PACKAGES = dict.fromkeys([
'leveldb',
])
@oleiade
oleiade / decorators.py
Created February 24, 2012 09:21
Python snippets
def memoize(func, cache, num_args):
"""
Wrap a function so that results for any argument tuple are stored in
'cache'. Note that the args to the function must be usable as dictionary
keys.
Only the first num_args are considered when creating the key.
"""
@wraps(func)
def wrapper(*args):
@oleiade
oleiade / python_patterns.py
Created April 12, 2012 08:02
Python patterns
##
## Common Python patterns and idioms
##
# remove elements from list in-place
mylist[:] = [e for e in mylist if mycondition(mylist)]
Diff a appliquer pour pouvoir gerer les coefficients:
iff --git a/axiom/core/hooks.py b/axiom/core/hooks.py
index ca6d47d..6cd9364 100644
--- a/axiom/core/hooks.py
+++ b/axiom/core/hooks.py
@@ -163,15 +163,15 @@ class Hooks(object):
entity['overriden'] = True
else:
relevancy_markers = [
@oleiade
oleiade / override_add.html
Created May 22, 2012 10:12
multiple failing selection box
<label class="control-label" for="channelselect">Channels</label>
<div class="controls">
<select name="channels" id="channelselect" multiple="multiple" style="height: 150px;">
{% for channel in channels %}
<option value="{{ channel }}">{{ channel }}</option>
{% endfor %}
</select>
<p class="help-block">Channels on whih keyword should be overriden</p>
</div>
@oleiade
oleiade / override_add.html
Created May 22, 2012 10:13
failing multiple selection
<label class="control-label" for="channelselect">Channels</label>
<div class="controls">
<select name="channels" id="channelselect" multiple="multiple" style="height: 150px;">
{% for channel in channels %}
<option value="{{ channel }}">{{ channel }}</option>
{% endfor %}
</select>
<p class="help-block">Channels on whih keyword should be overriden</p>
</div>