Skip to content

Instantly share code, notes, and snippets.

View gdamjan's full-sized avatar

Дамјан Георгиевски gdamjan

View GitHub Profile
@gdamjan
gdamjan / README.md
Last active April 21, 2025 17:13 — forked from gdamjan-loka/README.md
Local Docker registry running in Kubernetes / k3s

Install a docker registry in a k3s kubernetes cluster

k3s doesn't have a builtin plugin for a local registry, so this is how to install the docker registry. The registry will be exposed via the default traefik ingress (on port 80 and 443).

Assumptions

  • resolvectl query registry.localhost returns 127.0.0.1 - on most Linux distros it does. If not, enable and configure systemd-resolved
  • K3s comes with traefik ingress controller by default, so the ingress for the registry service is configured for that.
@gdamjan
gdamjan / ssh-agent.service
Created August 11, 2023 18:11
ssh-agent.service
[Unit]
Description=SSH key agent
Documentation=man:ssh-agent(1)
# Configure ssh to use the socket:
# cat ~/.ssh/config
# Host *
# IdentityAgent ${XDG_RUNTIME_DIR}/ssh-agent.socket
# ...
#
# /etc/soju/config
# only accept connections from nginx, so insecure is fine
accept-proxy-ip localhost
listen irc+insecure://127.0.0.1:12000
listen ws+insecure://127.0.0.1:12001
hostname <my-hostname>
@gdamjan
gdamjan / default-2.nix
Last active July 30, 2023 12:34
matrix-appservice-irc nix build
# nix-build -E 'with import <nixpkgs> {}; callPackage ./default-2.nix {}'
{ stdenv
, fetchFromGitHub
, fetchYarnDeps
, fixup_yarn_lock
, nodejs
, nodejs-slim
, matrix-sdk-crypto-nodejs
}:
@gdamjan
gdamjan / README.md
Last active March 24, 2025 08:55
fastapi and proxies

Quickstart

pdm install

These are equivalent (given the main.py code)

UVICORN_ROOT_PATH=/api/ pdm run uvicorn main:app
FASTAPI_ROOT_PATH=/api/ pdm run uvicorn main:app
@gdamjan
gdamjan / zz-update-systemd-boot
Last active June 20, 2025 15:12
kernel postinstall script to update systemd-boot on debian/ubuntu
#!/bin/bash
#
# /etc/kernel/postinst.d/zz-update-systemd-boot
# 0755 root:root
#
# This is a simple kernel hook to populate the systemd-boot entries
# whenever kernels are added or removed.
#
set -euo pipefail
@gdamjan
gdamjan / pleroma.service
Last active December 15, 2022 18:18
pleroma setup
# /etc/systemd/system/pleroma.service
[Unit]
Description=Pleroma is a federated social networking platform
Documentation=https://docs-develop.pleroma.social/
After=network.target
[Service]
Type=simple
DynamicUser=yes
StateDirectory=pleroma
@gdamjan
gdamjan / fetch-continuous-stream.js
Last active June 26, 2023 00:41
fetch couchdb changes as stream
function asContinuousEventStream() {
const transformer = {
start() {
this.buffer = "";
},
transform(chunk, controller) {
this.buffer += chunk;
while (true) {
// parse full lines only
const [line, sep, rest] = this.buffer.split(/(\n)/, 3);
[package]
name = "rust-cgi"
version = "0.1.0"
edition = "2021"
[dependencies]
hyper_cgi= "22.4.15"
hyper = "0.14.23"
tokio = "1.21.2"
@gdamjan
gdamjan / default.nix
Last active December 27, 2025 05:40
A demo "Portable Service" for a shell program built with nix - https://systemd.io/PORTABLE_SERVICES/
{ pkgs ? import <nixpkgs> { } }:
let
demo-program = pkgs.writeShellScriptBin "helloWorld" "while sleep 3; do echo Hello World; done";
demo-service = pkgs.substituteAll {
name = "demo.service";
src = ./demo.service.in;
demoExe = "${demo-program}/bin/helloWorld";
};
demo-socket = pkgs.concatText "demo.socket" [ ./demo.socket ];