Skip to content

Instantly share code, notes, and snippets.

View mzpqnxow's full-sized avatar
🙈
Look at all this free stuff!

AG mzpqnxow

🙈
Look at all this free stuff!
View GitHub Profile
@mzpqnxow
mzpqnxow / update_mozilla_firefox.sh
Created December 5, 2021 18:09
Install/Update Mozilla release of Firefox on Debian and other Linux distributions, can be run from cron
#!/bin/bash
#
# Install/Update Mozilla Firefox conveniently and repeatably, allowing version selection
# The ESR Firefox that ships with Debian 10/11 (and probably Ubuntu, etc) doesn't support
# containers, so I found myself installing the Mozilla distribution of Firefox. That had
# me a little concerned about keeping it up to date, so I run this out of cron. Maybe it's
# useful for someone ...
#
# This is intended for use with XFCE but I think most window managers use the .desktop style
# metadata files for launchers/menus/etc. Check /usr/share/applications/ on your system to
@mzpqnxow
mzpqnxow / pandas_cheat.py
Created November 25, 2021 23:01 — forked from pohzipohzi/pandas_cheat.py
Cheat sheet for the python pandas library
import numpy as np
import pandas as pd
#### creating dataframes, adding and dropping columns
df = pd.DataFrame(np.arange(1,10).reshape(3,3),['A','B','C'],['w','x','y'])
df.columns = ['W','X','Y'] # change column names
df['Z']=df['X']+df['Y'] # new column with values X+Y
df['XX']=df.apply(lambda row: row['X']*2, axis=1) # new column with values twice of column X
df['YY']=1 # new column of ones
@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