Skip to content

Instantly share code, notes, and snippets.

@ammmze
ammmze / README.md
Last active March 7, 2024 07:49
Installing Talos on VPS via Rescue mode

Installing Talos on VPS via Rescue mode

Most VPS solutions have a pretty limited selection of OS's that are available to install on your VPS. Talos is unlikely to be one of the options. While some VPS providers may allow you to open a ticket and receive help installing from a custom ISO, I didn't want to do that. I wanted a way to self-serve and get this installed. This took a bit of digging to learn some of these tools a bit more than I had in the past, but I think this is in a good place.

I haven't permanently put these nodes in my cluster yet, but did verify that I could get an installation done successfully.

@ammmze
ammmze / hoist-directives.sh
Last active June 13, 2023 16:24
Surfaces "use client" and "use server" directives to the top of the file. Workaround for https://github.com/swc-project/swc/issues/7315
#!/usr/bin/env sh
# Workaround for https://github.com/swc-project/swc/issues/7315
DIR="${1}"
if [ -z "${DIR}" ]; then
echo "Missing path to search"
echo "Usage: ${0} ./path-to-search"
exit 1
@ammmze
ammmze / ConditionalExpressionHelper.java
Created May 5, 2022 15:24
Java Handlebars helpers matching mandrill
package com.github.gist.ammmze.handlebars.helpers;
import com.github.jknack.handlebars.Options;
import com.github.jknack.handlebars.helper.IfHelper;
import java.io.IOException;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: chrony
namespace: host-system
spec:
selector:
matchLabels:
app: chrony
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: external-dns-public
namespace: network
spec:
interval: 5m
chart:
spec:
@ammmze
ammmze / README.md
Last active November 20, 2021 19:25
fluxcd + akri + conbee ii

This is a quick documentation on how I've setup akri in my kubernetes cluster to make my Conbee II stick available to zigbee2mqtt as a remote device. This allows zigbee2mqtt to run on any node in the cluster. The advantage to using Akri over node-feature-detection and node affinity rules to run zigbee2mqtt on a given node is that when a device is unplugged Akri will automatically remove the pod. So I can move the stick from one node to another and less than a minute later the stick is ready to be used again.

Eventually Kubernetes plans to add requiredDuringSchedulingRequiredDuringExecution affinity rules which in theory could give us a similar effect where zigbee2mqtt could connect directly to the device rather than connecting remotely, but we could simply move the stick and the zigbee2mqtt pod would follow it.

@ammmze
ammmze / ConverterDateAndJavaTime.java
Last active June 1, 2023 07:12
opencsv HeaderColumnNameAndOrderMappingStrategy
package com.example.csv;
import com.opencsv.bean.ConverterDate;
import com.opencsv.exceptions.CsvDataTypeMismatchException;
import java.lang.reflect.InvocationTargetException;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;
import java.util.Locale;
@ammmze
ammmze / dvd.sh
Last active May 8, 2019 16:38
Video File to DVD ISO
#!/bin/bash
# AVI to DVD Script
# Ben Dowling - www.coderholic.com
# Change to "ntsc" if you'd like to create NTSC disks
format=${VIDEO_FORMAT:-ntsc}
output_file=./dvd.iso
burn=false
burn_dev=/dev/cdrom
@ammmze
ammmze / handlebarsPartialLoader.js
Last active November 6, 2015 18:00
Adds a method to Handlebars (`Handlebars.registerPartialUrl`) which takes 2 parameters: The `name` of the partial and the `url` to read the template from. The ajax request will be cached, so that future requests for the same url will not cause additional requests. Even requesting the same template right after each other does not trigger duplicat…
(function($, Handlebars) {
Handlebars.registerPartialUrl = function (name, url) {
// Get the loaders cache
var loads = Handlebars.URL_REQUEST_CACHE || (Handlebars.URL_REQUEST_CACHE = {});
// Initiate the ajax request only if we don't already have it
if (!loads[url]) {
loads[url] = $.ajax({url: url, dataType: 'text'});
}
// Return the promise object and register a listener for when its done to register the partial
return loads[url].done(function (body) {
@ammmze
ammmze / patch.sh
Last active October 20, 2015 16:56
Patch Intellij 13 PHP Plugin
#!/bin/bash
wget -O ~/Library/Application\ Support/IntellijIdea13/php/lib/php.jar https://gist.github.com/ammmze/17db72254bb4713a2040/raw/fd8033dc385abf1b5a9852a1917801c47e58cc89/php.jar