Skip to content

Instantly share code, notes, and snippets.

View wrouesnel's full-sized avatar

Will Rouesnel wrouesnel

View GitHub Profile
@wrouesnel
wrouesnel / .gitconfig
Last active August 29, 2022 09:55
MS Access git merging scripts
# Obviously you're appending these sections.
[core]
ignorecase = true
[merge]
renormalize = true
tool = msaccess-merge
[mergetool "msaccess-merge"]
cmd = $(git rev-parse --show-toplevel)/msaccess-merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
trustExitCode = true
@wrouesnel
wrouesnel / relative_requests_session
Created August 24, 2022 10:30
Python relative requests session
import requests
from furl import furl
class RelativeSession(requests.Session):
def __init__(self, base_url):
super(RelativeSession, self).__init__()
self.__base_url = furl(base_url)
def request(self, method, url, **kwargs):
url = str(self.__base_url / url)
@wrouesnel
wrouesnel / collapsible.yml
Created August 23, 2022 03:00
gitlab collapsible sections
# Start
- printf "\e[0Ksection_start:`date +%s`:execution_section_0[collapsed=true]\r\e[0KEnvironment Info\n"
# End
- printf "section_end:`date +%s`:execution_section_0\r\e[0K"
@wrouesnel
wrouesnel / gist:6240468b75c6d72053ed
Created March 15, 2016 13:40
Updating system SSL and java keystore in a docker build
# Compile and install certificates for the Java trust keystore
# and main keystore. Let's face it, this is everyone's keystore password.
# Note I install java very flatly normally.
COPY trust-certs/ /usr/local/share/ca-certificates/
RUN update-ca-certificates && \
ls -1 /usr/local/share/ca-certificates | while read cert; do \
openssl x509 -outform der -in /usr/local/share/ca-certificates/$cert -out $cert.der; \
/java/bin/keytool -import -alias $cert -keystore /java/jre/lib/security/cacerts -trustcacerts -file $cert.der -storepass changeit -noprompt; \
rm $cert.der; \
done
@wrouesnel
wrouesnel / reverseit.systemd
Created August 10, 2022 23:45
Systemd script with restarts which will keep going
[Unit]
Description=Maintain a reverseit SSH connection
After=network.target
StartLimitBurst=5
# This line disables the "stop forever" start back off
StartLimitIntervalSec=0
[Service]
Type=simple
@wrouesnel
wrouesnel / README.md
Created August 2, 2022 00:47
Firefox enterprise CA certs
@wrouesnel
wrouesnel / README.md
Created July 23, 2022 10:22
Github Clone All

Script for bulk cloning of Github repositories.

@wrouesnel
wrouesnel / safeid.sh
Created June 8, 2022 03:47
128 bit ID in b32 lowercase with no special characters
# Generate a 128-bit identifier, encoded entirely in b32 lowercase. No special characters.
function safeid() {
python3 -c 'import uuid, base64 ; print(base64.b32encode(uuid.uuid4().bytes).lower().rstrip(b"=").decode())'
}
@wrouesnel
wrouesnel / keyvaluejsonaction.py
Created March 19, 2022 03:42
An action implementing key=<json> parsing
import argparse
import json
class KeyValueJsonAction(argparse.Action):
"""
Argparse action for generating dictionaries from key-value args with JSON support
"""
def __call__(self, parser, namespace, values, option_string=None):
result = {}
for entry in values:
@wrouesnel
wrouesnel / standard-bash-script-header.sh
Created March 13, 2022 23:24
standard-bash-script-header.sh
# See: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself
# Note: you can't refactor this out: its at the top of every script so the scripts can find their includes.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"