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
rbarrois / wsgi.py
Created May 25, 2018
Django uWSGI warmup
View wsgi.py
# -*- coding: utf-8 -*-
import io
import os
import sys
import time
import wsgiref.util
import uwsgidecorators
@rbarrois
rbarrois / fixed.py
Last active Feb 27, 2017
Support sur #python-fr, 20170227
View fixed.py
# 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"
os.remove("gaumont.generate.txt");
FILE = open("gaumont.generate.txt", "a+");
print("=========================");
print(" GAUMONT GENERATOR BY TCHOTCHO");
@rbarrois
rbarrois / my_factory.py
Created Feb 6, 2015
WIP: API for factory_boy / SQLAlchemy's session
View my_factory.py
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
rbarrois / test_lcd.py
Created Sep 7, 2014
Small test tool for mpdlcd / LCDd charset
View test_lcd.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import socket
import sys
DEFAULT_LCDD_CHARSET = 'utf-8'
@rbarrois
rbarrois / settings.py
Created Sep 29, 2013
Helper to get pretty (?) exceptions in Django templates for invalid variable names.
View settings.py
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
rbarrois / mock_datetime.py
Created Apr 21, 2013
Proper module for patching datetime.datetime.now().
View mock_datetime.py
# This code is in the public domain
# Author: Raphaël Barrois
from __future__ import print_function
import datetime
import mock
@rbarrois
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.