You're browsing snippets anonymously. Log in or create an account to save and manage your own snippets.
Public Snippets
Showing
12 snippets
where
is:
public
Reset default python log handlers
import logging
formatter = logging.Formatter('FOO: %(message)s')
root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO)
# This is the key line that removes the double logging
...
By
xtream1101
•
•
Updated
2025-03-04 18:33
Check if a server has strictsni enabled
curl -v -k https://1.2.3.4
By
xtream1101
•
•
Updated
2025-02-28 14:13
Firefox hide tab bar
/* Source file https://github.com/MrOtherGuy/firefox-csshacks/tree/master/chrome/hide_tabs_toolbar_v2.css made available under Mozilla Public License v. 2.0
See the above repository for updates as we...
By
xtream1101
•
•
Updated
2025-02-27 21:45
Get domain cert details in cli
DOMAIN=yourdomain.tld
echo | openssl s_client -showcerts -servername $DOMAIN -connect $DOMAIN:443 2>/dev/null | openssl x509 -inform pem -noout -text
By
xtream1101
•
•
Updated
2025-02-12 19:48
List mounted drives
df -h --output=target,size,used,avail,pcent,source | grep -e Mounted -e $1 | awk 'NR<2{print $0;next}{print $0| "sort"}'
By
xtream1101
•
•
Updated
2025-02-08 22:44
Django graphene mutation input validation
import graphene
class ScratchpadMutation(graphene.relay.ClientIDMutation):
class Input:
created_by = graphene.String(required=True)
foobar = graphene.String()
test = g...
By
xtream1101
•
•
Updated
2025-02-06 14:13
Try, try again - Multiple try/except blocks in a flat format
data = {'some_key': 'key value'}
key_data = None
for _ in range(1):
try:
key_data = data['someKey']
except Exception: pass
else: break # It worked
try:
key_d...
By
xtream1101
•
•
Updated
2025-02-06 13:43
Multi key sort on a list of dicts
data = [
{'name': 'Alice', 'age': 25, 'city': 'New York'},
{'name': 'Bob', 'age': 30, 'city': 'London'},
{'name': 'Charlie', 'age': 20, 'city': 'New York'}
]
# Sort by 'city' first,...
By
xtream1101
•
•
Updated
2025-02-06 13:27
Convert image to dxf file
inkscape --export-type=dxf my-image.svg
By
xtream1101
•
•
Updated
2025-02-06 05:18
Clean up empty dirs
# List/print empty dirs (does not delete)
find /mnt/my-data/ -type d -empty -print
# Delete empty dirs
find /mnt/my-data/ -type d -empty -delete
By
xtream1101
•
•
Updated
2025-02-06 05:15
Bash command test
# Access individual arguments
echo "The first argument is: $1"
echo "The second argument is: $2"
# Access all arguments
echo "All arguments: $@"
# Access the number of arguments
echo "Number...
By
xtream1101
•
•
Updated
2025-02-06 05:13
Showing
12 snippets
Snippet
import logging
formatter = logging.Formatter('FOO: %(message)s')
root_logger = logging.getLogger()
root_logger.setLevel(logging.INFO)
# This is the key line that removes the double logging
root_logger.handlers.clear()
# Must add a custom logger back otherwise there will be no log output
sys_stream = logging.StreamHandler()
sys_stream.setFormatter(formatter)
root_logger.addHandler(sys_stream)
logger = logging.getLogger(__name__)
Description
AWS lambdas seem to add their own custom logging to the python logger, causing all logs to output twice when also adding your own custom logger. You may not see any change when running this locally, but it does make a difference when running in a aws lambda.
By
xtream1101
•
•
Updated
2025-03-04 18:33