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
def _save_more_extensions(filename, extensions=['png', 'svg', 'pdf']):
for ext in extensions:
comp_filename = "{0}.{1}".format(filename, ext)
plt.savefig(comp_filename, dpi=300)
print "Saved plot: {0}".format(comp_filename)
# purge-old-kernels - remove old kernel packages
# Copyright (C) 2012 Dustin Kirkland <>
# Authors: Dustin Kirkland <>
# Kees Cook <>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
mattions / .screenrc
Created May 9, 2015
Sane screen rc default
View .screenrc
hardstatus alwayslastline '%{= G}[ %{G}%H %{g}][%= %{= w}%?%-Lw%?%{= R}%n*%f %t%?%{= R}(%u)%?%{= w}%+Lw%?%= %{= g}][ %{y}Load: %l %{g}][%{B}%Y-%m-%d %{W}%c:%s %{g}]'
startup_message off
termcapinfo xterm* ti@:te@
backtick 1 5 5 true
termcapinfo rxvt* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'
View style.min.css
* Bootstrap v3.2.0 (
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (
*//*! normalize.css v3.0.1 | MIT License | */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:0}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:700}dfn{font-style:italic}h1{margin:.67em 0;font-size:2em}mark{color:#000;background:#ff0}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{height:0;-webkit-box-sizing:content-box;-moz-box-sizing:cont
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import time
data = []
for n_elements in [100, 1000, 10000, 100000]:
a = range(n_elements)
sa = set(a)
b = np.array(a) + 50
View pagination
{% if is_paginated %}
<div class="col-md-offset-4">
<ul class="pagination pagination-centered">
{% if page_obj.has_previous %}
<li><a href="?page=1"><<</a></li>
<li><a href="?{{queries.urlencode}}&amp;page={{ page_obj.previous_page_number }}"><</a></li>
{% endif %}
{% for i in paginator.page_range %}
<li {% if page_obj.number == i %} class="active" {% endif %}><a href="?{{queries.urlencode}}&amp;page={{i}}">{{i}}</a></li>
View json-all-the-way
"metadata": {
"name": "",
"signature": "sha256:5835de2e10cb99253cfa1841c86b02e6b9ee8b2fb21e513bbaec771e6e006c1b"
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
"cells": [
View prepare_headers_bfx
import json
import base64
import hashlib
import hmac
def _prepare_headers(payload, api_key, api_secret):
# payload = parameters-dictionary -> JSON encode -> base64
payload_json = json.dumps(payload)
payload_encoded = base64.encodestring(payload_json)
# signature = HMAC-SHA384(payload, api-secret) as hexadecimal
mattions /
Created Dec 18, 2013
quick embedded Gunicorn app
from import Application, Config
class GUnicornFlaskApplication(Application):
def __init__(self, app):
self.usage, self.callable, self.prog, = None, None, None, app
def run(self, **options):
self.cfg = Config()
[self.cfg.set(key, value) for key, value in options.items()]
View Exploring different distribution.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.