Skip to content

Instantly share code, notes, and snippets.

View sigilioso's full-sized avatar

Christian sigilioso

View GitHub Profile
@sigilioso
sigilioso / xunit_summary.py
Created July 28, 2014 12:29
Parses xunit xml output and shows it in a 'human-readable' way.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import glob
from lxml import etree
def tests_elements(nodes):
for elm in nodes:
@sigilioso
sigilioso / psql_tmpfs.sh
Last active August 29, 2015 14:04
Posgresql in memory for testing
#!/bin/bash
set -x
service postgresql stop
TMPDIR=/tmp/tmp_psql
MOUNTPOINT=/var/lib/postgresql
mount -t tmpfs -o size=512M,nr_inodes=10k,mode=0777 tmpfs $TMPDIR
rsync --archive $MOUNTPOINT/ $TMPDIR/
mount -o bind $TMPDIR $MOUNTPOINT
service postgresql start
@sigilioso
sigilioso / property_mock_example.py
Created November 26, 2014 10:15
Side effect for mocks on object attributes access.
from unittest import TestCase
import mock
from django import models
from django.core.exceptions import ObjectDoesNotExist
class Foo(models.Model):
# ...
@property
def has_pending_related(self):
try:
@sigilioso
sigilioso / button_example.css
Created April 10, 2012 16:05
button style example
/*<input class="button" type="submit" value="test">*/
.button {
margin-top: 10px;
padding: 2px;
border: 1px solid #006699;
border-radius: 5px 5px 5px 5px;
color: #006699;
font-weight: bold;
text-align: center;
@sigilioso
sigilioso / input_help_validation.html
Created October 2, 2012 22:44
jQuery simple input help to choose a correct value.
<html>
<head>
<style>
.input_error {
color: red;
font-weight: bold;
}
#code_value_error {
color: red;
}
@sigilioso
sigilioso / postactivate
Created November 25, 2015 11:00
Environment variables for python virtualenvs with virtualenvwrapper
#!/bin/bash
# This hook is run after this virtualenv is activated.
# To be in $VIRTUALENV_HOME/bin/postactivate
if [[ -n $DJANGO_SETTINGS_MODULE ]]
then
export DJANGO_SETTINGS_MODULE_BACKUP=$DJANGO_SETTINGS_MODULE
fi
export DJANGO_SETTINGS_MODULE=YOUR.VALUE
@sigilioso
sigilioso / post-checkout.sh
Last active December 11, 2015 20:19
post-checkout hook to remove old pyc files and avoid errors
# post-checkout hook (on <path-to-project>/.git/hooks/post-checkout file)
# to avoid errors for old pyc files when checkout.
# Remember execution privileges (chmod +x <path-to-project>/.git/hooks/post-checkout).
#!/bin/bash
# Start from the repository root
cd ./$(git rev-parse --show-cdup)
# Delete pyc and empty directories
echo "[post-checkout] Deleting .pyc and empty directories"
find . -name "*.pyc" -delete
@sigilioso
sigilioso / asserts_picker.py
Last active December 21, 2015 01:39
An example to provide assert function from unittest.TestCase
from unittest import TestCase
import inspect
class AssertExample(object):
def __create_method(self, tc, name):
def method(self, *args, **kwargs):
return tc.__getattribute__(name)(self, *args, **kwargs)
return method
@sigilioso
sigilioso / pre_commit_python.py
Last active December 24, 2015 23:29
Git pre-commit: python. Look for debugger traces, check flake8 on changed code and run unit-test via external script.
#!/usr/bin/env python
import os
import sys
import re
import subprocess
from functools import partial
# Fabric requirement just for easy colour output
from fabric.colors import red, green, yellow
@sigilioso
sigilioso / .bashrc
Last active April 19, 2018 07:17
Custom prompt including git information
export LANGUAGE==en_US.utf8
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
source ~/.utils/git-completion.bash
# Only if docker installed
source /etc/bash_completion.d/docker