Skip to content

Instantly share code, notes, and snippets.

View mikroskeem's full-sized avatar
👻

Mark Vainomaa mikroskeem

👻
View GitHub Profile
use std::{
fs::File,
io::{Error, ErrorKind, Write},
os::{
fd::{AsRawFd, FromRawFd, OwnedFd},
unix::net::UnixStream,
},
path::Path,
process::Command,
};
@mikroskeem
mikroskeem / download-gh-release.yml
Created March 16, 2024 07:19
Download a private GitHub release using Ansible
---
- name: "Download a private GitHub release"
vars:
owner: "mikroskeem"
repo: "snakeoil"
tag: "v0.0.1"
asset_name: "snakeoil.x86_64-linux"
get_url_args:
dest: "/tmp/the-thing"
@mikroskeem
mikroskeem / vector-netconsole.yaml
Last active January 7, 2024 17:26
Use vector.dev to process Linux netconsole messages
---
# See https://www.kernel.org/doc/Documentation/networking/netconsole.txt
# Use e.g. `insmod netconsole.ko netconsole=+@/,[email protected]/` on the VM
# $ vector --version
# vector 0.34.2 (aarch64-unknown-linux-musl d685a16 2024-01-02 14:59:54.890517436)
sources:
in:
#type: "syslog" # does not work with netconsole
@mikroskeem
mikroskeem / deno.jsonc
Created November 13, 2023 10:05
ed25519 signing with Vault Transit engine
{
"imports": {
"$std/": "https://deno.land/[email protected]/",
"vault/": "https://raw.githubusercontent.com/restake/deno-hashicorp-vault/67b015694251a9f030bc419296c93e8900ebff84/",
"@noble/ed25519": "https://deno.land/x/[email protected]/mod.ts"
},
"fmt": {
"indentWidth": 4,
"lineWidth": 140
}
@mikroskeem
mikroskeem / inspect_svc.sh
Created August 23, 2023 15:11
Inspect systemd service namespace
#!/usr/bin/env bash
set -euo pipefail
svc="${1}"
pid="$(systemctl show --property MainPID --value "${svc}")"
user="$(systemctl show --property User --value "${svc}")"
uid="$(getent passwd "${user}" | cut -d: -f3)"
sudo nsenter -t "${pid}" -U -m -S "${uid}" /bin/bash -i
@mikroskeem
mikroskeem / docs.yml
Created August 3, 2023 12:25
Publish TypeDoc documentation to GitHub pages
name: "Publish documentation"
on:
push:
branches:
- "master"
jobs:
publish-documentation:
permissions:
id-token: "write"
@mikroskeem
mikroskeem / ldbus_systemd.lua
Created May 30, 2023 15:28
Example Lua script interfacing with systemd D-BUS service
-- nix-shell -p luajit luajitPackages.ldbus luajitPackages.inspect
local ldbus = require("ldbus")
local inspect = require("inspect")
local conn = assert(ldbus.bus.get("system"), "System bus connection failed")
function do_method_call(conn, destination, path, iface, method_name, args, f)
local msg = assert(ldbus.message.new_method_call(destination, path, iface, method_name), "Failed to create message")
local iter = ldbus.message.iter.new()
<script lang="ts">
import LazyImage from "$lib/components/LazyImage.svelte";
</script>
<style>
div.preview > :global(*) {
height: 320px;
width: 320px;
}
</style>
{"version":0,"class":"sysevent.fs.zfs.pool_create","pool":"tpool","pool_guid":11580135928063884441,"pool_state":0,"pool_context":6,"time":[1652401466,660179477],"eid":1}
{"version":0,"class":"sysevent.fs.zfs.history_event","pool":"tpool","pool_guid":11580135928063884441,"pool_state":0,"pool_context":6,"history_hostname":"noname","history_internal_str":"pool version 5000; software version zfs-macOS-2.1.0-0-ga3ba8b30c1; uts noname 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 ","history_internal_name":"create","history_txg":4,"history_time":1652401466,"time":[1652401466,660226311],"eid":2}
{"version":0,"class":"sysevent.fs.zfs.history_event","pool":"tpool","pool_guid":11580135928063884441,"pool_state":0,"pool_context":6,"history_hostname":"noname","history_internal_str":"feature@async_destroy=enabled","history_internal_name":"set","history_txg":4,"history_time":1652401466,"time":[1652401466,660330144],"eid":3}
{"version":0,"class":"sysevent.fs.zfs.
@mikroskeem
mikroskeem / gh_asset.sh
Created May 10, 2022 09:03
Download named GitHub asset by release name. Requires curl, jq and coreutils.
#!/usr/bin/env bash
set -euo pipefail
: "${GH_TOKEN}"
repo="${1}"
version="${2}"
name="${3}"
asset_url="$(curl -s -H "Accept: application/vnd.github.v3+json" -u "token:${GH_TOKEN}" "https://api.github.com/repos/${repo}/releases/tags/${version}" \