Skip to content

Instantly share code, notes, and snippets.

View jlumbroso's full-sized avatar

Jérémie Lumbroso jlumbroso

View GitHub Profile
@jlumbroso
jlumbroso / MissingFormatKey.py
Created July 5, 2019 02:41
Python method to format a string with missing keys.
"""
MissingFormatKey.py
Author: Jérémie Lumbroso <[email protected]>
Date: 2019-07-03
Usage:
# Define replacement f"..." compatible with Python 2 and 3
_f = _make_f(globals=lambda: globals(), locals=lambda: locals())
@jlumbroso
jlumbroso / SimpleColorLogging.py
Created April 21, 2019 22:49
Short snippet showing how to have colored terminal logging output in Python.
import os
import logging
class _Color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
@jlumbroso
jlumbroso / genanki-media-test.py
Created September 23, 2018 14:23
Minimal example of how to create a working Anki deck with a media file embedded.
import genanki
my_model = genanki.Model(
1380120064,
'Example',
fields=[
{'name': 'Object'},
{'name': 'Image'},
],
templates=[
@jlumbroso
jlumbroso / genanki-media-test.py
Created September 23, 2018 04:55
Minimal example to build an Anki deck with an image, with genanki
import genanki
my_model = genanki.Model(
1380120064,
'Example',
fields=[
{'name': 'Object'},
{'name': 'Image'},
],
templates=[