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
@MuellerSeb
MuellerSeb / listings.tex
Created August 25, 2020 15:40 — forked from FelipeCortez/listings.tex
LaTeX pretty listings
\usepackage{listings}
\usepackage{lstautogobble} % Fix relative indenting
\usepackage{color} % Code coloring
\usepackage{zi4} % Nice font
\definecolor{bluekeywords}{rgb}{0.13, 0.13, 1}
\definecolor{greencomments}{rgb}{0, 0.5, 0}
\definecolor{redstrings}{rgb}{0.9, 0, 0}
\definecolor{graynumbers}{rgb}{0.5, 0.5, 0.5}
if __name__ == "__main__":
from subprocess import Popen, PIPE
with Popen(
[
"pytest",
# '--tb=short', # shorter traceback format
# '--hypothesis-show-statistics',
str(__file__),
],
@MuellerSeb
MuellerSeb / temporary_directory.py
Created August 18, 2019 18:31 — forked from cpelley/temporary_directory.py
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.