View multiprocess-stats.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
#!/usr/bin/env python3 | |
from multiprocessing import Process, Pool, Manager | |
import random | |
import time | |
def percentile(values, percentile): | |
n = int(round((percentile / 100) * len(values) + 0.5)) | |
return values[n-1] |
View multiprocessing-logging.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
#!/usr/bin/env python3 | |
import logging | |
import multiprocessing | |
def create_logger(): | |
logger = multiprocessing.get_logger() | |
logger.setLevel(logging.INFO) | |
formatter = logging.Formatter(\ |
View multiprocess-producer-consumer.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
#!/usr/bin/env python3 | |
import logging | |
from multiprocessing import Process, Pool, Manager | |
import random | |
import time | |
def init(queue): | |
global q |
View ZeroFile
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 ZeroFile(): | |
def __init__(self, file_size): | |
self.file_size = file_size | |
self._buf = b'\0' | |
self.position = 0 | |
def tell(self): | |
return self.position |
View ntfy-login.sh
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 | |
if [ "$PAM_TYPE" == "close_session" ]; then | |
exit | |
fi | |
curl -s -X POST -H 'Content-type: application/json' SLACK_WEBHOOK \ | |
-d @- > /dev/null << EOF | |
{ | |
"attachments": [ |
View mariadb-backup
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 | |
TIMESTAMP=$(date +"%F") | |
BACKUP_DIR="/backup/$TIMESTAMP" | |
MYSQL=/usr/bin/mysql | |
MYSQLDUMP=/usr/bin/mysqldump | |
NTFY=/usr/local/bin/ntfy | |
mkdir -p "$BACKUP_DIR/mysql" | |
View install-makemkv.sh
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 bash | |
# | |
# Install/update MakeMKV. | |
# | |
TMP=$(mktemp -d) | |
# Get current version | |
VERS=$(curl --silent "http://www.makemkv.com/download/" 2>&1 | \ | |
egrep -o 'MakeMKV ([^ ]*) for' | \ |
View tree.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
from collections import defaultdict | |
def tree(): | |
return defaultdict(tree) |
View hddcheck.sh
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 | |
# | |
# hddcheck.sh | |
# | |
# Modified version of http://www.cyberciti.biz/files/scripts/monitor-my-hard-disk.sh.txt. | |
# | |
# Generate a warning email based on hard drive temps. | |
# | |
TO=test@test.com |
NewerOlder