Skip to content

Instantly share code, notes, and snippets.

View karlvr's full-sized avatar

Karl von Randow karlvr

View GitHub Profile
@karlvr
karlvr / 00README.md
Last active November 26, 2023 14:21
Roadwarrior configuration for macOS 10.12, iOS 10 and Windows 10 using strongSwan and user certificates

strongSwan setup for Road Warriors on macOS 10.12, iOS 10 and Windows 10

This setup is for remote users to connect into an office/home LAN using a VPN (ipsec). This is based on (but not the same as) the strongSwan documentation and this guide: https://raymii.org/s/tutorials/IPSEC_vpn_with_Ubuntu_16.04.html

I used strongSwan 5.5.1.

apt-get install -y strongswan strongswan-pki
@karlvr
karlvr / migrate-nexus-to-github-packages.md
Last active October 25, 2023 12:20
A small bash script to migrate Maven packages from Sonatype Nexus to GitHub Packages

Migrate Maven packages from Sonatype Nexus to GitHub Packages

This gist describes the process we've used to migrate our Maven package repository from Sonatype Nexus to GitHub Packages. The same process could be used for migrating any Maven package repo that is in the standard layout.

We created a special repository on GitHub to hold all of our Maven packages. You might decide to migrate packages to different repositories, in which case invoke the script multiple times.

The script uses find to look for all of the folders containing poms and upload them. You specify the folder

@karlvr
karlvr / Dynamic Ansible Roles.md
Last active September 20, 2023 13:25
Ansible playbook example of running roles dynamically by including a list of role names in a host's vars

I have a heterogenous set of hosts and a mix of different roles that I want to apply to each host. Using groups would mean creating a group for nearly every role, which felt like overkill.

This combination of a playbook and two task scripts runs the roles specified in the host's required_roles variable, in order. It supports a tag named after the role, to run the specific role, and a tag role-partial to activate the role but to require other tags to activate specific tasks in the role (helpful when debugging roles).

@karlvr
karlvr / opensceneryx.sh
Last active November 3, 2022 08:06
Download and update OpenSceneryX from https://www.opensceneryx.com
#!/bin/bash -eu
# Download and update OpenSceneryX from https://www.opensceneryx.com
target="${1:-}"
if [ -z "$target" ]; then
echo "usage: $0 <target dir>" >&2
exit 1
fi
if [ ! -d "$target" ]; then
#!/bin/bash
# This script automatically sets the version and short version string of
# an Xcode project from the Git repository containing the project.
#
# To use this script in Xcode, add the script's path to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
--
-- GEOIP IN POSTGRESQL
--
-- We use two approaches. First using PostgreSQL inet and cidr types and indexing (PostgreSQL 9.4 and later),
-- and then using ip4r (https://github.com/RhodiumToad/ip4r).
-- The performance of ip4r indexes is significantly better than PostgreSQL's own index.
-- An operation that took 42s using ip4r took 47 minutes using PostgreSQL's cidr index.
--
@karlvr
karlvr / git-delete-tags-not-part-of-branch.sh
Last active October 29, 2021 05:03
Delete tags from a git repository that reference commits that aren't part of the named branch.
#!/bin/bash -eu
#
# Delete tags from a git repository that reference commits that aren't part of the named branch
#
# This is useful if you've split a branch out of a repository and want to remove all of the commits
# that referenced activity in other branches.
usage() {
echo "usage: $0 [-d] [-p <remote>] <branch>" >&1
echo " -d dry run" >&1
@karlvr
karlvr / main.css
Created September 2, 2021 02:43
Webpack asset naming ENAMETOOLONG bug
body {
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNyIgdmlld0JveD0iMCAwIDE2IDE3Ij4KICA8cGF0aCBmaWxsPSIjRkZGRkZGIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xNiw4IEwxNiw0LjAwNjg0NTQ3IEMxNiwzLjQ0OTk0ODc2IDE1LjU1MTg5NDUsMyAxNC45OTkxMjgzLDMgTDEzLDMgTDEzLDUuMDAwMTkyNTEgQzEzLDUuNTUyMzcwOTQgMTIuNTU2MTM1Miw2IDEyLDYgQzExLjQ0NzcxNTMsNiAxMSw1LjU1NjI4MzM1IDExLDUuMDAwMTkyNTEgTDExLDMgTDUsMyBMNSw1LjAwMDE5MjUxIEM1LDUuNTUyMzcwOTQgNC41NTYxMzUxOCw2IDQsNiBDMy40NDc3MTUyNSw2IDMsNS41NTYyODMzNSAzLDUuMDAwMTkyNTEgTDMsMyBMMS4wMDA4NzE2NiwzIEMwLjQ0NDYzMDg2MSwzIDAsMy40NTA3ODAwNyAwLDQuMDA2ODQ1NDcgTDAsOCBMMTYsOCBaIE0xNiw5IEwxNiwxNS45OTMxNTQ1IEMxNiwxNi41NDkyMTk5IDE1LjU1NTM2OTEsMTcgMTQuOTk5MTI4MywxNyBMMS4wMDA4NzE2NiwxNyBDMC40NDgxMDU1MDUsMTcgMCwxNi41NTAwNTEyIDAsMTUuOTkzMTU0NSBMMCw5IEwxNiw5IFogTTQsMiBDMy40NDc3MTUyNSwyIDMsMS41NTIyODQ3NSAzLDEgQzMsMC40NDc3MTUyNSAzLjQ0NzcxNTI1LDAgNCwwIEM0LjU1MjI4NDc1LDAgNSwwLjQ0NzcxNTI1IDUsMSBDNSwxLjU1MjI4NDc1IDQuNTUyMjg0NzUsMiA0LDIgWiBNMTI
@karlvr
karlvr / ob-search.js
Created March 23, 2021 19:42
Search a JavaScript object for a string
function search(ob, needle, path = [], seen = new Map()) {
if (seen.has(ob)) {
return
}
seen.set(ob, true)
for (const key of Object.keys(ob)) {
if (typeof ob[key] === 'string') {
if (ob[key].indexOf(needle) !== -1) {
const pathDesc = [...path, key].map(pathKey => Number(pathKey) == pathKey ? `[${pathKey}]` : `.${pathKey}`).join('').substring(1)
@karlvr
karlvr / bulk-update-git-remotes.sh
Created November 12, 2020 00:06
A bash script to search and replace git remotes in multiple git repositories
#!/bin/bash -eu
# Update the git remotes on git working copies contained in the given parent folder.
#
# usage: bulk-update-git-remotes.sh <path containing git repo(s)> <remote search> <remote replace>
#
# e.g. bulk-update-git-remotes.sh ~/git github.com/foo gitlab.com/bar
dryrun=0
while getopts ":n" opt; do