Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lukauskas
lukauskas / function_lock.py
Last active August 29, 2015 14:21
Python functions locked without setup() function (see https://twitter.com/randal_olson/status/599610510795874304)
from __future__ import print_function
from functools import wraps
class UnitialisedFunctionCallException(Exception):
pass
def setup_function(function_):
@wraps(function_)
def setter(self, *args, **kwargs):
@lukauskas
lukauskas / gist:08b11f1cde505d32746c
Last active August 29, 2015 14:14
install-python 2.7.9 script
#/bin/bash
# Get installation prefix from the args
VERSION=2.7.9
PREFIX=$HOME/python${VERSION} # Default to home/python-2.7.9
if [ -n "$1" ]; then
PREFIX=$1
if [ ! -d "$PREFIX" ]; then
mkdir $PREFIX
fi
@lukauskas
lukauskas / random-wallpaper-gnome.py
Last active November 28, 2018 13:28
Random Wallpaper for GNOME 3
#!/usr/bin/env python
"""
Sets a random wallpaper on Mac OSX Mavericks.
The wallpaper is fetched from interfacelift's random page for Retina resolution
"""
from urllib.request import Request, urlopen
import re
import os
# We need to pretend we are Chrome, otherwise HTTP 403 Forbidden is thrown
@lukauskas
lukauskas / parse_sbml_stoichiometry.py
Last active June 7, 2021 04:12
Parse SBML stoichiometry matrix
from __future__ import print_function
import libsbml
import argparse
def _parser():
parser = argparse.ArgumentParser(description="Parse stoichiometry matrix of SBML file")
parser.add_argument('file', metavar="filename", type=argparse.FileType('r'),
help="Filename of SBML file to parse")
@lukauskas
lukauskas / random-wallpaper.py
Last active November 6, 2018 08:30
Download and set a random wallpaper on Mac OSX Mavericks
#!/usr/bin/env python
"""
Sets a random wallpaper on Mac OSX Mavericks.
The wallpaper is fetched from interfacelift's random page for Retina resolution
"""
import urllib2
import re
import os
# We need to pretend we are Chrome, otherwise HTTP 403 Forbidden is thrown
@lukauskas
lukauskas / ipnbdoctest.py
Last active February 23, 2016 01:26 — forked from shoyer/ipnbdoctest.py
#!/usr/bin/env python
"""
simple example script for running and testing notebooks.
Forked from shoyer / ipnbdoctest.py (https://gist.github.com/shoyer/7497853),
who has forked from the original author minrk/ipnbdoctest.py (https://gist.github.com/minrk/2620735)
Usage: `ipnbdoctest.py foo.ipynb [bar.ipynb [...]]`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
@lukauskas
lukauskas / benchmark.ipynb
Last active August 29, 2015 13:56
A set of benchmarks for the "Why your Python is slow. Part 1: Data Structures" blogpost
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lukauskas
lukauskas / install_python.sh
Last active December 18, 2015 05:49
Script to install python 2.7 to a local location together with virtualenv
#/bin/bash
# Get installation prefix from the args
PREFIX=$HOME # Default to home
if [ -n "$1" ]; then
PREFIX=$1
if [ ! -d "$PREFIX" ]; then
mkdir $PREFIX
fi
PREFIX=`cd $PREFIX; pwd` # Convert to absolute path