Skip to content

Instantly share code, notes, and snippets.

@mattions
mattions / myapp.py
Created December 18, 2013 18:07
quick embedded Gunicorn app
from gunicorn.app.base import Application, Config
class GUnicornFlaskApplication(Application):
def __init__(self, app):
self.usage, self.callable, self.prog, self.app = None, None, None, app
def run(self, **options):
self.cfg = Config()
[self.cfg.set(key, value) for key, value in options.items()]
@mattions
mattions / Exploring different distribution.ipynb
Created July 30, 2013 14:32
Shapes and definition of some statistical PDFs, handy to do some modelling. You can see the rendered version on nbviewer here: http://nbviewer.ipython.org/urls/gist.github.com/mattions/6113437/raw/c5468ea930d6960225d83e112d7f3d00d9c13398/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.
@mattions
mattions / python_r_NGS
Created July 26, 2013 15:35
Quick NGS file
{
"metadata": {
"name": "reading stuff in"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mattions
mattions / NGS_notes.ipnb
Last active December 20, 2015 06:39
Notes on the NGS course
{
"metadata": {
"name": "NGS"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@mattions
mattions / page_checker.py
Last active December 19, 2015 07:09
Checking if a sentence goes away from a page.
import requests
import time
from datetime import datetime
from bs4 import BeautifulSoup
URL="http://www.plosone.org/search/advanced?pageSize=12&sort=&queryField=author&queryTerm=&unformattedQuery=author%3A%22Michele+Mattioni%22&journalOpt=some&filterJournals=PLoSONE&subjectCatOpt=all&filterArticleTypeOpt=all"
SENTENCE_WHICH_SHOULD_CHANGE="There were no results"
article_out = False
#!/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 / 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).
@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",