Skip to content

Instantly share code, notes, and snippets.

Michele Mattioni mattions

Block or report user

Report or block mattions

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattions
mattions / parse_git.sh
Created Mar 16, 2012
parse_git function in bash which updates your prompt with the git branch if it is a git repo
View parse_git.sh
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory 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 / protecting_with_braces.py
Created Mar 30, 2012
Initial work to protect the Capital letters in latex with braces. WARNING: Does not work, but it is a start
View protecting_with_braces.py
#!/usr/bin/env python
# -*- coding: utf8 -*-
import re
def protect_with_braces(title):
new_title = ''
words = title.split()
for w in words:
@mattions
mattions / gist:2421351
Created Apr 19, 2012
Temporary gist for git crash course
View gist:2421351

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

How git is controlled

General config file

@mattions
mattions / pr.md
Created Aug 30, 2012 — forked from piscisaureus/pr.md
Checkout github pull requests locally
View pr.md

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 / build_less.py
Created Sep 11, 2012 — forked from aliang/build_less.py
Compile LESS to CSS automatically whenever a file is modified
View build_less.py
#!/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)
View greeter.py
# 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")
View gist:4150516
{
"metadata": {
"name": "previsioni_primarie_pd"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mattions
mattions / gist:4194475
Created Dec 3, 2012
italian_demographic_dstribution_2011
View gist:4194475
{
"metadata": {
"name": "italian_demographic_distribution"
},
"nbformat": 2,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
@mattions
mattions / widgets.py
Created Jan 10, 2013
Widgets to deal with time and dates, created putting together different solutions. Just storing them here if I ever need them.
View widgets.py
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 / matplotlibrc
Last active Oct 7, 2017 — forked from huyng/matplotlibrc
Matplotlib style to have a default similar to ggplot2. Inspired by http://www.huyng.com/posts/sane-color-scheme-for-matplotlib/
View matplotlibrc
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overwritten in your next install.
# If you want to keep a permanent local copy that will not be
# overwritten, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
You can’t perform that action at this time.