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 / Remove ASCII escape codes from delta.sh
Created December 1, 2025 18:10
Remove ASCII escape codes from delta
# use perl to strip ASCII escape codes so we can copy delta's diff output
# this is because unlike `git diff` there is no `--no-color` flag.
# and using the classic `diff` is just hard to decipher
delta foo.yaml bar.yaml | perl -pe 's/\x1b\[[0-9;]*[mK]//g' | pbcopy
@Integralist
Integralist / gh-cli-pr-merged-analysis.sh
Last active November 13, 2025 17:36
Merged PRs Analysis #shell #jq #github #cli
gh pr list --repo whatever/example -s merged -L 4666 --search "merged:>2025-05-13" --json author,mergeCommit,number,title,createdAt | jq -r '.[] | select(
(
(.title | startswith("build(deps)")) or
(.title | startswith("bump:")) or
(.title | startswith("build: bump")) or
(.title | startswith("Data update"))
) | not
) | "• \(.title) (\(.number)) -- \(.author.name)"'
@Integralist
Integralist / 4-backticks.md
Created November 10, 2025 18:05
Markdown code block that contains a code block

Use 4 backticks to create a markdown code block that itself contains a code block...

# Some title

This is my __markdown__ file.

## Code Example

Here is a code example:
@Integralist
Integralist / Interface Boxing.md
Created October 24, 2025 17:25
Go: Interface Boxing #perf

In Go, when you convert a concrete value (like a number or a struct) into an interface type, it's called interface boxing. This can sometimes cause performance problems because it can lead to hidden memory allocations on the heap, extra copying of data, and more work for the garbage collector. This is especially true for performance-critical code.

How it Works

An interface in Go is made up of two parts: a type descriptor and a data pointer. When you assign a value that isn't a pointer to an interface, Go might have to make a copy of that value on the heap. This can be slow and use a lot of memory, especially if you're working with large data structures.

The Problem

@Integralist
Integralist / Object Pooling.md
Last active October 24, 2025 17:22
Go: Object Pooling #perf

Object pooling helps reduce allocation churn in high-throughput Go programs by reusing objects instead of allocating fresh ones each time. This avoids repeated work for the allocator and eases pressure on the garbage collector, especially when dealing with short-lived or frequently reused structures.

Go's sync.Pool provides a built-in way to implement pooling with minimal code. It's particularly effective for objects that are expensive to allocate or that would otherwise contribute to frequent garbage collection cycles. While not a silver bullet, it's a low-friction tool that can lead to noticeable gains in latency and CPU efficiency under sustained load.

Object pooling allows programs to reuse memory by recycling previously allocated objects instead of creating new ones on every use. Rather than hitting the heap each time, objects are retrieved from a shared pool and returned once they're no longer needed.

@Integralist
Integralist / macOS Utilities.md
Last active October 21, 2025 14:51
macOS /usr/bin Utilities Summary

macOS /usr/bin Utilities Summary

This file lists each binary currently found in /usr/bin on this system (snapshot from ls /usr/bin) with a brief, high‑level description. Many are standard POSIX / BSD userland tools; others are Apple platform, developer, diagnostic, multimedia, DTrace scripts, Perl helper scripts, or language/runtime tools. Versioned duplicates (e.g. foo5.34) are Perl 5.34 module helper variants; they perform the same function for that specific interpreter version.

Note

Descriptions are concise and generalized. For authoritative detail consult man <tool> or --help.

Index

  • aa – ASCII art / legacy utility placeholder (rarely used)
@Integralist
Integralist / main.go
Last active October 17, 2025 13:34
Go: generate Private Key and CSR
// https://go.dev/play/p/nDnCcCkMlFj
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/x509"
"encoding/pem"
"fmt"
@Integralist
Integralist / main.go
Created October 16, 2025 11:20
Go: fmt indexing
package main
import "fmt"
func main() {
fmt.Printf("%[1]s %[1]s %[2]s %[2]s %[3]s", "one", "two", "three") // yields "one one two two three"
}
@Integralist
Integralist / main.go
Created October 9, 2025 11:49
Go URL filter query parsing
package main
import (
"fmt"
"net/http"
"net/url"
)
func main() {
// Simulate a URL with filter parameters
@Integralist
Integralist / README.md
Last active October 2, 2025 11:11
Go API Optional Fields

Handling Optional and Nullable Fields

The API uses the optional package to distinguish between three states for a field in a JSON payload:

  1. Omitted: The field is not present in the JSON request body.
  2. Set to null: The field is present with an explicit null value (e.g., "description": null). This is used to unset or clear a field's value.
  3. Set to a value: The field is present with a non-null value (e.g., "description": "my description" or "description": "").
type Input struct {
	Description optional.String `json:"description"`