Skip to content

Instantly share code, notes, and snippets.

View KaiserWerk's full-sized avatar

R. Kaiser KaiserWerk

  • Germany
View GitHub Profile
@KaiserWerk
KaiserWerk / llm_client.go
Last active June 5, 2026 12:26
Golang OpenAI HTTP API Client
// Client sends requests to an OpenAI-compatible chat-completions endpoint.
type Client struct {
cfg *configuration.AppConfig
httpClient *http.Client
}
// NewClient creates a new LLM client with the given configuration.
func NewClient(cfg *configuration.AppConfig) *Client {
return &Client{
cfg: cfg,
@KaiserWerk
KaiserWerk / messaging.go
Created October 5, 2025 23:57
Message passing in templates
package templating
import (
"encoding/base64"
"net/http"
"time"
"reload-helper/internal/global"
)
@KaiserWerk
KaiserWerk / env.go
Created July 26, 2025 12:17
Load env vars from file (typically .env)
func loadEnvVars(filename string) {
file, err := os.Open(filename)
if err != nil {
log.Fatalf("failed to open env file: %v", err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
@KaiserWerk
KaiserWerk / coding-guidelines.md
Last active July 6, 2025 09:41
Coding guidelines summary for C#

Coding Guidelines (C#)

A summary of the official Microsoft C# coding conventions, based on Microsoft’s documentation.


1. Naming Conventions

  • PascalCase for class, property, method, and namespace names
    public class MyExampleClass { }
@KaiserWerk
KaiserWerk / authorize.html
Last active August 18, 2024 15:10
Quick and dirty example for a discord social login with Golang
<!doctype html>
<html>
<head>
</head>
<body>
<h2>Discord login</h2>
Token: {{ .Token }}
@KaiserWerk
KaiserWerk / main.go
Created September 12, 2022 20:49
Custom JSON (Un)Marshaler in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net/url"
"strings"
)
@KaiserWerk
KaiserWerk / README.md
Created August 21, 2022 23:19
Golang benchmark testing different HTTP router implementations

Please observe the difference in speed when calling resp.Body.Close().

@KaiserWerk
KaiserWerk / main.go
Created June 25, 2022 15:21
A tiny tool to generate a selectable number of Loprem Ipsum paragraphs.
package main
import (
"fmt"
"os"
"strconv"
)
var (
paragraphs = []string{
@KaiserWerk
KaiserWerk / Program.cs
Created May 9, 2022 17:44
C#: De- and Encryption using RSA
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Encodings;
using Org.BouncyCastle.Crypto.Engines;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System.Text;
namespace RSATest
@KaiserWerk
KaiserWerk / certmaker-bot.service
Last active December 16, 2021 14:06
Homelab Service unit templates
[Unit]
Description=CertMaker Bot (to cover your cert needs)
After=network.target
[Service]
Type=simple
ExecStart=/home/certmaker-bot/bin/certmaker-bot
WorkingDirectory=/home/certmaker-bot/bin
User=certmaker-bot
Group=certmaker-bot