Skip to content

Instantly share code, notes, and snippets.

Avatar
🍌
Go banana!

Peter Mescalchin magnetikonline

🍌
Go banana!
View GitHub Profile
@magnetikonline
magnetikonline / README.md
Created Nov 24, 2020
Access Golang private modules within a GitHub organization.
View README.md

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
Created Nov 23, 2020
Find latest non beta/RC release for Docker CLI
View README.md

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 Nov 11, 2020
Creating a 'run once' systemd unit.
View README.md

Creating a 'run once' systemd unit

A template for a systemd unit which calls a script exactly once on startup and keeps unit status active after script exits.

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 Aug 4, 2020
DynamoDB local quick usage guide.
View README.md

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
Golang io.TeeReader() example.
View README.md

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 Sep 28, 2020
GitHub token validation regular expressions.
View README.md

GitHub token validation regular expressions

Simple regular expressions to check if a given GitHub token could be valid.

Personal access tokens

Personal access tokens are exactly 40 hexadecimal characters in length.

^[0-9a-f]{40}$
@magnetikonline
magnetikonline / README.md
Last active Nov 17, 2020
VirtualBox create host-only interface and attach to VMs.
View README.md
@magnetikonline
magnetikonline / README.md
Created Jun 3, 2019
Git correct a commit via --fixup
View README.md

Git correct a commit via --fixup

Initial commit state:

$ git log --oneline
733e2ff Second widget done
fb2f677 First widget done
ac5db87 First commit
@magnetikonline
magnetikonline / README.md
Last active Aug 20, 2019
Modify DHCP DNS servers for Optus supplied (Vividwireless) Huawei B315 4G modem.
View README.md

Modify DNS for Optus supplied Huawei B315 4G modem

The Huawei B315 modem supplied by Optus for the (now defunt) Vividwireless service is a workable but sadly rather crippled device, even down to the inabiilty to modify assigned DNS servers from it's DHCP server away from Optus DNS to something sane (Google DNS/Cloudflare/etc.).

This script should allow for the easy update of assigned DNS servers and has been tested with Google Chrome.

Usage

  • Log into router web UI (e.g. http://192.168.0.1).
  • From the same browser session, open the "web developer tools" pane.
  • Drop the contents of dnsmodify.js into Console area - modifying ROUTER_URI, PRIMARY_DNS and SECONDARY_DNS to suit.
  • Run the script, updated DHCP settings are pushed and modem will restart.
You can’t perform that action at this time.