Skip to content

Instantly share code, notes, and snippets.

@johnlane
johnlane / README.md
Last active November 1, 2023 19:56
Simple installer for ArchLinux on ZFS (tested in VirtualBox)

ArchZFS examples

Use with QEMU; example:

for i in {1..2}; do qemu-img create -f qcow2 hd$i.qcow2 4G; done
qemu-system-x86_64 --enable-kvm -global isa-fdc.fdtypeA=none -cdrom archlinux-2023.07.25-x86_64.iso -nic bridge,br=br0 -m 8192 -smp cpus=4 -hda hd1.qcow2 --hdb hd2.qcow2 &
@johnlane
johnlane / dockbar-gtk2.py
Last active October 24, 2023 21:43
Example GTK to create a dock-like bar and strut
#!/usr/bin/env python2
#
# dockbar.py
#
# Example program places a coloured bar across the top of the
# current monitor
#
# demonstrates
#
# (a) creating the bar as an undecorated "dock" window

Injecting Terminal Input

Some examples demonstrating how to inject keystrokes into a terminal's input stream.

2022-10-03T09:29:04.494+0100 [INFO] Terraform version: 1.3.1
2022-10-03T09:29:04.494+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.9.0
2022-10-03T09:29:04.494+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.14.1
2022-10-03T09:29:04.494+0100 [DEBUG] using github.com/hashicorp/terraform-config-inspect v0.0.0-20210209133302-4fd17a0faac2
2022-10-03T09:29:04.494+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734
2022-10-03T09:29:04.494+0100 [DEBUG] using github.com/zclconf/go-cty v1.11.0
2022-10-03T09:29:04.494+0100 [INFO] Go runtime version: go1.19.1
2022-10-03T09:29:04.494+0100 [INFO] CLI args: []string{"terraform", "plan"}
2022-10-03T09:29:04.494+0100 [TRACE] Stdout is not a terminal
2022-10-03T09:29:04.494+0100 [TRACE] Stderr is not a terminal

The file not allowed in a Docker image

You cannot have a file in a Docker image with a name that starts with .wh.. Try this:

$ echo "files beginning .wh. are not allowed!" > test.txt
$ echo -e "FROM alpine:latest\nCOPY test.txt /.wh.test.txt" > Dockerfile
$ docker build -t johnlane/wontwork:latest .
@johnlane
johnlane / zk3d
Last active December 22, 2021 22:40
A wrapper for k3d for use with ZFS file systems
#!/bin/bash
# wrapper for k3d v3 usage on ZFS using Docker volumes
# JL20200603
# Usage: pass 'create' as the first argument to create a cluster
# pass 'destroy' (or anything else) to destroy a cluster
#
# The following optional arguments may be provided (in this order):
# second argument is the cluster name (k3d is prefixed to this)
# following arguments apply to create: masters workers
#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
#include <signal.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
--- gitweb.cgi.orig 2020-10-06 10:13:45.621810025 +0100
+++ gitweb.cgi 2020-10-06 10:08:21.651823286 +0100
@@ -18,9 +18,10 @@
use Encode;
use Fcntl ':mode';
use File::Find qw();
-use File::Basename qw(basename);
+use File::Basename qw(basename dirname);
use Time::HiRes qw(gettimeofday tv_interval);
use Digest::MD5 qw(md5_hex);
@johnlane
johnlane / Example Grub Module.md
Created July 6, 2015 13:08
Example GRUB Module

This is an example Grub module that demonstrates how to add a command to Grub that can process command-line options and other parameters.

@johnlane
johnlane / wysiwyg.js
Last active September 14, 2020 14:56
An integrated Markdown WYSIWYG editor
$(document).on('ready page:load ajaxComplete', function() {
$('textarea.wysiwyg').each(function() {
var textarea = $(this)
textarea.hide().uniqueId();
var textarea_id = textarea[0].id;
var textarea_class = textarea[0].className;
var wysiwyg_id = "wysiwyg_" + textarea_id;
var wysiwyg_class = textarea_class + " wysiwyg";