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 | |
# from https://serverfault.com/a/842825/200976 | |
# Create ssh-mux (SSH multiplex) dir only if not exists | |
[[ ! -d dir ]] || mkdir ~/.ssh/ssh-mux | |
apache_site_path_source="/var/www/source_site" | |
apache_site_path_target="/var/www/target_site" |
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
from cryptography import x509 | |
from cryptography.hazmat.backends import default_backend | |
from cryptography.hazmat._der import DERReader, SEQUENCE | |
from cryptography.hazmat.primitives import serialization | |
from cryptography.hazmat.backends.openssl.backend import hashes | |
from binascii import hexlify | |
import sys | |
import json | |
with open('oids.json', 'rt') as f: |
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 | |
''' | |
Run as `echo MESSAGE | smail.py smail.yaml [email protected] -s "Note: warning"` | |
where `smail.yaml` looks like this: | |
---------------------------------- >8 ----------------------------------------- | |
mail: | |
host: smtp.mail.net | |
sender: [email protected] | |
password: !secret mail_password |
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 | |
''' | |
Two-pass re-run safe micro (85 LOC) patcher in python. | |
Sample patch config (yes, it's in YAML): | |
---->8---- | |
version: 0 | |
title: tribute to sublimetext_4126_crack_linux.py by dmknght @github | |
file: /tmp/sublime_text | |
# size: 8862888 # optional check for file size |
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 | |
''' | |
Configure sudo(8) to run openvpn(8) without password prompt by adding | |
you ALL = NOPASSWD: /usr/sbin/openvpn | |
to your sudoers file. The script will try to verify your sudo(8) config. | |
Note: the command to run is | |
sudo openvpn --config myconfig.ovpn | |
where `myconfig.ovpn` is your actual config. |
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 | |
''' | |
Start your OpenVPN config with | |
client | |
management myconfig.socket unix | |
management-query-passwords | |
lines. | |
Make sure the config has | |
static-challenge "Enter PIN: " 1 |
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 | |
# sudo apt install them first: | |
# pandoc evince # pandoc + evince | |
# texlive-xetex # xelatex | |
# ttf-mscorefonts-installer # Georgia TTF | |
args=( "$@" ) | |
tmpd="$(mktemp -p /tmp -d md2pdf.$$.XXXXXXXXXX.tmp)" |
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 | |
''' | |
Simple dict with dot-syntax access to its data. | |
Mostly for configs (the keys are already known). | |
Example: | |
cfg = DottedDict().load_json('config.json') | |
print(cfg.application.db.name) | |
''' | |
from collections import UserDict |
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
def SQL(query): | |
sql = str(query) | |
prm = query.compile().params.copy() | |
for p in prm: | |
t = ':' + p | |
sql = sql.replace(t, f'{prm[p]!r}') | |
return '\t'.join(sql.splitlines()) |
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
# Usage: source it from ~/.bashrc before unsetting color_prompt | |
# it will notify you when you're about to crack a git repo at wrong branch... | |
_is_git() { | |
local wd=`pwd` | |
while [ -n "$wd" -a "$wd" != '/' ]; do | |
[ -d "$wd/.git/." ] && { echo "$wd"; return 0; } | |
wd="$(dirname "$wd")" | |
done | |
return 1 |
NewerOlder