Skip to content

Instantly share code, notes, and snippets.

@BigNerd
BigNerd / strict_base_model.py
Created March 29, 2022 08:46
strict pydantic base model validating that all fields are defined
from pydantic import BaseModel, root_validator
class StrictBaseModel(BaseModel):
@root_validator(pre=True)
def check_all_fields_are_defined(cls, values):
for v in values:
if v not in cls.__fields__:
raise ValueError(f"{v} is not a field of {cls}")
@BigNerd
BigNerd / k9s.txt
Last active April 23, 2024 22:41
K9s column descriptions
View: Pods(<namespace>)[number of pods listed]
NAME pod name
READY number of pods in ready state / number of pods to be in ready state
RESTARTS number of times the pod has been restarted so far
STATUS state of the pod life cycle, such as Running | ... | Completed
CPU current CPU usage, unit is milli-vCPU
MEM current main memory usage, unit is MiB
%CPU/R current CPU usage as a percentage of what has been requested by the pod
%MEM/R current main memory usage as a percentage of what has been requested by the pod
@BigNerd
BigNerd / thread_safe_model.py
Created June 27, 2020 12:56
A wrapper for thread safe execution of Keras model prediction when using Tensorflow as backend
import threading
from keras.models import Model
import keras
class ThreadSafeModel:
def __init__(self, model: Model):
self.model = model
self.lock = threading.Lock()
import math
import matplotlib.pyplot as plt
import numpy as np
import random
import scipy.stats as stats
die_e = 3.5 # expected value of an ordinary six-sided die
die_var = 17.5/6 # variance of an ordinary six-sided die
die_sigma = math.sqrt(die_var)
import math
import matplotlib.pyplot as plt
import numpy as np
import random
import scipy.stats as stats
die_e = 3.5 # expected value of an ordinary six-sided die
die_var = 17.5/6 # variance of an ordinary six-sided die
die_sigma = math.sqrt(die_var)
import math
import matplotlib.pyplot as plt
import numpy as np
import random
import scipy.stats as stats
die_e = 3.5 # expected value of an ordinary six-sided die
die_var = 17.5/6 # variance of an ordinary six-sided die
die_sigma = math.sqrt(die_var)
@BigNerd
BigNerd / download-my-fritz-box-logs.sh
Created June 2, 2019 10:48
This bash script downloads the current Fritz Box event log as JSON file and as TXT file
#!/bin/bash
#
# This bash script downloads the current Fritz Box event log as JSON file and as TXT file.
#
# The login procedure was implemented according to https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID.pdf
#
# The script was tested successfully on MacOS High Sierra 10.13.6 with Fritz!Box 6490 Cable (kdg)
PASSWORD=<replace-with-your-fritz-box-password>