Skip to content

Instantly share code, notes, and snippets.

View rluders's full-sized avatar
🤓
be !false

Ricardo Lüders rluders

🤓
be !false
View GitHub Profile
@rluders
rluders / README.go
Created January 9, 2026 15:25
Angelica Polkadot Counter for fun
# Polkadot Score Counter
This Gist contains a self-contained Go program to calculate a "Polkadot score" from an ASCII art input.
## The Solution
The program reads ASCII art from standard input and calculates a score based on the following logic:
- It identifies a "lips" area, defined by a run of tildes (`~`) followed by an apostrophe (`'`).
- It counts the number of 'O' characters that fall "inside" and "outside" this lips area.
- It counts the number of "pupils", represented by `()` tokens.
@rluders
rluders / encode.go
Created January 4, 2026 17:27
An idiomatic, high-performance Base62 encoder for uint64 in Go. It avoids string concatenation by using a fixed-size byte buffer, achieving O(n) time complexity with zero heap allocations, and includes clear comments plus a table-driven, TDD-friendly unit test.
package base62
// base62Chars is the Base62 alphabet.
// Keeping it as a string is fine: it's immutable and indexable.
const base62Chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
// Encode converts a uint64 number into a Base62-encoded string.
func Encode(num uint64) string {
// Special case:
// If the input is 0, return the first character of the alphabet.
@rluders
rluders / main.go
Last active December 31, 2025 14:41
A simple, idiomatic Go implementation of the Monty Hall problem with clean structure, input validation, and minimal state.
// NOTE:
// Revision 1 contains a much simpler and more idiomatic version of this program.
// Revision 2 intentionally over-engineers the solution using an event bus and channels.
// This revision exists mostly as a joke and as an experiment in architecture, not as
// a recommendation for how to write small Go programs.
package main
import (
"bufio"
"context"
@rluders
rluders / ControlManager.cs
Last active June 22, 2025 19:00
Godot Flow Field Experiment
using Godot;
using System;
using System.Collections.Generic;
/// <summary>
/// Controls spawning and movement of a large number of units using Flow Field Navigation.
/// </summary>
public partial class ControlManager : Node
{
[Export] public PackedScene UnitScene;
@rluders
rluders / main.go
Created May 4, 2025 19:23
SQLx Cached Prepared Statement for Repository Pattern
// README: https://medium.com/@rluders/prepared-statement-caching-in-go-repositories-with-sqlx-a-professional-pattern-43a1fcdb7ed8
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/mattn/go-sqlite3"
[alias]
ci = commit
co = checkout
cm = checkout master
cb = checkout -b
st = status -sb
sf = show --name-only
lg = log --pretty=format:'%Cred%h%Creset %C(bold)%cr%Creset %Cgreen<%an>%Creset %s' --max-count=30
incoming = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' ..@{u})
outgoing = !(git fetch --quiet && git log --pretty=format:'%C(yellow)%h %C(white)- %C(red)%an %C(white)- %C(cyan)%d%Creset %s %C(white)- %ar%Creset' @{u}..)