- Adopted from: https://github.com/azagniotov/stubby4j/blob/master/docs/ADMIN_PORTAL.md
- Inspired by Swagger API docs style & structure: https://petstore.swagger.io/#/pet
The set
lines
- These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
- With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
set -euxo pipefail
is short for:
set -e
set -u
Once upon a time there was a user that wanted to install firefox.
The user tried to do pacman -S firefox
but it didn't work. The all
mighty pacman reported that firefox-3.2.4-1.i686.pkg.tar.gz
could not
be found on his mirror. So the user tried pacman -Sy firefox
. It
worked and the user rejoiced since he could once again go and troll /h/.
But all was not good. The user had made a grave error!
See, when the user told the almighty pacman to -Sy firefox
, pacman did
Comprehensions are a really useful feature of Python that aren't available in JavaScript (or many languages).
These concepts of course can be tranlsated into using map
instead. But especially the dictionaries are a bit
trickier.
>>> foobar = range(5)
>>> [x + 1 for x in foobar]
[1, 2, 3, 4, 5]
You have to do 2 things in order to allow your container to access your host's postgresql database
- Make your postgresql listen to an external ip address
- Let this client ip (your docker container) access your postgresql database with a given user
Obs: By "Host" here I mean "the server where docker is running on".
Find your postgresql.conf (in case you don't know where it is)
$ sudo find / -type f -name postgresql.conf
# Reference | |
# https://github.com/Delgan/loguru/issues/302 | |
from logging import __file__, Handler, LogRecord, currentframe | |
from sys import stdout, stderr | |
class InterceptHandler(Handler): | |
def emit(self, record: LogRecord): | |
# Get corresponding Loguru level if it exists | |
try: |
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |