Skip to content

Instantly share code, notes, and snippets.

View sigilioso's full-sized avatar

Christian sigilioso

View GitHub Profile
@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 / cuter.py
Created June 19, 2012 22:58
Python PIL Example: get a thumbnail by resizing and cropping an image.
# -*- coding: utf-8 -*-
import Image
def resize_and_crop(img_path, modified_path, size, crop_type='top'):
"""
Resize and crop an image to fit the specified size.
args:
img_path: path for the image to resize.
@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 / .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
@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 / .gitconfig
Last active February 7, 2019 09:35
gitconfig
[user]
name = Your Name
email = [email protected]
[color]
ui = true
[pull]
default = current
[push]
default = current
[alias]
@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