Skip to content

Instantly share code, notes, and snippets.

View mikroskeem's full-sized avatar
👻

Mark Vainomaa mikroskeem

👻
View GitHub Profile
{"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}" \
@mikroskeem
mikroskeem / generics.go
Created March 2, 2022 16:13
Doing weird stuff with Go generics
// ~/go/bin/go1.18beta2
package main
type Closeable interface {
Close() error
}
type CloseableChan[T any] struct {
ch chan T
}

Result of nixpkgs-review pr 152348 run on aarch64-darwin 1

4 packages failed to build:
  • geany-with-vte
  • germinal
  • gtkd
  • termite (termite-unwrapped)
@mikroskeem
mikroskeem / err.go
Last active March 1, 2022 15:33
Golang errors wrapping & finding specific error type
// tested with go1.16.12
package main
import (
"errors"
"fmt"
)
type RetryableError struct {
Cause error
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.endlessh;
in
{
options = {
services.endlessh = {
enable = mkEnableOption "endlessh daemon";
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <string.h>
#include <unistd.h>
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/vj2rm3yqx51isxic92n5fq0fwbyj9k31-source
source root is source
Executing cargoSetupPostUnpackHook
unpacking source archive /nix/store/hgfq41za09skzf22dz1m6whb428iavix-deno-1.16.2-vendor.tar.gz
Finished cargoSetupPostUnpackHook
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
Executing cargoSetupPostPatchHook
<?php
$site_url = 'http://time.d0.ee';
$tz = 'Europe/Tallinn';
header("Cache-Control: no-cache, must-revalidate");
header("Content-Security-Policy: frame-ancestors 'self'; default-src 'none'; style-src 'unsafe-inline';");
$ua = $_SERVER['HTTP_USER_AGENT'];
setlocale(LC_TIME, 'C');
@mikroskeem
mikroskeem / docker-network-ns.nix
Last active October 27, 2023 06:33
Stay using nftables in combination with Docker, and set up separate network namespace to make it happy.
{ pkgs, ... }:
# Based on https://wiki.archlinux.org/title/Nftables#Working_with_Docker
let
dockerHostName = "dockernet";
hostip = "${pkgs.util-linux}/bin/nsenter --target 1 --net -- ${ip}";
ip = "${pkgs.iproute2}/bin/ip";
dockerNsSetupScript = pkgs.writeShellScript "docker-netns-setup" ''