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 /
Created May 22, 2024 08:17
[Rename files matching specific pattern] #shell #bash #macos #files #rename
# Iterate over each MP4 file in the current directory
for file in *.mp4; do
# Check if the file matches the pattern: MMDDYYYY <NAME>.mp4
if [[ "$file" =~ ^([0-9]{2})([0-9]{2})([0-9]{4})\ (.*)\.mp4$ ]]; then
# Extract the parts of the filename
Integralist /
Created May 15, 2024 09:10
[Proxy HTTP requests through a SSH connection via SOCKS5 proxy] #ssh #proxy #tunnel

Essentially your local machines creates a SOCK5 proxy which connects to a remote server via SSH (using either username/password or SSH PKI Cert/Key combination).

The SOCK5 proxy handles sending the HTTP request via the SSH tunnel.

The remote server will automatically process the HTTP request and handle sending it to its intended destination.

The upstream (i.e. the endpoint being requested) will see the request coming from the SSH server and presume that's where it originated.

Integralist /
Created May 13, 2024 15:10
[Highligh notes and warnings in Markdown] #gist #github #notes
Integralist / .editorconfig
Created May 8, 2024 13:44
[Example Editor Config] #editorconfig
root = true
indent_size = 2
charset = utf-8
end_of_line = lf
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
Integralist / Different Testing
Created April 29, 2024 09:03
[Different Testing Styles] #tests #terminology #system

Unit test

Specify and test one point of the contract of single method of a class. This should have a very narrow and well defined scope. Complex dependencies and interactions to the outside world are stubbed or mocked.

Integration test

Test the correct inter-operation of multiple subsystems. There is whole spectrum there, from testing integration between two classes, to testing integration with the production environment.

Acceptance test

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 (
// Decorator is a middleware function.
type Decorator func(http.Handler) http.Handler
Integralist /
Created March 25, 2024 10:30

Integralist /
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 / main.go
Created March 7, 2024 10:26
[Go convert JSON types when unmarshalling] #go #golang #json #unmarshal
package main
import (
func main() {
var jsonBlob = []byte(`[
{"str": "Foo", "num": "1", "bool": "true", "its": 3},
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.
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
# @:$(call check_defined, ENV_REGION, you must set ENV_REGION=usc1|awsuse2)