This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PyQt4 import uic | |
from PyQt4.QtCore import pyqtWrapperType | |
UI_DIR='path_to_ui_files' | |
class WindowMeta (pyqtWrapperType, type): | |
"""This is the metaclass of all Qt-Windows. It automatically | |
sets the correct base classes, so they do not have to be set | |
by the programmer. | |
@attention: The class has to have the same name as the .ui-file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mixIn (base, addition): | |
"""Mixes in place, i.e. the base class is modified. | |
Tags the class with a list of names of mixed members. | |
""" | |
assert not hasattr(base, '_mixed_') | |
mixed = [] | |
for item, val in addition.__dict__.items(): | |
if not hasattr(base, item): | |
setattr(base, item, val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Per funzionare il programma ha bisogno della libreria pygame | |
# | |
# Le istruzioni per installare pygame sono a questo indirizzo: | |
# http://pygame.org/download.shtml | |
# | |
import pygame, random | |
pygame.init() | |
random.seed() | |
screen = pygame.display.set_mode((400, 400)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from django.db import models | |
from django.core.serializers.json import DjangoJSONEncoder | |
from django.utils import simplejson as json | |
class JSONField(models.TextField): | |
""" | |
JSONField is a generic textfield that neatly serializes/unserializes | |
JSON objects seamlessly. | |
Django snippet #1478 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Point = namedtuple('Point', 'x, y, z') | |
class BoundingBox(object): | |
def __init__(self,bottom,top): | |
self.top = Point._make(top) | |
self.bot = Point._make(bottom) | |
def _point_contained(self, other_point): | |
over_bot = all(map(lambda x: x[0]<=x[1], zip(self.bot,other_point))) | |
under_top = all(map(lambda x: x[0]>=x[1], zip(self.top,other_point))) | |
return over_bot and under_top |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _virtualenv_prompt_info { | |
[[ -n $(whence virtualenv_prompt_info) ]] && virtualenv_prompt_info | |
} | |
function _git_prompt_info { | |
[[ -n $(whence git_prompt_info) ]] && git_prompt_info | |
} | |
function _python_ver { | |
[[ -n $(/usr/bin/env python --version) ]] && python_ver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
PyMol Widget | |
Usage: | |
main.py [input_files] | |
Options: | |
-h, --help: print this screen | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = Massimiliano Pippi | |
email = [email protected] | |
signingkey = 22AA96CA | |
[alias] | |
co = checkout | |
ci = commit | |
st = status | |
br = branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="masci" | |
# Example aliases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VENV=$1 | |
if [ -z $VENV ]; then | |
echo "usage: runinenv [virtualenv_path] CMDS" | |
exit 1 | |
fi | |
. ${VENV}/bin/activate | |
if [ -f ${VENV}/bin/postactivate ]; then | |
. ${VENV}/bin/postactivate |
OlderNewer