Skip to content

Instantly share code, notes, and snippets.

View harobed's full-sized avatar
💭
CTO at Spacefill

Stéphane Klein harobed

💭
CTO at Spacefill
View GitHub Profile
from contextlib import nested
from fabric.api import task, run, settings, env
def switch_user(user):
return nested(settings(
user=user,
host_string="%s@%s:%s" % (user, env['host'], env['port'])
))
@task
#!/bin/bash
#
# lxc: linux Container library
# Authors:
# Daniel Lezcano <daniel.lezcano@free.fr>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@harobed
harobed / How to fill dict attribute with Factory-boy ?
Created June 27, 2012 08:49
How to fill dict attribute with Factory-boy ?
class UserFactory(factory.Factory):
FACTORY_FOR = User
first_name = factory.InfiniteIterator([ 'Peggie', 'Gabe', 'King', 'Fredy', 'Ole', 'Vernice' ])
last_name = factory.InfiniteIterator([ 'Leannon', 'Barton', 'Sauer', 'Walker', 'Strosin'])
username = factory.LazyAttribute(
lambda o: '%s.%s@example.com' % (o.first_name.lower(), o.last_name.lower())
)
# How can I feed data in dict, metadata isn't another Entities (MongoDB context)
@harobed
harobed / gist:3713283
Created September 13, 2012 09:49
Mon programme au PyCon FR 2012
Samedi matin :
* Processus de développement de CPython (Antoine Pitrou)
* La boite à outils pour Django (Ordoquy Xavier)
* Picasso, le polyglotte et le philosophe (Marc Chantreux)
* Je configure mes serveurs avec fabric et fabtools (Ronan Amicel)
Samedi après midi :
* OpenERP : gestion d'entreprise Open Source en Python (Alexandre ALLOUCHE)
@harobed
harobed / gist:3905199
Created October 17, 2012 12:07
How to use jQuery simulate with CasperJS
casper.then(function() {
this.test.assertEval(function() {
$('[name="name"]').simulate("key-sequence", {sequence: "{selectall}Foobar"});
return $('.title').text() == 'Foobar';
});
});
@harobed
harobed / gist:3905215
Created October 17, 2012 12:09
Append client scripts in casperjs
var casper = casperjs.create({
verbose: true,
logLevel: "error",
clientScripts: [
'jquery.js',
'jquery.simulate.js',
'jquery.simulate.ext.js',
'jquery.simulate.drag-n-drop.js',
'jquery.simulate.key-combo.js',
'jquery.simulate.key-sequence.js'
@harobed
harobed / gist:5777518
Last active December 18, 2015 11:39 — forked from athoune/gist:5777474
#!/usr/bin/env python
import sys
# Lamson is an application, but also the best way to read email without
# struggling with "battery include" libraries.
from lamson.encoding import from_string
from pyelasticsearch import ElasticSearch
from pyelasticsearch.exceptions import ElasticHttpNotFoundError
@harobed
harobed / gist:5845674
Created June 23, 2013 16:50
python assert equal with ellipsis
import unittest
import re
class BaseTest(unittest.TestCase):
def assertEqualEllipsis(self, first, second, ellipsis_marker='...', msg=None):
"""
Example :
>>> self.assertEqualEllipsis('foo123bar', 'foo...bar')
@harobed
harobed / gist:0e3a2b6420f2ea23c33ad03d9d6e09b3
Last active July 18, 2016 09:43
tu veux que je te donne
#include <stdio.h>
void ft_is_negative(int n)
{
if (n < 0)
{
putchar('N');
}
else
{
#include <stdio.h>
int main ()
{
int chiffres[3];
char *pn = 0;
x = 0;
pn = chiffres;