Skip to content

Instantly share code, notes, and snippets.

@RulerOf
RulerOf / Dockerfile
Created May 22, 2024 19:43
Build ImageMagick into a Ruby AWS Lambda build image at /opt
FROM public.ecr.aws/sam/build-ruby3.2:latest as builder
# Prereqs
RUN yum install -y git gcc gcc-c++ cpp cpio make cmake automake autoconf chkconfig clang clang-libs dos2unix zlib zlib-devel zip unzip tar perl libxml2 bzip2 bzip2-libs xz xz-libs pkgconfig libtool
# libjpg
RUN cd /root && \
curl https://github.com/winlibs/libjpeg/archive/refs/tags/libjpeg-9c.tar.gz -L -o tmp-libjpeg.tar.gz && \
tar xf tmp-libjpeg.tar.gz && \
cd libjpeg* && \
@RulerOf
RulerOf / readme.md
Last active June 29, 2023 04:30
Chef fails with 'No candidate version available' when using amazon-linux-extras on Amazon Linux 2

The Problem

We have a few packages we like to install through Amazon Linux Extras repo, but we discovered that this doesn't work right:

execute 'Enable java 11 via amazon-linux-extras' do
  command 'amazon-linux-extras enable java-openjdk11'
end

package 'java-11-openjdk'
@RulerOf
RulerOf / README.md
Last active May 3, 2023 18:18
Using a different shell without running `chsh`

Problem

I wanted to create a jumpbox where the default shell was zsh, but I couldn't actually change the default shell of the users that would be connecting to the box. I also wanted to manage some symlinks in the user profile dynamically with Dotbot.

My initial idea was to add a script to /etc/profile.d that would just dump users into /bin/zsh, but this had several different problems, including the all-important question of "But what if I want to run Bash on purpose?"

Solution

Through a little bit of trial and error, I settled on this script located at /etc/profile.d/dotbot.sh

@RulerOf
RulerOf / ec2-exec.sh
Created November 16, 2021 10:05
Synchronously run commands on an SSM-managed EC2 instance
#!/bin/bash
which jq > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
>&2 echo Error: this script requires jq; exit 1
fi
which aws > /dev/null 2>&1
if [ "$?" -ne 0 ]; then
>&2 echo Error: this script requires awscli; exit 1
@RulerOf
RulerOf / script.sh
Created June 2, 2021 15:44
Dump linux release information
#!/bin/bash
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
@RulerOf
RulerOf / main.py
Created May 7, 2021 02:35
Predictable Shuffle with Python
import random
shuffle_key = "QRUzaKNB4V5pparzJWTa"
# Imagine we have a list of images that's 200k items long
frame_list = [*range(1,200000)]
# Shuffle the frame list with the key
random.Random(shuffle_key).shuffle(frame_list)
@RulerOf
RulerOf / install.sh
Created April 4, 2021 15:41
Install OpenVSwitch with os-net-config on Debian Buster
# Install python3 and OVS
sudo apt install python3-pip openvswitch-switch -y
# Install os-net-config
sudo pip3 install os-net-config
# Create os-net-config file
sudo mkdir -p /etc/os-net-config
sudo touch /etc/os-net-config/config.yaml
@RulerOf
RulerOf / README.md
Created March 31, 2021 13:44
DNS SRV Records with Terraform

DNS SRV with Terraform (On AWS Route53)

DNS SRV records are a little cryptic. Even when you create them, it's not particularly obvious what the information in the SRV record actaully means.

When creating the records with Terraform, you can for_each the resource to supply one or more maps that contain better descriptors of the SRV record's constituent components. See the example in the terraform snippet below. Refer here for a longer explanation.

@RulerOf
RulerOf / README.md
Last active April 9, 2021 14:26
Provides a bare-minimum configuration to keep Amazon Linux 2 on Lightsail updated if you want it to be a "hands off" setup.

Amazon Linux 2 on Lightsail, Bare Minimum Setup

The idea here is to give a set of "common sense" defaults for running Amazon Linux 2 on Lightsail. These defaults include:

  • Automatic Updates
  • Live Kernel Patching
  • Automatic Reboots when Required by Updates

Usage

@RulerOf
RulerOf / pfsense-on-centos-8.md
Last active January 9, 2024 22:18
Installing pfSense on KVM in CentOS 8

Installing pfSense on KVM in CentOS 8

We download the latest release of pfSense as a gzipped ISO, then extract it and pass it to virt-install to get the VM up and running. Interactive portions of setup are done with virt-install's native console redirection. This guide assumes you've already installed and configured KVM, and that you've created network bridges already.

Instructions

Find the latest release here.

Download the gzipped memstick-serial image from a mirror into a directory that KVM can access, then unzip it: