Skip to content

Instantly share code, notes, and snippets.

Raphaël Barrois rbarrois

Block or report user

Report or block rbarrois

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
rbarrois /
Created May 25, 2018
Django uWSGI warmup
# -*- coding: utf-8 -*-
import io
import os
import sys
import time
import wsgiref.util
import uwsgidecorators
rbarrois /
Last active Feb 27, 2017
Support sur #python-fr, 20170227
# Pas besoin de point-virgule
import os;
# Utilise open("gaumont.generate.txt", 'w') à la place ; ici tu supprimes le fichier puis l'ouvres en mode "ajout à la fin",
# autant l'ouvrir directement en mode "remplacement"
FILE = open("gaumont.generate.txt", "a+");
rbarrois /
Created Feb 6, 2015
WIP: API for factory_boy / SQLAlchemy's session
import factory
import factory.alchemy
import my_tests
import my_models
class MyFactory(factory.alchemy.SQLAlchemyFactory):
class Meta:
sqlalchemy_session_loader = my_tests.session_loader
model = my_models.Model
rbarrois /
Created Sep 7, 2014
Small test tool for mpdlcd / LCDd charset
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import socket
import sys
rbarrois /
Created Sep 29, 2013
Helper to get pretty (?) exceptions in Django templates for invalid variable names.
class InvalidStringHandler(object):
"""Custom handler for invalid string in templates."""
def __call__(self):
"""Force crashes in {{ foo|sth }}, without breaking __str__."""
import ipdb; ipdb.set_trace()
raise ValueError()
def __nonzero__(self):
"""So that '{% if foo %}' doesn't break."""
rbarrois /
Created Apr 21, 2013
Proper module for patching
# This code is in the public domain
# Author: Raphaël Barrois
from __future__ import print_function
import datetime
import mock
rbarrois / gist:3721801
Created Sep 14, 2012
Well behaving HTTP transport for suds
View gist:3721801
from suds.transport.http import HttpTransport as SudsHttpTransport
class WellBehavedHttpTransport(SudsHttpTransport):
"""HttpTransport which properly obeys the ``*_proxy`` environment variables."""
def u2handlers(self):
"""Return a list of specific handlers to add.
The urllib2 logic regarding ``build_opener(*handlers)`` is:
You can’t perform that action at this time.