Skip to content

Instantly share code, notes, and snippets.

View mzpqnxow's full-sized avatar
🙈

AG mzpqnxow

🙈
View GitHub Profile
@mzpqnxow
mzpqnxow / build-nmap-debian.sh
Created October 2, 2021 16:51
Build nmap on Debian/Ubuntu without zenmap, ncat (+ install dependencies)
#!/bin/bash
#
# How many times I've had to do this... this saves the trouble, especially of one-by-one
# recalling what the dependencies are by reading the output of ./configure ...
#
# - AG
#
set -eu
declare -r BUILD_DIR=~/nmap-build
declare -r NMAP_VERSION="7.92"
@mzpqnxow
mzpqnxow / verifyblobsession.py
Created September 4, 2021 00:26
Provide a PEM blob as the verify / CA value to a requests Session instead of a file
"""An extension of requests.Session that provides an interface for specifying a PEM blob
This was created as a workaround for https://github.com/psf/requests/issues/4032
This is really only useful if you have a sprawling application and/or many sessions
and you don't want to handle the NamedTemporaryFile solution outside of the Session
yourself
It's surprising at first that requests.Session doesn't provide the ability to specify
a StringIO (or other file stream like object) but when you see the OpenSSL interface
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /db/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
@mzpqnxow
mzpqnxow / rc.local
Created August 22, 2021 15:26 — forked from yspb/rc.local
#!/bin/sh
sysctl vm.overcommit_memory=1
sysctl -w net.core.somaxconn=65535
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
exit 0
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
@mzpqnxow
mzpqnxow / redis.conf
Created August 22, 2021 15:25 — forked from yspb/redis.conf
################################## MODULES #####################################
loadmodule /db/modules/libredis-roaring.so
loadmodule /db/modules/rejson.so
loadmodule /db/modules/redisearch.so
################################## NETWORK #####################################
bind 127.0.0.1
protected-mode yes
@mzpqnxow
mzpqnxow / node.sh
Created August 22, 2021 15:24 — forked from yspb/node.sh
#make directories
mkdir /git
mkdir /db
mkdir /db/modules
mkdir /downloads
#update packages, install gcc and redis
add-apt-repository ppa:chris-lea/redis-server -y && \
apt-get update && \
apt-get upgrade -y && \
@mzpqnxow
mzpqnxow / lzmarotate.py
Last active January 5, 2022 16:55
LZMA compressed RotatingFileHandler with support for backupCount
"""Example extension of RotatingFileHandler that LZMA compresses the rotated files
Other examples I found didn't actually respect maxBackups, this does
- AG
"""
import codecs
import glob
import logging.handlers
import os
@mzpqnxow
mzpqnxow / logging.py
Created August 8, 2021 15:36 — forked from kingspp/logging.py
Python Comprehensive Logging using YAML Configuration
import os
import yaml
import logging.config
import logging
import coloredlogs
def setup_logging(default_path='logging.yaml', default_level=logging.INFO, env_key='LOG_CFG'):
"""
| **@author:** Prathyush SP
| Logging Setup
@mzpqnxow
mzpqnxow / cachetools-example.py
Created August 1, 2021 15:08
Using cachetools as a convenient short-hand to use Python functiion caching for a specific argument
from cachetools import cached
from cachetools.keys import hashkey
from random import randint
@cached(cache={}, key=lambda db_handle, query: hashkey(query))
@cached(cache={}, key=lambda db_handle, query: hashkey(query))
def find_object(db_handle, query):
saved = query
query = 5