This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prevent Git managing line endings of CSV files, otherwise it changes CRLF to LF on commit and checkout. | |
# This is useful if you're working with CSV files that come from legacy systems and have differing line endings. | |
# | |
# You can see view how Git manages line endings with this command: git ls-files --eol | grep .csv | |
# | |
# @see: https://git-scm.com/docs/gitattributes | |
# @see: https://stackoverflow.com/questions/17628305/windows-git-warning-lf-will-be-replaced-by-crlf-is-that-warning-tail-backwar | |
# @see: https://stackoverflow.com/questions/42667996/enforce-core-autocrlf-input-through-gitattributes | |
# @see: https://stackoverflow.com/questions/20496084/git-status-ignore-line-endings-identical-files-windows-linux-environment | |
# @see: https://stackoverflow.com/questions/21822650/disable-git-eol-conversions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
directory = '/home/kenny/gist' | |
if not os.path.exists(directory): | |
os.makedirs(directory) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import matplotlib.pyplot as plt | |
def save(path, ext='png', close=True, verbose=True): | |
"""Save a figure from pyplot. | |
Parameters | |
---------- | |
path : string | |
The path (and filename, without the extension) to save the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
import sys, os | |
@contextmanager | |
def suppress_stdout(): | |
with open(os.devnull, "w") as devnull: | |
old_stdout = sys.stdout | |
sys.stdout = devnull | |
try: | |
yield |