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
-- Find all active connections (and idle) | |
SELECT | |
pid | |
,state | |
,datname | |
,usename | |
,application_name | |
,client_hostname | |
,client_port | |
,backend_start |
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
# Find in the current folder (recursively) all the files with .xml extension. | |
find . -name '*.xml' | |
# Find all the __pycache__ files (or folders) and execute | |
# for each result the command `rm -r` with the filename as a first argument | |
find . -name "__pycache__" -print0 | xargs -0 rm -r | |
# Find into the /tmp folder files that the path matchs a regex expression | |
find /tmp -regextype posix-egrep -regex ".*\.(le|c)ss$" |
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
# Get valid patterns from http://strftimer.com/ | |
>>> from datetime import datetime, date | |
>>> datetime.strptime("January 23, 2019", "%B %d, %Y") | |
datetime.datetime(2019, 1, 23, 0, 0) | |
>>> datetime.strptime("January 23, 2018", "%B %d, %Y").strftime("%Y-%m-%d") | |
'2018-01-23' | |
>>> datetime.strptime("2021-01-01T18:33:00Z", '%Y-%m-%dT%H:%M:%SZ') # The ISO format supported by Python does not parse dates ended with 'Z' |
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
#!/usr/bin/env sh | |
# | |
# video2gif.sh | |
# | |
# See https://askubuntu.com/questions/648603/how-to-create-an-animated-gif-from-mp4-video-via-command-line | |
# | |
# Useful Params: | |
# | |
# -r Num of frames x sec | |
# -vf scale=512:-1 Scale up to 512, remove to preserve original resolution |
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
#!/usr/bin/python3 | |
""" | |
Filter repeated JSON objects from a given JSON line file. | |
""" # noqa | |
import argparse | |
import json | |
import sys | |
parser = argparse.ArgumentParser( |
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
#!/usr/bin/python3 | |
# | |
# Usage: ./msdos2utf8.py OLD_DOS_FILE NEW_ENCODED_FILE | |
# | |
# Creates a new file UTF-8 encoded, taking the input file as a file with old ASCII encoded used in MS-DOS systems. | |
# | |
# Try to replace 'cp437' with 'iso8859' if the new file isn't encoded properly | |
import sys |
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
from random import random, choice, choices, randint, seed | |
import string | |
seed() | |
random() # Floating point number in the range [0.0, 1.0) | |
0.24756287159145907 | |
choice(['A','B','Z']) | |
'B' |
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
cat file.json | jq '([leaf_paths as $path | {"key": $path | map(tostring) | join("_"),"value": getpath($path)}] | from_entries) | keys' > file_keys.txt |
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
# See https://docs.python.org/3/library/logging.html#logging.debug :: | |
# | |
# There are three keyword arguments in kwargs which are inspected: | |
# exc_info which, if it does not evaluate as false, causes exception information to be | |
# added to the logging message. If an exception tuple (in the format returned by sys.exc_info()) | |
# is provided, it is used; otherwise, sys.exc_info() is called to get the exception information. | |
# | |
# Changed in version 3.5: The exc_info parameter can now accept exception instances. | |
import logging |
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
find . -name "__pycache__" -print0 | xargs -0 rm -r |