Skip to content

Instantly share code, notes, and snippets.

@jk
jk / kubectl-get-shortnames.sh
Created June 12, 2024 08:53
Get a sorted list of kubectl get shortnames
kubectl api-resources --no-headers | awk -F' ' '{if (NF == 5) {shortname=$2; name=$1; kind=$5} else if (NF == 4) {shortname=""; name=$1; kind=$4} else {shortname=$2; name=$1; kind=$4} if (shortname != "") print shortname "\t" name "\t" kind}' | sort | uniq | column -t
@jk
jk / check_etchosts.sh
Last active May 24, 2024 08:59
Shell script to check syntax of /etc/hosts
#!/bin/zsh
# Function to validate each line of /etc/hosts
validate_line() {
local line="$1"
# Regular expression to match valid IP address and hostname entries, including comments
if [[ "$line" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}([[:space:]]+([a-zA-Z0-9.-]+,?)+)+$ ]] || [[ "$line" =~ ^::1([[:space:]]+([a-zA-Z0-9.-]+,?)+)+$ ]] || [[ "$line" =~ ^#.* ]]; then
echo "Valid: $line"
else
echo "Invalid: $line"
@jk
jk / !README.md
Created April 22, 2024 09:02
Generate IPv6 address from IPv6 prefix and interface's MAC address

Generate IPv6 address from IPv6 prefix and interface's MAC address

More or less like what SLAAC is doing, but without relying on the router advertisment.

Installation

pip install netifaces
@jk
jk / keybase.md
Created July 5, 2023 19:09
keybase.md

Keybase proof

I hereby claim:

  • I am jk on github.
  • I am jenskohl (https://keybase.io/jenskohl) on keybase.
  • I have a public key ASCJQngNFVFpJ0E9EF6huIW-XMK7ylP7mUlcTa0jMKgpbAo

To claim this, I am signing this object:

@jk
jk / kagi-summarizer-bookmarklet.js
Created February 12, 2023 12:23
Kagi Universal Summarizer Bookmarklet for every Browser that supports it
javascript:q=location.href;if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;void(open('https://labs.kagi.com/ai/sum?url='+encodeURIComponent(q),'Kagi Universal Summarizer','toolbar=no,width=710,height=685'));
@jk
jk / docker-compose.yml
Created May 25, 2022 11:12
Traefik docker-compose network settings
version: '3.8'
services:
traefik:
image: traefik:v2.5.0-rc2
container_name: traefik
restart: always
environment:
- TZ=Asia/Taipei
ports:
@jk
jk / regex.txt
Created September 14, 2021 12:05
YouTrack Issue Number RegEx
/\b[A-Z_0-9]+-[1-9]\d?\b/gmi
@jk
jk / sodium.php
Created March 16, 2021 14:06
Sodium Test
<?php
if (sodium_crypto_aead_aes256gcm_is_available()) {
echo 'sodium_crypto_aead_aes256gcm_is_available is true'.PHP_EOL;
} else {
echo 'sodium_crypto_aead_aes256gcm_is_available is false'.PHP_EOL;
}
//echo 'Generated key with sodium_crypto_aead_aes256gcm_keygen is: ' . sodium_crypto_aead_aes256gcm_keygen() . PHP_EOL;
$msg = '[email protected]';
@jk
jk / gitlab-ci.yml
Created December 18, 2020 13:11
Run JetBrains Qodana on GitLab CI
qodana:
stage: report
image:
name: jetbrains/qodana:latest
entrypoint: ["/usr/bin/bash", "-l", "-c"]
needs:
- composer-prod
script:
- ln -sf $CI_PROJECT_DIR/ /data/project
- /opt/idea/bin/entrypoint --save-report
@jk
jk / Dockerfile
Last active April 22, 2020 11:50
glove
FROM nvidia/cuda:10.0-base-ubuntu18.04
# See http://bugs.python.org/issue19846
ENV LANG C.UTF-8
LABEL com.nvidia.volumes.needed="nvidia_driver"
RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libc6-dev \