Skip to content

Instantly share code, notes, and snippets.

@glance-
glance- / netboot-embedd.ipxe
Created March 5, 2023 14:36
Ipxe embedded script
#!ipxe
ifstat
ifopen && goto chain ||
dhcp
:chan
chain --replace http://${next-server}/netboot.ipxe
#!/usr/bin/perl
# vim: ts=4 sw=4 et
use warnings;
use strict;
use autodie;
use Data::Dumper;
exit(0) unless ($ENV{FAI_ACTION} // '' eq 'install' and $ENV{disklist} // '' eq 'nvme0n1');
@glance-
glance- / Makefile
Created June 12, 2020 07:36
use hass-cli to edit lovelace config as yaml in vim
# make edit_lovelace-ui.yml
edit_lovelace-ui.yml:
TMPFILE=$$(mktemp /tmp/XXXXXX-lovelace-ui.yml) ; \
~/lap/homeassistant/bin/hass-cli raw ws lovelace/config > "$${TMPFILE}" ; \
perl -pi -e 'BEGIN {undef $$/;} s/^id: 1\ntype: result\nsuccess: true\nresult:\n/config:\n/' "$${TMPFILE}"; \
vim "$${TMPFILE}" ; \
~/lap/homeassistant/bin/hass-cli raw ws lovelace/config/save --yaml "@$${TMPFILE}" && \
rm -f "$${TMPFILE}"
@glance-
glance- / .rtorrent.rc
Created May 13, 2020 21:27
rtorrent / screen / systemd
# If we're running with the right systemd env, run our heartbeat to systemd.
execute2={/bin/systemd-notify,--ready}
execute2={/bin/bash,-c,systemd-notify MAINPID=`ps -p "$\{1:-$$\}" -o ppid= | tr -d " "`}
execute2={/bin/systemd-notify,WATCHDOG_USEC=480000000}
schedule=systemd_watchdg, 10, 60, "execute2={/bin/systemd-notify,WATCHDOG=1}"
@glance-
glance- / .git-pre-commit.sh
Created October 14, 2019 09:03
Don't allow git commit as root
#!/bin/bash
# install with ln -s ../../.git-pre-commit.sh .git/hooks/pre-commit
AUTHORINFO=$(git var GIT_AUTHOR_IDENT) || exit 1
NAME=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^\(.*\) <.*$/\1/p')
EMAIL=$(printf '%s\n' "${AUTHORINFO}" | sed -n 's/^.* <\(.*\)> .*$/\1/p')
[ "${NAME}" != root ] && [ "${NAME}" != "Your Name" ] && [[ ! "${EMAIL}" =~ root@.* ]] || {
cat <<EOF >&2
Please commit under your own name and email instead of "${NAME} <${EMAIL}>":
@glance-
glance- / hack-docker-plugin-instance-cap.groovy
Created October 10, 2019 12:53
This is a nice hack to workaround a bug in docker-plugin
def c = com.nirima.jenkins.plugins.docker.DockerCloud.getCloudByName('Host docker')
// We're going to hack java final fields here...
import java.lang.reflect.Field
import java.lang.reflect.Modifier
for (def jt in c.getJobTemplates().values()) {
Field field = jt.getClass().getDeclaredField("instanceCap")
Field modifiersField = Field.class.getDeclaredField("modifiers")
@glance-
glance- / LockableResourcesHelper.groovy
Created August 10, 2017 06:52
Helper pipeline library for label based locking in jenkins pipeline
// vim: noet sw=4 ts=4 cindent
// This is a helper that runs as privileged code, to get the LockableResource to pipeline jobs
package PipelineHelpers;
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted
// Wrapper class to expose a safe subset to the client code
class LockableResourcesHelper implements Serializable {