Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile
@magnetikonline
magnetikonline / README.md
Last active May 12, 2023 21:59
macOS - Install The Silver Searcher (`ag`) from source.

Install The Silver Searcher (ag) on macOS from source

A quick n' dirty bash script to install the following:

  • automake, pkg-config, PCRE, xz - all needed by ag configure.
  • ag - from source.

Requires as a minimum Xcode CLI tools (don't need a full Xcode install). Can be done via the following:

$ xcode-select --install
@magnetikonline
magnetikonline / README.md
Last active November 28, 2020 04:06
Golang net/http middleware flow.

Golang net/http middleware flow

$ go run main.go
Called middleware03()
Called middleware02()
Called middleware01()
Called initial()
@magnetikonline
magnetikonline / README.md
Last active April 21, 2025 23:37
Access Golang private modules within a GitHub organization.

Golang private modules within a GitHub organization

You've got Golang modules within a private repository or an organization and would like to go get them.

For this example the GitHub organization will be spacely-sprockets.

Howto

Set GOPRIVATE (ideally placed in your .bashrc / dotfiles):

@magnetikonline
magnetikonline / README.md
Last active December 10, 2023 10:54
Find latest non beta/RC release for Docker CLI

Find latest non beta/RC release for Docker CLI

Using curl and jq to:

  • Pull list of GitHub release tags.
  • Filter out all that don't match vX.Y.Z (stripping beta/rc).
  • Finally return just the first entry (latest tag).
$ curl --silent \
@magnetikonline
magnetikonline / README.md
Last active November 14, 2025 13:00
Creating a 'run once' systemd unit.

Creating a 'run once' systemd unit

Systemd unit template which calls a script exactly once upon startup and keeps unit status active after script finishes.

Unit file placed in /etc/systemd/system and enabled with:

$ sudo systemctl enable runonce.service
$ sudo systemctl start runonce.service
@magnetikonline
magnetikonline / README.md
Created August 4, 2020 03:03
DynamoDB local quick usage guide.

DynamoDB local quick usage guide

Running a local version of DynamoDB inside a Docker container.

Commands

$ docker pull amazon/dynamodb-local:latest
$ docker run --publish 8000:8000 amazon/dynamodb-local

# in another terminal
@magnetikonline
magnetikonline / README.md
Last active May 2, 2020 12:37
Golang io.TeeReader() example.

Golang io.TeeReader() example

  • Opening a source words file.
  • Create a io.TeeReader(), writing read file chunks also to a gzip writer.
  • Output source chunks as read and total bytes.
  • Finally, output compressed bytes and total compressed size.

Output

$ go run main.go
@magnetikonline
magnetikonline / README.md
Last active February 5, 2025 16:52
GitHub token validation regular expressions.
@magnetikonline
magnetikonline / README.md
Last active October 25, 2025 23:35
VirtualBox create host-only interface and attach to VMs.