Skip to content

Instantly share code, notes, and snippets.

View ryanmaclean's full-sized avatar
🍩
Running tf apply 💜

Ryan MacLean ryanmaclean

🍩
Running tf apply 💜
View GitHub Profile
@ryanmaclean
ryanmaclean / gzip_10_biggest.sh
Created October 26, 2016 23:07
Gzip 10 Largest Files
#!/usr/bin/env bash
# Find the 10 largest files in a directory and transparently zip them
for i in $(du -hsx * | sort -rh | head -10 | awk '{print $2}'); do gzip $i; done
@ryanmaclean
ryanmaclean / rename_to_old.sh
Last active October 25, 2016 23:35
Rename file to .old
#!/usr/bin/env bash
mv $1{,.old}
@ryanmaclean
ryanmaclean / iso_mount_copy.sh
Last active October 12, 2016 18:15
Traverse directories, mount ISOs and copy files out of them
#!/bin/bash
printf '\e[31m *** This command will traverse subfolders ***\e[0m\n'
printf '\e[31m *** and mount each ISO found and copy the contents ***\e[0m\n'
printf '\e[31m *** to the directory of the ISO, then unmount the ISO ***\e[0m\n'
printf '\e[31m *** and delete it permanently. ***\e[0m\n'
read -r -p "Are you sure you would like to proceed? [y/N] " response
case $response in
[yY][eE][sS]|[yY])
@ryanmaclean
ryanmaclean / playlist-dl.sh
Created October 9, 2016 22:05
Download Youtube Playlist From Conference Before a Flight on Windows 10 Using Ubuntu on Windows
sudo curl -L https://yt-dl.org/latest/youtube-dl -o /usr/local/bin/youtube-dl`
sudo chmod a+rx /usr/local/bin/youtube-dl
/usr/local/bin/youtube-dl -f mp4 -o "%(autonumber)s - %(title)s - %(id)s.%(ext)s" --autonumber-size 2 https://www.youtube.com/playlist?list=PLD409ujd87ZsfNMffX9h1rGNVqnC
@ryanmaclean
ryanmaclean / add_erl_dns_host.sh
Created October 4, 2016 18:28
Add a DNS entry on Edge Router Lite Via Command Line
#!/bin/bash
set system static-host-mapping host-name headnode.localdomain.local alias headnode
set system static-host-mapping host-name headnode.localdomain.local inet 10.10.1.50
@ryanmaclean
ryanmaclean / triton_usb_download.sh
Last active October 21, 2016 00:09
Download Joyent Triton SDC USB Image
#!/bin/env bash
# A script to quickly download the latest image of Open Source Joyent Triton SDC for USB "DC on a stick" servers
# Check if aria2 is installed, otherwise, install it
command -v aria2c >/dev/null 2>&1 || { sudo apt install -y aria2; exit 1; }
# Download 5 streams of the file at once
# I found 5 to be the maximum, each topping out around 300kb/s
aria2c -x 5 https://us-east.manta.joyent.com/Joyent_Dev/public/SmartDataCenter/usb-latest.tgz --async-dns=false
@ryanmaclean
ryanmaclean / sierra_boot_usb.sh
Last active May 6, 2017 21:07
Create macOS Sierra USB Installation Disk
#!/bin/bash
## The drive will need to be named "USB"
## It should be over 8GB large
sudo /Applications/Install\ macOS\ Sierra.app/Contents/Resources/createinstallmedia --volume /Volumes/USB --applicationpath /Applications/Install\ macOS\ Sierra.app --nointeraction
@ryanmaclean
ryanmaclean / check_docker_tag.sh
Created September 29, 2016 18:05
Check if Docker Image with Tag Exists
#!/bin/bash
# This script will check to see if a Docker image exists for a specific tag.
# Taken from here, with love: https://www.reddit.com/r/docker/comments/4hwdma/check_if_an_image_tag_for_a_private_repo_exists/
TOKEN=$( curl -sSLd "username=${DOCKER_HUB_USERNAME}&password=${DOCKER_HUB_PASSWORD}" https://hub.docker.com/v2/users/login | jq -r ".token" )
curl -sH "Authorization: JWT $TOKEN" "https://hub.docker.com/v2/repositories/${DOCKER_REPO}/tags/${DOCKER_TAG}/" | jq .
#{
# "name": "latest",
# "id": 780668,
@ryanmaclean
ryanmaclean / openbsd_restart_sshd.sh
Last active September 10, 2016 17:30
OpenBSD Restart OpenSSHd
#!/bin/sh -
kill -HUP $(cat /var/run/sshd.pid)
#!/bin/bash
# Profile and Region are optional
aws efs describe-file-systems --profile dev --region us-east-1 | jq -r ".FileSystems[] | .FileSystemId"