Skip to content

Instantly share code, notes, and snippets.


Will Rouesnel wrouesnel

View GitHub Profile
wrouesnel /
Last active May 23, 2021
Python argparse with config file fallback. This is great for scripting up daemon-like tools (note PyDev template syntax - replace as needed)
#!/usr/bin/env python
# encoding: utf-8
import sys
import os
from os import path
wrouesnel / cliptype
Created Apr 22, 2021
Autotype clipboard contents
View cliptype
xclip -selection clipboard -out | xdotool selectwindow windowfocus type --clearmodifiers --delay 25 --window %@ --file -
View csharp_from_db.sql
DECLARE @TableName VARCHAR(MAX) = 'NewsItem' -- Replace 'NewsItem' with your table name
DECLARE @TableSchema VARCHAR(MAX) = 'Markets' -- Replace 'Markets' with your schema name
DECLARE @result varchar(max) = ''
SET @result = @result + 'using System;' + CHAR(13) + CHAR(13)
IF (@TableSchema IS NOT NULL)
SET @result = @result + 'namespace ' + @TableSchema + CHAR(13) + '{' + CHAR(13)
wrouesnel / windows_ux_annoyances.ps1
Last active Feb 13, 2021
Powershell script to make a bunch of initial windows annoyances changes
View windows_ux_annoyances.ps1
# Sets some UX annoyances in Windows
# *************************************************************
# * Change how often Windows asks you for feedback to "NEVER" *
# *************************************************************
New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" `
-Name "NumberOfSIUFInPeriod" `
-PropertyType DWORD `
-Value 0x00000000 `
wrouesnel / .remote-backup-excludes.txt
Last active Jan 22, 2021
A script for performing a remote backup to another server using rsync and bup for versioning.
View .remote-backup-excludes.txt
# this is an rsync-excludes format list of files to exclude.
wrouesnel / ansible-vm-base-image.yml
Created Jan 29, 2016
Ansible VM base image builder
View ansible-vm-base-image.yml
# Provisions a Debian base-image
- hosts: local
connection: local
force_handlers: True
sudo: yes
# - name: Check environment set
# fail: msg="Configuration incompletely specified!"
# when: (server_ip is defined|bool and netmask is defined|bool and gateway is defined|ipaddr and
wrouesnel / gist:6240468b75c6d72053ed
Created Mar 15, 2016
Updating system SSL and java keystore in a docker build
View gist:6240468b75c6d72053ed
# 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; \
View gpg.conf
keyid-format 0xlong
verify-options show-uid-validity
list-options show-uid-validity
wrouesnel / gist:4517f5088a2ac84db5dd6a40191610e2
Last active Jul 17, 2020
Easy bash "atexit" shutdown hooks.
View gist:4517f5088a2ac84db5dd6a40191610e2
function atexit() {
val=$(echo "$@")
trap "shutdown" INT TERM
wrouesnel /
Created Jul 6, 2020
Get the current script directory for a bash shell script.
# See:
# Note: you can't refactor this out: its at the top of every script so the scripts can find their includes.
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
SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"