Skip to content

Instantly share code, notes, and snippets.

View show_mongo_converts_tzaware_datetimes.py
# A snippet to show that pymongo / mongo converts timezone aware datetime objects to UTC, when saving.
# docker run --env MONGO_INITDB_DATABASE=brain --env MONGO_INITDB_ROOT_USERNAME=root --env MONGO_INITDB_ROOT_PASSWORD=secret --publish-all mongo:4.2
#
# lookup which port it was mapped to:
# $ docker container ls
# CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
# 8eaf2dd5aedb mongo:4.2 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:55000->27017/tcp brave_moser
import datetime
@mezhaka
mezhaka / threadpool_queue.py
Last active Mar 26, 2021
Show threadpool processes only max_workers tasks at the same time and behaves like a queue
View threadpool_queue.py
# Show threadpool processes only max_workers tasks at the same time and behaves
# like a queue
import itertools
from concurrent import futures
from io import StringIO
from time import sleep
def print_sleep_print(p, out):
print("(", file=out, end="")
@mezhaka
mezhaka / profile_example.py
Created Aug 28, 2018
Printing profiling stats example
View profile_example.py
#!/usr/bin/env python3.4
import cProfile
import pstats
def first():
pass
def second():