(venv) $ python3 manage.py showmigrations
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_alter_permission_name_max_length
[X] 0003_alter_user_email_max_length
(venv) $ python3 manage.py showmigrations
account
[X] 0001_initial
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
DROP DATABASE
CREATE DATABASE
ALTER DATABASE
You are now connected to database "netbox" as user "postgres".
GRANT
SET
SET
SET
SET
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
# https://stackoverflow.com/questions/1557571/how-do-i-get-time-of-a-python-programs-execution | |
time -v python yourprogram.py |
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
#!/bin/bash | |
function rand() { | |
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1 | |
} | |
echo $(rand 20) | |
## OUTPUT | |
# w4QS0zoS9yUUAEc6dlMJ |
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
# https://stackoverflow.com/questions/40959708/find-all-log-files-under-a-directory-copy-them-to-another-directory-named-af | |
find /stack-exchange/ -type f -iname "*.log" -exec sh -c 'cp "$0" "./logs/$(basename "$(dirname "$0")").log"' {} \; |
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 math | |
class Test: | |
def __init__(self): | |
self.radius = 0 | |
@property | |
def perimeter(self): | |
return self.radius |
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
# https://pythonguide.readthedocs.io/en/latest/python/unix.html | |
class Test: | |
public_class_attribute = 1 | |
_protected_class_attribute = 2 | |
__private_class_attribute = 3 | |
def __init__(self): | |
self.public_instance_attribute = 4 | |
self._protected_instance_attribute = 5 |
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
class MyException(Exception): | |
def __init__(self, message): | |
super().__init__(message) |
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 sys | |
import logging | |
from logging import handlers | |
from logging.handlers import RotatingFileHandler | |
LOG_PYTH = '/var/log/logging.log' | |
LOG_LEVEL = logging.DEBUG | |
LOG_BACKUP_COUNT = 10 | |
LOG_MB = 1048576 | |
LOG_MAX_BYTES = MB * 10 |
NewerOlder