Skip to content

Instantly share code, notes, and snippets.

@Yamp
Yamp / ipython-progress.py
Created Apr 9, 2019
Watching your jujpyter progress in page title
View ipython-progress.py
import IPython.core.display as ipydi
tabber_template = """<script id="the_tabber">(() => {
setTimeout(() => document.querySelector("#the_tabber").closest(".output_area").remove());
document.title="%s";
})()</script>"""
def tab(*args):
ipydi.display(ipydi.HTML(tabber_template % " ".join(map(str, args)).replace('"','\\"')))
@Yamp
Yamp / deep_dict.py
Created Feb 12, 2019
d_dict.a.b.c.d = 1234
View deep_dict.py
from collections import defaultdict
class DeepDict(defaultdict):
def __init__(self, d=None):
defaultdict.__init__(self, DeepDict)
if d is not None:
self.from_dict(d)
def __getattr__(self, key):
@Yamp
Yamp / setting.py
Last active Feb 12, 2019
Setting["key"] = "value" Setting["key"].of(Plant.objects.first()) = "value2" Setting["key"].of(table1, employee1) = "value2"
View setting.py
class SettingsMeta(ModelBase):
@logged
def __getitem__(self, name: str) -> Any:
return Setting.get_value(name)
@logged
def __setitem__(self, name: str, value) -> None:
Setting.set_value(name, value)