Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# This hook is run after a new virtualenv is activated.
# ~/.virtualenvs/postmkvirtualenv
libs=( PyQt4 sip.so )
python_version=python$(python -c "import sys; print (str(sys.version_info[0])+'.'+str(sys.version_info[1]))")
var=( $(which -a $python_version) )
get_python_lib_cmd="from distutils.sysconfig import get_python_lib; print (get_python_lib())"
@mattions
mattions / sin_and_cos.py
Last active December 15, 2015 22:09
a bunch of sin and cos
import numpy as np
import pylab as pl
from numpy import sin, cos
x = np.linspace(-10, 10, 500)
pl.plot(x, sin(x), label="sin")
pl.plot(x, cos(x), label="cos")
pl.plot(x, sin(x) + cos(x), label="sin + cos")
pl.plot(x, pow(sin(x), 2), label = "sin^2")
@mattions
mattions / widgets.py
Created January 10, 2013 13:10
Widgets to deal with time and dates, created putting together different solutions. Just storing them here if I ever need them.
import re
import django.forms
from django.forms.widgets import Widget, Select
from django.utils.safestring import mark_safe
from django.forms.widgets import MultiWidget
from django.forms.extras.widgets import SelectDateWidget
__all__ = ('SelectTimeWidget', 'SplitSelectDateTimeWidget')
@mattions
mattions / gist:4194475
Created December 3, 2012 11:49
italian_demographic_dstribution_2011
{
"metadata": {
"name": "italian_demographic_distribution"
},
"nbformat": 2,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
{
"metadata": {
"name": "previsioni_primarie_pd"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
# The Greeter class Python
class Greeter:
def __init__(self, name):
self.name = name.capitalize()
def salute(self):
print "Hello %s!" %self.name
# Create a new object
g = Greeter("world")
@mattions
mattions / build_less.py
Created September 11, 2012 15:10 — forked from aliang/build_less.py
Compile LESS to CSS automatically whenever a file is modified
#!/usr/bin/env python
# determines filename and extension, then delegates compiling the LESS files to lessc via a shell command
import sys, os.path
from subprocess import call
src = sys.argv[1]
base,ext = os.path.splitext(src)
@mattions
mattions / pr.md
Created August 30, 2012 23:26 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

from pysam import VariantFile
import time
def count_oldvar_reg(vcffile_reg, labels=["OLDVARS", "OLDVARS_A", "OLDVARS_B"]):
t_start = time.time()
bcf_in = VariantFile(vcffile_reg)
total = 0
reg = 0
for rec in bcf_in:
@mattions
mattions / protecting_with_braces.py
Created March 30, 2012 13:43
Initial work to protect the Capital letters in latex with braces. WARNING: Does not work, but it is a start
#!/usr/bin/env python
# -*- coding: utf8 -*-
import re
def protect_with_braces(title):
new_title = ''
words = title.split()
for w in words: