Skip to content

Instantly share code, notes, and snippets.

View kwilczynski's full-sized avatar
🍀

Krzysztof Wilczyński kwilczynski

🍀
  • Yokohama, Japan
  • 22:05 (UTC +09:00)
View GitHub Profile
@kwilczynski
kwilczynski / main.go
Created June 12, 2023 12:26
ZooKeeper TLS in Go example
package main
import (
"crypto/dsa"
"crypto/ecdsa"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"flag"
@kwilczynski
kwilczynski / cidr-to-netmask.sh
Last active February 24, 2026 19:24
CIDR to netmask in bash.
# Return netmask for a given network and CIDR.
cidr_to_netmask() {
value=$(( 0xffffffff ^ ((1 << (32 - $1)) - 1) ))
echo "$(( (value >> 24) & 0xff )).$(( (value >> 16) & 0xff )).$(( (value >> 8) & 0xff )).$(( value & 0xff ))"
}
@kwilczynski
kwilczynski / disable-ipv6.sh
Last active December 22, 2025 00:41
Amazon Linux OS tweaks
#!/bin/bash
set -u
set -e
set -o pipefail
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cat <<'EOF' > /etc/modprobe.d/blacklist-ipv6.conf
@kwilczynski
kwilczynski / binary.rb
Last active November 24, 2025 10:25
Example Homebrew formula for a Go command-line (CLI) binary
class Binary < Formula
desc ""
homepage ""
head do
url "", branch: "main"
depends_on "go@1.14" => :build if build.head?
end
@kwilczynski
kwilczynski / route53-hosted-zone.json
Last active November 1, 2025 22:37
Route53 Hosted Zone - CloudFormation
{
"AWSTemplateFormatVersion":"2010-09-09",
"Description":"A CloudFormation template for creating a Hosted Zone in Route53.",
"Parameters":{
"Name":{
"Description":"A fully-qualified domain name.",
"Type":"String",
"MinLength":"1",
"MaxLength":"64",
"AllowedPattern":"(?!-)[a-zA-Z0-9-.]*(?<!-)",
// Based on https://github.com/ericwbailey/millennials-to-snake-people.
function walkTextNodes(rootNode) {
let walker = document.createTreeWalker(rootNode, NodeFilter.SHOW_TEXT,
function(node) {
if (node.textContent.length === 0) {
return NodeFilter.FILTER_SKIP;
}
return NodeFilter.FILTER_ACCEPT
},
@kwilczynski
kwilczynski / trailers.txt
Last active March 26, 2025 06:15
Linux kernel tag (trailers) order
* PCI legacy (from https://lore.kernel.org/all/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com):
Fixes:
Closes: (link or Message-ID]
Suggested-by:
Link:
Reported-by:
Tested-by:
Co-developed-by: (co-author)
Signed-off-by: (co-author)
@kwilczynski
kwilczynski / check.md
Last active February 3, 2025 05:27
Recipe / Role check in Chef

If you want to check whether a node run_list includes a specific role (upon expansion), then you could use role? method on the Node object:

node.role?('name')

Alternatively, you can see whether either would work for you:

node.roles.include?('name')

node.run_list?('role[name]')

Jan 11 11:48:06 rocinante kernel: [17610.105025] amdgpu 0000:03:00.0: amdgpu: Dumping IP State
Jan 11 11:48:06 rocinante kernel: [17610.106837] amdgpu 0000:03:00.0: amdgpu: Dumping IP State Completed
Jan 11 11:48:06 rocinante kernel: [17610.106864] amdgpu 0000:03:00.0: amdgpu: ring sdma0 timeout, signaled seq=165765, emitted seq=165768
Jan 11 11:48:06 rocinante kernel: [17610.106867] amdgpu 0000:03:00.0: amdgpu: GPU reset begin!
Jan 11 11:48:06 rocinante kernel: [17610.106918] amdgpu 0000:03:00.0: amdgpu: Failed to disallow df cstate
Jan 11 11:48:06 rocinante kernel: [17610.137182] ------------[ cut here ]------------
Jan 11 11:48:06 rocinante kernel: [17610.137183] WARNING: CPU: 18 PID: 2156760 at drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:631 amdgpu_irq_put+0x9f/0xb0 [amdgpu]
Jan 11 11:48:06 rocinante kernel: [17610.137349] Modules linked in: uhid rfcomm cmac algif_hash algif_skcipher af_alg xt_conntrack nft_chain_nat xt_MASQUERADE nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 bridge stp llc xfrm_user xfrm
@kwilczynski
kwilczynski / test.c
Last active December 17, 2024 16:48
Test for AES NI in the CPU.
#include <stdio.h>
int main (int argc, char **argv)
{
unsigned int eax, ebx, ecx, edx;
asm(
"xchg{l}\t{%%}ebx, %1\n\t" \
"cpuid\n\t" \
"xchg{l}\t{%%}ebx, %1\n\t" \