Skip to content

Instantly share code, notes, and snippets.

View ohe's full-sized avatar
🚀

Olivier H. ohe

🚀
  • Smart Flows
  • Paris
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ohe
ohe / test_errno.c
Created May 23, 2014 08:42
Why you should (sometimes) reset errno manually!
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
int main(void) {
unsigned long number = -1;
@ohe
ohe / review
Created August 12, 2013 15:01
Review upstream commits (actually works only on OS X with open command)
#!/bin/bash
# Place here your github organization/account name
GITHUB_ACCOUNT=
COMMITS=`git log ..@{u} --format=%h --no-merges`
for commit in $COMMITS
do
git --no-pager show $commit
@ohe
ohe / defaultdict.py
Created January 13, 2012 10:04
Simple defaultdict implementation
"""
Default Dict Implementation.
Unlike python's collections.defaultdict, the default_factory takes the key in
argument.
"""
class defaultdict(dict):
"""
Default Dict Implementation.
Unlike python's collections.defaultdict, the default_factory (called here
@ohe
ohe / pre-commit
Created June 15, 2011 16:50
Launch flake8 for pre-commit hook
#!/bin/bash
for file in `git diff --name-only --cached`
do
flake8 $file
if [ $? == 0 ]
then
ret_code=0
else
ret_code=1
@ohe
ohe / KataBankOCR.py
Created March 14, 2011 10:06
Une implémentation possible du problèmes KataBankOCR (voir codingdojo.org)
import unittest
ALL_0 = """\
_ _ _ _ _ _ _ _ _
| || || || || || || || || |
|_||_||_||_||_||_||_||_||_|
"""
ALL_1 = """\
@ohe
ohe / earthquake.py
Created March 11, 2011 22:28
EarthQuake in Japan ...
"""
Dirty Scraping Around USGS website to be informed of japan quake replica.
"""
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
from time import sleep
def get_usgs_info():
# classinstancemethod, when you want to use both a classmethod and the function with a class instance
## Descriptors
## Anything with __get__ and optionally __set__:
class classinstancemethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, type=None):
# classinstancemethod, when you want to use both a classmethod and the function with a class instance
## Descriptors
## Anything with __get__ and optionally __set__:
class classinstancemethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, type=None):