Skip to content

Instantly share code, notes, and snippets.

@ephes
ephes / dict.py
Created February 21, 2024 23:20
Memory usage __dict__ vs __slots__
import string
import random
long_key = "a_key_with_a_very_long_name_"
class Test:
def __init__(self):
for i in range(20):
v = "".join(random.choices(string.ascii_lowercase, k=20))
def blog_to_podcast(blog, content_type):
exclude = {"id", "page_ptr_id", "page_ptr", "translation_key"}
kwargs = {
f.name: getattr(blog, f.name)
for f in Blog._meta.fields
if f.name not in exclude
}
kwargs["slug"] = f"new_{blog.slug}"
kwargs["content_type"] = content_type
kwargs["new_itunes_artwork"] = blog.itunes_artwork
http:
routers:
{{ fqdn }}-web-router:
rule: "{{ traefik_host_rule }}"
entryPoints:
- web
middlewares:
- redirect
service: {{ fqdn }}-web
┬─[jochen@ephes-m1:~/s/podlovers.org]─[13:45:31]─[G:master=]
╰─>$ NODE_APP_INSTANCE=testpodlovers npm run build Fr 22 Apr 13:45:31 2022
> build
> npm run clean && gridsome build
> clean
> rm -rf static/images
@ephes
ephes / essen_dus
Created February 22, 2022 09:02
Empfehlenswerte Restaurants in Düsseldorf
# Kein schöner Ort zum Rumhängen, ist aber lecker
* Kirtis Dhaba
* Cho
* Beef Brothers (Burger)
* Takumi
* Su Nuraghe (Pizza)
# Auch zum Rumhängen geeignet
* Embrass
* Der böse Chinese
spam = {"ham": "eggs", "sausage": "tomato"}
spam = spam | {"ham": "bacon"} # since 3.9
spam = {**spam, "ham": "bacon"} # since 3.5
spam = dict(spam, ham="bacon") # even on python2
assert spam == {'ham': 'bacon', 'sausage': 'tomato'}
spam = {"ham": "eggs"}
spam | {"ham": "bacon"} # since 3.9
{**spam, "ham": "bacon"} # since 3.5
dict(spam, ham="bacon") # even on python2
import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
import os
import time
import math
import psutil
def convert_size(size_bytes):
if size_bytes == 0:
return "0B"
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")