Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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)
# 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")
{
"metadata": {
"name": "previsioni_primarie_pd"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@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",
@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 / matplotlibrc
Last active October 7, 2017 23:58 — 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/
### 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).