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 / 1. middleware.go
Last active March 27, 2024 12:03
[Go basic middleware abstraction] #go #golang #middleware
// THIS IS THE REDESIGNED VERSION (see 3. middleware.go for my original approach)
package middleware
import (
"net/http"
)
// Decorator is a middleware function.
type Decorator func(http.Handler) http.Handler
@Integralist
Integralist / OSI.md
Created March 25, 2024 10:30
[OSI] #OSI

@Integralist
Integralist / README.md
Last active March 14, 2024 13:52
[Docker Go Image with mounted files] #docker #go #golang #image #container #mount

Start with a Dockerfile:

FROM golang:latest

RUN apt-get update -y && apt-get install git -y

CMD ["/bin/bash"]
@Integralist
Integralist / main.go
Created March 7, 2024 10:26
[Go convert JSON types when unmarshalling] #go #golang #json #unmarshal
package main
import (
"encoding/json"
"fmt"
)
func main() {
var jsonBlob = []byte(`[
{"str": "Foo", "num": "1", "bool": "true", "its": 3},
@Integralist
Integralist / Makefile
Created March 1, 2024 10:48
[Check if Makefile target is called with a required input arg] #Makefile #make
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# PARAMS:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# EXAMPLE:
# @:$(call check_defined, ENV_REGION, you must set ENV_REGION=usc1|awsuse2)
#
@Integralist
Integralist / Install Windows on macOS with VirtualBox.md
Created February 29, 2024 10:42
[Install Windows on macOS with VirtualBox] #virtualbox #vm #windows
@Integralist
Integralist / 1. README.md
Last active March 8, 2024 13:01
[Fastly create, validate, and destroy service] #CLI #Fastly

Compute readthrough cache validator

This directory contains a Compute application that proxies incoming requests onto https://http-me.glitch.me/.

There is a run.sh script which will attempt to validate the

@Integralist
Integralist / Makefile
Last active February 23, 2024 13:15
[Download latest GitHub Asset Release] #github #asset #release
.PHONY: bin-viceroy
bin-viceroy: # Download latest version of Viceroy to ./bin/ directory
@arch=$$(uname -m | sed 's/x86_64/amd64/'); \
os=$$(uname -s | tr '[:upper:]' '[:lower:]'); \
url=$$(curl -s https://api.github.com/repos/fastly/viceroy/releases/latest | jq --arg arch $$arch --arg os $$os -r '.assets[] | select((.name | contains($$arch)) and (.name | contains($$os))) | .browser_download_url'); \
filename=$$(basename $$url); \
curl -sLO $$url && mkdir -p bin && tar -xzvf $$filename --directory ./bin/ && \
./bin/viceroy --version && rm $$filename && sudo cp ./bin/viceroy /usr/local/bin/viceroy # NOTE: sudo is a no-op in GitHub Actions
@Integralist
Integralist / main.go
Created February 9, 2024 10:30
[Go type cast] #go #golang
// https://play.golang.com/p/fLovZCiAzn1
package main
import (
"fmt"
)
type myString string
func main() {
@Integralist
Integralist / 1. README.md
Last active March 20, 2024 09:04
[Golang slog structure logging] #go #golang #log #logging #structuredlogs