Skip to content

Instantly share code, notes, and snippets.

@thomasaarholt
thomasaarholt / is_notebook.py
Created August 30, 2019 07:02
Check if code is running in jupyter notebook
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
@joshbode
joshbode / logging.py
Last active January 15, 2024 13:39
Colour Logging - Works in Jupyter Lab/Notebook
import sys
import logging
from typing import Optional, Dict
from colorama import Fore, Back, Style
class ColoredFormatter(logging.Formatter):
"""Colored log formatter."""
@blaix
blaix / whatversionoftmuxamirunning.txt
Created August 18, 2017 17:44
I just wanted to know what version of tmux I'm running...
$ 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]]
@pylover
pylover / inspections.txt
Last active April 22, 2024 07:47 — forked from ar45/inspections.txt
PyCharm inspections
# 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
@danijar
danijar / blog_tensorflow_scope_decorator.py
Last active January 17, 2023 01:58
TensorFlow Scope Decorator
# 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