Skip to content

Instantly share code, notes, and snippets.

View mikeschinkel's full-sized avatar

Mike Schinkel mikeschinkel

View GitHub Profile
@mikeschinkel
mikeschinkel / mv-jetbrains-ide-project.sh
Created March 31, 2025 20:45
Bash script to rename the directory a JetBrain's IDE project is contained in (I got tired of waiting for JetBrains to add this obviously needed feature to their actual IDE!)
#!/usr/bin/env bash
set -euo pipefail
# Check if both arguments are provided
if [ $# -ne 2 ]; then
echo "Rename a Jetbrains IDE project"
echo "Usage:"
echo " $(basename "$0") <old_project_name> <new_project_name> [<projects_dir default=~/Projects>]"
exit 1
@mikeschinkel
mikeschinkel / _LOGGER_FOR_GOLANG.md
Last active March 30, 2025 06:10
Go logging package that leverages slog.Default() for creating package-level loggers (Proof-of-concept)

This solution is built on top of Go's log/slog package and leverages slog.Default(). To use it a developer should declare a package variable logger in every package that is part of their Go project that needs to perform logging (e.g. a package containing only type, var and/or const declarations would usually not need a logger.go file.)

Add a logger.go file to every packages and then add this line to the file, updating it with the package's name:

var logger = logging.NewPackageLogger("<package_name>")    

This uses a small logging package you can find below which has a Logger type simply to embed slog.Log. This allows adding extra methods beyond that provided by slog.Logger and to preprocess calls to *slog.Logger if we later find that to be needed.

@mikeschinkel
mikeschinkel / membership_test.go
Last active March 19, 2025 12:09
Test for Peformance of SwitchCase vs. IfOr vs. Generic for Determining Membership in Golang
package main_test
import (
"testing"
)
type Lexer struct {
input string // the string being scanned.
pos int // current position in the input.
}
// readType reads a type from r at off of name. It adds types to the
// type cache, appends new typedef types to typedefs, and computes the
// sizes of types. Callers should pass nil for typedefs; this is used
// for internal recursion.
func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Offset]Type, fixups *typeFixer) (t Type, err error) {
var e *Entry
var ok bool
var addressSize int
var typ Type
var nextDepth int
// readType reads a type from r at off of name. It adds types to the
// type cache, appends new typedef types to typedefs, and computes the
// sizes of types. Callers should pass nil for typedefs; this is used
// for internal recursion.
func (d *Data) readType(name string, r typeReader, off Offset, typeCache map[Offset]Type, fixups *typeFixer) (t Type, err error) {
var e *Entry
var ok bool
var addressSize int
var typ Type
var nextDepth int
@mikeschinkel
mikeschinkel / resume.json
Last active March 24, 2025 22:55
Mike Schinkel's resume — Last updated 2025-03-24 — Also see github.com/mikeschinkel/resume for more recent updates
{
"meta": {
"theme": "kendall"
},
"basics": {
"name": "Mike Schinkel",
"label": "Senior Engineer specializing in Go, OpenAPI, Kubernetes, AWS, and CI/CD",
"photo": "https://www.gravatar.com/avatar/c988a2da603a19e827a39ab4d9186909?s=200&r=pg&d=mm",
"summary": "I am looking a long-term contract role working to enhance software products where my unique set of Go development, OpenAPI, Kubernetes AWS, and CI/CD skills and experience can have a big impact. And I will be really excited if the project I get to work on is open source.",
"location": {
package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"mime"
"net/http"
"net/url"
@mikeschinkel
mikeschinkel / main.go
Last active February 2, 2025 14:27
Hypothetical example illustrating Golang issue #70257 along with goto error handling
package main
import (
"encoding/json"
"errors"
"fmt"
"io"
"mime"
"net/http"
"net/url"
@mikeschinkel
mikeschinkel / main.go
Last active January 29, 2025 05:40
Example use-case for github.com/micromdm/plist where `UnmarshalPlist()` needs access to `pval`
package main
import (
"bytes"
"fmt"
"os"
"github.com/micromdm/plist"
)
@mikeschinkel
mikeschinkel / Dockerfile
Last active July 26, 2024 01:21
Statamic — Dockerfile and compose; FILES SHOWN DO NOT WORK, see the _README.md for the working solution.
# Use an official PHP image with FPM
FROM php:8.3-fpm
LABEL authors="gearbox.works"
ENV LARAVEL_STORAGE_PATH=/var/statamic/storage
# PHP Extension Installer
COPY --from=mlocati/php-extension-installer \
/usr/bin/install-php-extensions \