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/env python3 | |
import signal | |
import socket | |
import multiprocessing | |
import asyncio | |
import logging | |
import argparse | |
from threading import Event | |
from asyncio import StreamReader, StreamWriter |
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 boto3 | |
from datetime import datetime, timedelta | |
from typing import Dict, List | |
def cpu_usage_metrics_for_instance( | |
region: str, instance_id: str, start_time: datetime, duration: timedelta | |
) -> Dict[str, float]: | |
end_time = start_time + duration | |
metric_name = "CPUUtilization" |
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
# Create your CA crt and key: | |
openssl req -new -x509 -nodes -newkey rsa:4096 -extensions v3_ca -sha256 -days 3650 -subj "/C=US/ST=CA/L=San Francisco/O=Acme Inc./CN=Acme Insecure Certificate Authority" -keyout ca.key -out ca.crt | |
chmod 600 ca.key | |
# Create a CSR: | |
openssl req -newkey rsa:2048 -nodes -sha256 -keyout cert.key -out cert.csr -subj "/C=US/ST=CA/L=San Francisco/O=Snakeoil Inc./OU=Core/CN=lobotomat.de" | |
# Check contents of CSR (optional): | |
openssl req -in cert.csr -text -noout |
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
docker_version=$(docker version 2>/dev/null | awk ' | |
BEGIN { | |
version = 0 | |
client_version = 0 | |
server_version = 0 | |
} | |
{ | |
if($1 == "Server:") { | |
server = 1 | |
client = 0 |
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 | |
set -o errexit -o nounset -o pipefail | |
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support" | |
export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver | |
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 | |
export PLEX_MEDIA_SERVER_TMPDIR=/tmp | |
export LD_LIBRARY_PATH="$PLEX_MEDIA_SERVER_HOME" | |
export LC_ALL="en_US.UTF-8" | |
export LANG="en_US.UTF-8" |
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
git checkout $(git branch | grep -E "(main|master)" | sed -e 's/*\s\+//') && git branch | grep -vE "(main|master)" | xargs git branch -D |
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 pprint import pprint | |
document_uri = 'https://gist.githubusercontent.com/demersdesigns/4442cd84c1cc6c5ccda9b19eac1ba52b/raw/cf06109a805b661dd12133f9aa4473435e478569/craft-popular-urls' | |
def process(document, num_threads=10): | |
"""Processes a document either found on the local disk or a remote http/https URI | |
The function reads the document (either from a local file or remote URL) and finds all the http and https URLs in it. |
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 the long region names used by the AWS Pricing API | |
# | |
# There's currently no proper API to do this | |
# | |
# Example: | |
# print(SHORT_TO_LONG_REGIONS['us-west-2']) | |
# > US West (Oregon) | |
from pkg_resources import resource_filename |
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 python | |
import os | |
import json | |
import cherrypy | |
import time | |
import threading | |
from cklib.graph import Graph | |
from cklib.graph.export import node_from_dict | |
from prometheus_client import Summary | |
from prometheus_client.exposition import generate_latest, CONTENT_TYPE_LATEST |
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 python | |
import base64 | |
import os | |
from cryptography.fernet import Fernet, MultiFernet | |
from cryptography.hazmat.primitives import hashes | |
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC | |
psk = "superSecretPreSharedKey" | |
salt = os.urandom(16) | |
content = "Super secret data" |
NewerOlder