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
def is_notebook(): | |
try: | |
from IPython import get_ipython | |
if "IPKernelApp" not in get_ipython().config: # pragma: no cover | |
raise ImportError("console") | |
return False | |
if "VSCODE_PID" in os.environ: # pragma: no cover | |
raise ImportError("vscode") | |
return False |
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 sys | |
import logging | |
from typing import Optional, Dict | |
from colorama import Fore, Back, Style | |
class ColoredFormatter(logging.Formatter): | |
"""Colored log formatter.""" |
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
$ tmux --version | |
tmux: illegal option -- - | |
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name] | |
[-S socket-path] [command [flags]] | |
$ tmux --help | |
tmux: illegal option -- - | |
usage: tmux [-2CluvV] [-c shell-command] [-f file] [-L socket-name] | |
[-S socket-path] [command [flags]] |
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
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |' | |
# noinspection PyPep8 | |
# noinspection PyPep8Naming | |
# noinspection PyTypeChecker | |
# noinspection PyAbstractClass | |
# noinspection PyArgumentEqualDefault | |
# noinspection PyArgumentList | |
# noinspection PyAssignmentToLoopOrWithParameter | |
# noinspection PyAttributeOutsideInit |
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
# Working example for my blog post at: | |
# https://danijar.github.io/structuring-your-tensorflow-models | |
import functools | |
import tensorflow as tf | |
from tensorflow.examples.tutorials.mnist import input_data | |
def doublewrap(function): | |
""" | |
A decorator decorator, allowing to use the decorator to be used without |