Skip to content

Instantly share code, notes, and snippets.

@kmkaplan
kmkaplan / identity.xslt
Created March 24, 2022 10:55
XSLT to pretty print XML
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform">
<output method="xml" indent="yes"/>
<template match="@*|node()">
<copy>
<apply-templates select="@*|node()"/>
</copy>
</template>
</stylesheet>
@kmkaplan
kmkaplan / dns_name.rs
Created February 26, 2022 18:21
Implementing `Deref` on my wrappre type in Rust
#[derive(Debug)]
struct MyDnsNameInner<T: ?Sized> {
data: T
}
type MyDnsName = MyDnsNameInner<[u8]>;
// This uses the technique documented in the
// [Rustonomicon](https://doc.rust-lang.org/nomicon/exotic-sizes.html#dynamically-sized-types-dsts)
fn reference() {
@kmkaplan
kmkaplan / career-tasks.js
Last active February 2, 2023 06:32
TAU station helper for doing career tasks
// ==UserScript==
// @name Tau Career tasks helper
// @namespace https://www.kim-minh.com/tau-career-tasks-helper
// @version 0.13.1
// @description Tau Station: Grind career tasks for KMK
// @author KMK
// @match https://taustation.space/*
// @require https://code.jquery.com/jquery-3.3.1.min.js
// @require https://github.com/taustation-fan/userscripts/raw/master/userscript-preferences.js
// @grant none
@kmkaplan
kmkaplan / dnsquery.c
Created December 3, 2020 16:40
Send and receive a DNS query
#include <netinet/ip.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define NAMESERVER_IP 0x01010101
int
@kmkaplan
kmkaplan / bdb-get.c
Last active January 19, 2019 10:51
Get an entry from a Berkley DB database.
/* Compile with: cc bdb-get.c -ldb */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db.h>
static DB_ENV *env = NULL;
static DB *db = NULL;
static DBT dkey, ddata;
@kmkaplan
kmkaplan / postinstall.sh
Last active June 21, 2018 12:54
Install Yunohost en postinstall Debian 9 sur OVH
#!/bin/sh
log=$(mktemp -p / postinstall-tmp.XXXXXXXXXX.log)
printf 'Logs go to %s\n' "$log" >&2
exec >>"$log" 2>&1
set -e
apt-get update -q
apt-get install -qy git
if test -d /etc/.git
then :
else
@kmkaplan
kmkaplan / prepare-btrfs.sh
Last active January 28, 2017 18:22
Prepare BTRFS volumes after install
#!/bin/sh
set -e
exec >>/installer.log 2>&1
date -u +'%Y-%m-%d %H:%M:%S'
random=$(hexdump -n 8 -e '/1 "%02x"' /dev/urandom)
tmpdir="/tmp/installer-$random"
mkdir "$tmpdir"
trap "rm -rf '$tmpdir'" 0
# Make a snapshot of all BTRFS volumes

Keybase proof

I hereby claim:

  • I am kmkaplan on github.
  • I am kmkaplan (https://keybase.io/kmkaplan) on keybase.
  • I have a public key whose fingerprint is 16FB 696F DC78 63EE DA8F 5A6A F846 9101 A8E1 5F04

To claim this, I am signing this object: