Skip to content

Instantly share code, notes, and snippets.

{
"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:

@mattions
mattions / gist:2421351
Created April 19, 2012 14:36
Temporary gist for git crash course

================= Git: Crash course

How git is controlled

General config file

@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:
@mattions
mattions / parse_git.sh
Last active December 7, 2020 10:54
parse_git function in bash which updates your prompt with the git branch if it is a git repo
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
}
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
@mattions
mattions / neuronvisio_dev_reqs.txt
Created February 8, 2012 16:57
Requirements for version 0.8.0 of neuronvisio
-e git+https://mattions@github.com/mattions/mayavi.git@fix-21#egg=mayavi
-e git+https://github.com/enthought/traitsui.git#egg=traitsui
ipython==0.12
@mattions
mattions / patch_qstring_windows_pyqt.py
Created October 2, 2011 10:58
importing the right Qstring for Python 3 on windows
"""
This is a check to make sure the sip and the Qstrings play nicely in Windows,
where the PySide is using the new Python API (Python 3)
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg19702.html
http://stackoverflow.com/questions/1400858/how-to-create-qstring-in-pyqt4
This could be easily removed when we move to Python 3
"""
if os.name == 'nt':
import sip
sip.setapi('QString', 2)
@mattions
mattions / run_model_in_neuronvisio_example.py
Created September 12, 2011 15:07
run a downloaded model in Neuronvisio
def run_model_in_neuronvisio(model_dir):
if os.path.exists(os.path.join (model_dir, 'mosinit.hoc')):
os.chdir(model_dir)
#TODO: We should check if the file is already compiled,
# and call the right executable according to the system.
call(['nrnivmodl'])
from neuron import gui # to not freeze neuron gui
from neuron import h
from neuronvisio.controls import Controls