This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
from dataclasses import dataclass | |
# exceptions.py | |
class NoMoneyException(Exception): | |
pass | |
class InvalidValueException(Exception): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export MYIP=$(dig -4 +short myip.opendns.com @resolver1.opendns.com) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import svgwrite | |
from dataclasses import dataclass | |
from random import randint, uniform | |
@dataclass | |
class Circle: | |
x: float | |
y: float | |
r: float |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# docker ps --format | |
# Example: docker ps --format 'table {{.Names}}\t{{.Image}}\t{{.Command}}\t{{.Status}}' | |
# | |
# Overwrite default "docker ps" format (do not show Container ID and Created At columns) | |
# Read more: https://container42.com/2016/03/27/docker-quicktip-7-psformat/ | |
jq '. + {"psFormat": "table {{.Names}}\t{{.Image}}\t{{.Command}}\t{{.Status}}"}' ~/.docker/config.json > /tmp/docker_config.json && mv /tmp/docker_config.json ~/.docker/config.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from json import JSONEncoder, dumps | |
from datetime import date, datetime | |
from uuid import NAMESPACE_DNS, uuid3 | |
class DateTimeEncoder(JSONEncoder): | |
def default(self, obj): | |
if isinstance(obj, (date, datetime)): | |
return obj.isoformat() |