Skip to content

Instantly share code, notes, and snippets.

View azylinski's full-sized avatar

Artur Zylinski azylinski

View GitHub Profile
import datetime
from dataclasses import dataclass
# exceptions.py
class NoMoneyException(Exception):
pass
class InvalidValueException(Exception):
pass
export MYIP=$(dig -4 +short myip.opendns.com @resolver1.opendns.com)
import svgwrite
from dataclasses import dataclass
from random import randint, uniform
@dataclass
class Circle:
x: float
y: float
r: float
@azylinski
azylinski / set-docker-ps-format.sh
Created December 20, 2017 16:53
Overwrite default "docker ps" format
# 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
@azylinski
azylinski / uuid.py
Created October 12, 2017 22:36
Get uuid from Python dict.
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()