Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / Common Table Expressions.md
Last active June 10, 2026 09:23
MySQL Database: Core Fundamentals & Common Gotchas

Common Table Expressions

A Common Table Expression (CTE) in MySQL is a temporary result set that you can reference within a SELECT, INSERT, UPDATE, or DELETE statement.

Think of it as a temporary view that exists only for the duration of that single query. It allows you to write cleaner, more readable SQL by breaking down complex queries into smaller, modular building blocks.

CTEs were introduced in MySQL 8.0, so you will need that version or higher to use them.

The Basic Syntax

@Integralist
Integralist / Kubernetes Probes.md
Created June 1, 2026 16:44
Kubernetes Probes
  • livenessProbe: tells Kubernetes whether the container is still alive. If it fails repeatedly, Kubernetes restarts the container.
  • readinessProbe: tells Kubernetes whether the container is ready to receive traffic. If it fails, the pod stays running but is removed from Service load balancing.
  • startupProbe: tells Kubernetes whether the app has finished starting up. While it is still failing, Kubernetes suppresses liveness/readiness handling for slow-starting apps.

Typical behavior:

  • Use livenessProbe to detect deadlocks/hung processes.
  • Use readinessProbe to gate traffic until dependencies/init work are done.
  • Use startupProbe when startup is slow and you don’t want liveness to kill the app too early.

Simple mental model:

@Integralist
Integralist / go-test-flags-summary.md
Last active May 24, 2026 13:26
Go: Discoverable Test Config in Go with Flags (rednafi.com)

Discoverable Test Config in Go: Use Flags

Summary of rednafi.com/go/test-config-with-flags.

The article compares three ways to toggle tests in Go (snapshot, integration, real-vs-mock) and argues for custom flags.

1. Build tags — discouraged

//go:build snapshot
@Integralist
Integralist / go-shebang-summary.md
Last active May 24, 2026 13:17
Go 'shebang' trick — running .go files as scripts

Go "Shebang": Running Go Files as Scripts

Summary of lorentz.app: go-shebang by Lorentz Kinde (2025-12).

The trick

Prepend this line to a .go file, chmod +x, then run it directly:

//usr/local/go/bin/go run "$0" "$@"; exit
@Integralist
Integralist / Writing Guidelines.md
Created April 18, 2026 19:18
Writing Guidelines

Documentation Principles & Best Practices

The primary goal of documentation is to reduce friction for the reader. While the best starting point is simply ensuring a README.md exists, adhering to the following pillars will significantly improve the quality and longevity of your technical writing.

  1. Prioritize Brevity and Professionalism
  • Be Concise: Value the reader’s time. Use AI as a tool to trim wordy explanations and get straight to the point.
  • Maintain an Even Tone: Avoid letting personal frustrations or over-enthusiasm color the technical content. Aim for a "neutral-expert" voice that remains consistent from start to finish.
  1. Eliminate Assumptions
  • Define Your Terms: Never assume a concept is "common knowledge."
  • External Context: Use hyperlinks to Wikipedia or official documentation for industry terms, protocols, or third-party tools to ensure readers of all levels can follow along.
@Integralist
Integralist / main.go
Last active May 6, 2026 05:31
Go: unexported interface methods "seal" the interface support when embedding types
// This code demonstrates how you can embed a type,
// and have it satisfy an interface (`ProblemDetailer`)
// but only for the embedded type.
// This works because the interface uses an unexported method,
// that is part of the embedded type's package.
// https://go.dev/play/p/7lbikIyPHi1
//
// IMPORTANT: If the `isProblem` inteface method was exported (i.e `IsProblem`),
// then our `Fake` struct would pass the `.(errorsx.ProblemDetailer)` type assertion
// e.g. https://go.dev/play/p/pPD3OgtiyHx
@Integralist
Integralist / Prometheus Metrics.md
Last active March 13, 2026 14:20
Prometheus Metrics

Prometheus Metric Types: A Quick Reference

This guide explains the four core Prometheus metric types, including common "patterns" that might seem counter-intuitive at first glance.

1. Counter

Definition: A cumulative metric that represents a single monotonically increasing counter. Its value can only increase or be reset to zero on restart.

  • Best for: "How many times has X happened?"
  • Examples: Total HTTP requests, total errors, bytes received.
@Integralist
Integralist / HTML ASCII Encoding Reference.md
Created February 19, 2026 15:09
HTML ASCII Encoding Reference
@Integralist
Integralist / redirect.go
Created February 19, 2026 10:39
Go: trie redirects with wildcard support
// First complete match wins.
// Because exact children are tried before `*` which is tried before `**`.
// The most-specific rule wins without an explicit priority sort.
package redirect
import (
"fmt"
"strings"
)
@Integralist
Integralist / README.md
Created February 16, 2026 14:48
Go: ignore vendor directory for multi-language repo

In a multi-language repository—for example, one that includes both Go and Ruby—you can run into conflicts around the vendor/ directory. Ruby commonly uses a vendor/ directory to store dependencies, but Go’s toolchain assumes that a vendor/ directory follows its own vendoring format (including the modules.txt file that defines vendored modules).

If Ruby’s vendor/ directory is present, the Go toolchain may attempt to interpret it as a Go vendoring directory, leading to unexpected errors.

To prevent this, configure Go to use module mode explicitly and ignore the vendor/ directory (which, in this case, is only relevant to Ruby):

  • Add -mod=mod to commands such as go build and go test.
  • Set a global flag with export GOFLAGS=-mod=mod for commands like go tool that do not expose a -mod flag directly.