Skip to content

Instantly share code, notes, and snippets.

View chadmayfield's full-sized avatar

Chad Mayfield chadmayfield

View GitHub Profile
@chadmayfield
chadmayfield / gist:f16a3bf27c5f2587be1ec5bb82433dd6
Created May 6, 2017 02:24
Using perl File::Fetch to download alexa top 1m, error
GET /alexa-static/top-1m.csv.zip HTTP/1.1
TE: deflate,gzip;q=0.3
Connection: TE, close
Authorization: Basic YW5vbnltb3VzOkZpbGUtRmV0Y2hAZXhhbXBsZS5jb20=
From: [email protected]
Host: s3.amazonaws.com
If-Modified-Since: Fri, 05 May 2017 17:42:18 GMT
User-Agent: File::Fetch/0.38
HTTP/1.1 400 Bad Request
@chadmayfield
chadmayfield / hashcat_macos.sh
Created June 2, 2017 17:24
Install Hashcat on macOS
#!/bin/bash
git clone https://github.com/hashcat/hashcat.git
mkdir -p hashcat/deps
git clone https://github.com/KhronosGroup/OpenCL-Headers.git hashcat/deps/OpenCL
cd hashcat/ && make
./hashcat --version
./hashcat -b -D 1,2
./example0.sh
@chadmayfield
chadmayfield / indent_flags.sh
Created January 8, 2018 05:28
Using printf for fun with formatting
#!/bin/bash
flags=$(grep '^flags' /proc/cpuinfo | uniq | awk -F ": " '{print $2}')
printf "%-20s %s" "Flags:"
echo "$flags" | fold -s -w 40 | sed -e "2,\$s/^/$(echo $'\t' | pr -Te21)/"
@chadmayfield
chadmayfield / tmux-cheatsheet.markdown
Created February 11, 2019 05:19 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@chadmayfield
chadmayfield / expected_behavior.txt
Created February 11, 2019 23:15
rename_season.sh: a simple TV season renamer to rename DVR'ed season more in-line with what Plex is expecting.
chad@localhost:~$ ./rename_season.sh
mv ./Series 1/Season 1 ./Series 1/Season 01
mv ./Series 1/Season 2 ./Series 1/Season 02
mv ./Series 1/Season 3 ./Series 1/Season 03
mv ./Series 2/Season 1 ./Series 2/Season 01
mv ./Series 3/Season 1 ./Series 3/Season 01
mv ./Series 3/Season 2 ./Series 3/Season 02
mv ./Series 3/Season 3 ./Series 3/Season 03
mv ./Series 3/Season 4 ./Series 3/Season 04
mv ./Series 3/Season 5 ./Series 3/Season 05
user@localhost:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
jenkinsci/blueocean latest 82af3de1a82d 14 hours ago 433MB
gogs/gogs latest ddfb5cfc5595 35 hours ago 169MB
jenkinsci/blueocean <none> 0edbdc899e2e 38 hours ago 433MB
nginx latest 5699ececb21c 2 days ago 109MB
gogs/gogs <none> 1c9ee1dfb9af 2 days ago 169MB
jenkinsci/blueocean <none> a4830eae32eb 2 days ago 433MB
gogs/gogs <none> 58df9f960a87 3 days ago 169MB
gogs/gogs <none> bea8d72e27db 3 days ago 169MB
tmux start tmux server
tmux new-session -s basic start a new session and name it basic
tmux new -s basic same command as above but abbreviated
CTRL+b command key combo (PREFIX)
PREFIX + d detach window
tmux list-sessions list running sessions
tmux ls list running sessions abbreviated
tmux attach attach to running session
tmux new -s second -d create tmux instance in background
tmux attach -t second attach to session named "second"
@chadmayfield
chadmayfield / blacklist.sh
Last active June 2, 2019 21:39
Blacklist domains in a list file
#!/bin/bash
while read line
do
echo "Blacklisting: $line"
pihole -b $line
done < "/path/to/your/blacklisteddomains.list"
@chadmayfield
chadmayfield / check_version.sh
Created June 2, 2019 21:19
Check version of a Github project and email (using cron)
#!/bin/bash
# check_version.sh - check github project for latest release version from cron & email
url="https://github.com/USER/REPO/releases/latest"
txt="/tmp/release.txt"
prj="$(echo $url | awk -F "/" '{print $4 "/" $5}')"
cmd="$(curl -sL -o /dev/null -w "%{url_effective}" ${url} | awk -F "/" '{print $NF}')"
if [ ! -f "$txt" ]; then
@chadmayfield
chadmayfield / check_registry.sh
Created June 2, 2019 23:33
Quick check of registry
#!/bin/bash
# docker api reference : https://docs.docker.com/registry/spec/api/#detail
# docker list repos : https://docs.docker.com/registry/spec/api/#listing-repositories
curl -X GET localhost:5000/v2/_catalog