Skip to content

Instantly share code, notes, and snippets.

Matt McKellar-Spence MattMS

Block or report user

Report or block MattMS

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MattMS
MattMS / Docker_remove_untagged_Images.sh
Created Nov 13, 2017
Delete all Docker Images with no ("<none>") tag.
View Docker_remove_untagged_Images.sh
#!/bin/sh
docker images | awk '$2 == "<none>" {print $3}' | xargs docker rmi
View Compose Express calls.coffee.md

Compose Express calls

compose = (calls)-> (req, res, next)->
	if calls.length
		calls[0] req, res, ->
			call = compose calls.slice 1
			call req, res, next
	else if next
		next()
@MattMS
MattMS / small_file_contents.fish
Last active Jul 21, 2017
Print file name (minus `.txt` extension), `=`, then file contents
View small_file_contents.fish
#!/usr/bin/env fish
set ext '.txt'
for f in (ls | grep $ext)
echo (basename $f $ext)=(cat $f)
end
@MattMS
MattMS / Append to PATH.fish
Created Jul 13, 2017
Append to current folder to PATH in Fish Shell
View Linux users and groups.md

Users in Linux

Sorted list of all users:

cat /etc/passwd | awk -v FS=: -e '{print $1}' | sort

Switch to another user (prompts for password):

su - my_other_user
@MattMS
MattMS / Kubernetes tasks.md
Last active Mar 27, 2017
Kubernetes tasks with kubectl
View Kubernetes tasks.md

Kubernetes tasks

Get credentials before using kubectl:

gcloud container clusters get-credentials my-cluster --project my-project --zone my-zone

Pod management

Delete all pods (in all namespaces) that are in "Error" state:

@MattMS
MattMS / Ramda extensions.md
Created Mar 25, 2017
Possibly helpful function compositions for Ramda.
View Ramda extensions.md

Ramda extensions

Test a path exists:

const has_path = R.pipe(R.path, R.complement(R.isNil))
@MattMS
MattMS / Node.js Ubuntu install.md
Last active Jul 21, 2017
Install Node.js on Ubuntu from package manager
View Node.js Ubuntu install.md

Install Node.js on Ubuntu

The [official instructions][install] say to download and run a script with sudo, which should sound scary. So I went through the script and wrote up what it is doing.

It's actually fine to run, but it's not much harder to do it all yourself.

Add the key

@MattMS
MattMS / Google_Cloud_access_token.sh
Created Mar 10, 2017
Get an access token for future requests to Google Cloud APIs
View Google_Cloud_access_token.sh
access_token=$(curl
-H "Metadata-Flavor: Google"
--show-error
--silent
http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token?alt=text
| awk '$1 == "access_token" { print $2 }')
View print_file_size_in_bytes.sh
size=$(ls -l ./my_file | awk '{ print $5 }')
echo $size
You can’t perform that action at this time.