This file contains hidden or 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 os | |
import sys | |
import time | |
### Configuration changes here ### | |
BACKUP_DIR = "/tmp" |
This file contains hidden or 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 subprocess | |
def install_package(package): | |
percent = 0 | |
# Alpine apk provides machine-readable progress in bytes_downloaded/bytes_total format output to file descriptor of choice, so create a pipe for it | |
pipe_rfd, pipe_wfd = os.pipe() | |
with os.fdopen(pipe_rfd) as pipe_rf: | |
with subprocess.Popen(['apk', '--progress-fd', str(pipe_wfd), '--no-cache', 'add', package], pass_fds=[pipe_wfd]) as p: | |
# Close write pipe for vmmgr to not block the pipe once apk finishes | |
os.close(pipe_wfd) |
This file contains hidden or 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 | |
import asyncio | |
import os | |
import signal | |
class Server(): | |
def __init__(self, socket_path): | |
self.jobs = {} | |
self.socket_path = socket_path |
This file contains hidden or 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 | |
STDIN=$(</dev/stdin) | |
echo "Sendmail invoked at $(date)" >>/var/log/sendmail.log | |
echo "Params: ${@}" >>/var/log/sendmail.log | |
echo -e "---\n${STDIN}\n---\n" >>/var/log/sendmail.log | |
echo "${STDIN}" | /usr/sbin/sendmail.real ${@} |
This file contains hidden or 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
-----BEGIN CERTIFICATE----- | |
MIIDZjCCAk6gAwIBAgIUVH0iZ4zKue6OdcaHZ8ul+Hc6gtcwDQYJKoZIhvcNAQEL | |
BQAwSjEjMCEGA1UEAwwaTGV0J3MgRW5jcnlwdCBBdXRob3JpdHkgWDMxFjAUBgNV | |
BAoMDUxldCdzIEVuY3J5cHQxCzAJBgNVBAYTAlVTMB4XDTE4MTEwNTE5Mzg0MFoX | |
DTE5MDIwMzE5Mzg0MFowGzEZMBcGA1UEAwwQZXhhbXBsZS5pbnZhbGlsZDCCASIw | |
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAK5kmB+Gm1mNLylGBf4BcakMU5bb | |
9/rNwTX0jXmFKOrRkbXbkea8RKPjlv+oQrZ8zMu8bgmTyJvk0esSbedGbq2tzDfi | |
Q4fz9dPu+Y4oXnXz0G/zzNibQiXnJJ+AnO5u4BmLHcg/eQQyBQm+tsxDlpd+A9WG | |
wejFUE2XkBG/3yQgPRCzO5w6LopbDX+sP1nDoFME4m0lCmB++w0BQBxlYHT3pMZP | |
dDx7VlychO6UFXz4PPPKnwT2rz1orqNdQ9OohP7ONxPh7QwPD+fKnt7ufyCl+VSg |
This file contains hidden or 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/sh | |
openssl rand -base64 18 | |
head -c 18 /dev/urandom | base64 | |
</dev/urandom tr -cd '[:alnum:]' | head -c26 |
This file contains hidden or 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 threading import Lock | |
@contextmanager | |
def nonblocking(lock=Lock()): | |
locked = lock.acquire(False) | |
try: | |
yield locked | |
finally: | |
if locked: | |
lock.release() |
This file contains hidden or 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/sh | |
# https://blogs.gnome.org/hughsie/2018/08/17/nvme-firmware-i-need-your-data/ | |
dnf install nvme-cli | |
nvme id-ctrl --raw-binary /dev/nvme0 > /tmp/id-ctrl | |
curl \ | |
-F type=nvme \ |
This file contains hidden or 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 | |
import csv | |
colgroup = 5 # Kolik sloupcu na zacatku musi byt stejnych | |
with open('input.csv', 'r') as ifd, open('output.csv', 'w') as ofd: | |
reader = csv.reader(ifd, delimiter=';') # Vstupni CSV | |
writer = csv.writer(ofd, delimiter=';') # Vystupni CSV | |
buffer = [next(reader)] # Buffer, ktery drzi radky se stejnymi prvnimi sloupci |
This file contains hidden or 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
/* | |
Compile using | |
gcc libcurl-check-response.c -lcurl -o libcurl-check-response | |
*/ | |
#include <curl/curl.h> | |
int main(int argc, char *argv[]) | |
{ | |
CURLcode ret; |