Skip to content

Instantly share code, notes, and snippets.

View chriscz's full-sized avatar
🍎
vs 🍊

Chris Coetzee chriscz

🍎
vs 🍊
  • Activitar
  • Brisbane, Australia
  • 05:40 (UTC +10:00)
View GitHub Profile
@chriscz
chriscz / vagrant-ssh-fast.sh
Created September 30, 2023 00:44
Bash script for speeding up vagrant ssh
#!/bin/bash
SOURCE=${BASH_SOURCE[0]}
while [ -L "$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 )
@chriscz
chriscz / 1_generate_certs.sh
Last active October 7, 2023 00:53 — forked from reillysiemens/signing-vbox-kernel-modules.md
Signing VirtualBox Kernel Modules
#!/usr/bin/env bash
set -eou pipefail
# This is probably waaay too long.
CERTIFICATE_VALID_DAYS=36500
NAME="$(getent passwd $(whoami) | awk -F: '{print $5}')"
OUTPUT_DIR="/root/module-signing"
KEY_FILE="${OUTPUT_DIR}/MOK.priv"
@chriscz
chriscz / active_record_unpersisted_has_one_fix.rb
Created February 16, 2024 10:15
Fix for unpersisted has_one's through being inaccessible in Rails.
# FIXME Rails has-one through is nil on unpersisted objects (bug)
# https://github.com/rails/rails/issues/33155
module ActiveRecordUnpersistedHasOneFix
extend ActiveSupport::Concern
# Define utility methods
class << self
# @return [Array<String>, nil]
def association_path(model_class, association)
path = []