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 re | |
# Based on: https://stackoverflow.com/a/59071238/21784 | |
def isplit(s, sep='\n'): | |
sep = re.escape(sep) | |
start = 0 | |
for m in re.finditer(sep, s): |
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 time | |
from urllib.parse import urlparse | |
import boto3 | |
from cryptography import x509 | |
from cryptography.x509.oid import NameOID | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives import hashes | |
from cryptography.hazmat.primitives import serialization | |
from cryptography.hazmat.primitives.asymmetric import rsa |
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
# https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself | |
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
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 socket | |
import ssl | |
import certifi | |
_CERT_BUNDLE_PATH = certifi.where() | |
class CertificateStatus(Enum): | |
UNKNOWN = -1 | |
CONNECTION_ERROR = 100 |
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
function string:contains(sub) | |
return self:find(sub, 1, true) ~= nil | |
end | |
function string:startswith(start) | |
return self:sub(1, #start) == start | |
end | |
function string:endswith(ending) |
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
; https://gryzli.info/2019/02/21/tuning-ansible-for-maximum-performance/#Enabling_Pipelining | |
[defaults] | |
# Use the YAML callback plugin. | |
stdout_callback = yaml | |
# Use the stdout_callback when running ad-hoc commands. | |
bin_ansible_callbacks = False | |
deprecation_warnings=False |
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
export CPATH=`xcrun --show-sdk-path`/usr/include |
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 cryptography import x509 | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat.primitives import serialization | |
def verify(path): | |
with open(path, 'rb') as f: | |
cert = x509.load_pem_x509_certificate(f.read(), default_backend()) | |
with open(path, 'rb') as key_file: | |
private_key = serialization.load_pem_private_key( |
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
# -*- mode: nginx; mode:autopair; mode: flyspell-prog; ispell-local-dictionary: "american" -*- | |
# LearningMode; | |
SecRulesEnabled; | |
DeniedUrl "/RequestDenied" | |
CheckRule "$SQL >= 8" BLOCK; | |
CheckRule "$RFI >= 8" BLOCK; | |
CheckRule "$TRAVERSAL >= 4" BLOCK; |
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
# https://stackoverflow.com/questions/166506/finding-local-ip-addresses-using-pythons-stdlib | |
def _get_primary_ip(): | |
sk = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
try: | |
# doesn't even have to be reachable | |
sk.connect(('10.255.255.255', 1)) | |
primary_ip = sk.getsockname()[0] | |
except Exception: | |
primary_ip = '127.0.0.1' | |
finally: |