Skip to content

Instantly share code, notes, and snippets.

View MuellerSeb's full-sized avatar
😎
working

Sebastian Müller MuellerSeb

😎
working
View GitHub Profile
@MuellerSeb
MuellerSeb / pdf_export.py
Last active April 9, 2021 09:22
A code snippet creator. Convert code files to cropped PDFs.
# -*- coding: utf-8 -*-
"""A code snippet creator. Convert code files to cropped PDFs.
Copy this file to the folder containing your code-snippets.
A "pdf" folder will be created containing the rendered snippets.
Will convert "*.py" and "*.txt" files by default.
Needs pdflatex and minted installed.
"""
from pathlib import Path
@salotz
salotz / move_axes.py
Created March 1, 2019 20:22
Move a matplotlib Axes from one figure to another.
import matplotlib.pyplot as plt
def move_axes(ax, fig, subplot_spec=111):
"""Move an Axes object from a figure to a new pyplot managed Figure in
the specified subplot."""
# get a reference to the old figure context so we can release it
old_fig = ax.figure
# remove the Axes from it's original Figure context
@cpelley
cpelley / temporary_directory.py
Created August 26, 2014 14:40
Support for temporary directories in python2.7 as context managers (already available in python3.2+)
import shutil
import tempfile
class TemporaryDirectory(object):
"""
Context manager for tempfile.mkdtemp().
This class is available in python +v3.2.
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream