Skip to content

Instantly share code, notes, and snippets.

@hexaflexahexagon
hexaflexahexagon / tempusmaps.csv
Created November 30, 2021 00:28
List of Tempus maps as of 11/29/21
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
jump_
jump_abandon
jump_abuq
jump_acepogo
jump_adventure
jump_aggregate_zip
jump_ahh_c
jump_air
jump_allstars
jump_anime
@hexaflexahexagon
hexaflexahexagon / not-grep.sh
Created December 20, 2021 14:49
# Emulate the functionality of grep through regular expressions
#!/bin/bash
# Emulate the functionality of grep through regular expressions
# ./script -a = echo a a
# ./script a = echo a at end of file
# ./script -g = echo idk
# ./script what = echo $@
opts="n l i v x"
@hexaflexahexagon
hexaflexahexagon / acronym.sh
Created December 20, 2021 14:53
# given a phrase, convert into an acronym
#!/bin/bash
# given a phrase, convert into an acronym
# Portable Network Graphics -> PNG
# this assumes only that the words are separated by spaces, case doesn't matter
if [ -z "$1" ]; then
echo "Error: Please enter a quoted phrase to acronymize"
exit -1
@hexaflexahexagon
hexaflexahexagon / atbash-cipher.sh
Created December 20, 2021 14:53
# Encode the given string using the ancient 'atbash' cipher technique
#!/bin/bash
# Encode the given string using the ancient 'atbash' cipher technique
# Letters are transposed with a reverse alphabet. E.G.:
# a -> z, test -> gvhg, gvhg -> test
upperOffsetLow=101
upperOffsetHigh=132
lowerOffsetLow=141
@hexaflexahexagon
hexaflexahexagon / coin-change.sh
Last active December 20, 2021 14:55
# Given a $1 number of cents, output the correct distribution
#!/bin/bash
# Given a $1 number of cents, output the correct distribution of coins to use proper change using as few coins as possible
# TODO: consider some coin-agnostic refactor approach. if I want to add a new set of coins it becomes very annoying
c_penny=0
c_nickel=0
c_dime=0
c_quarter=0
@hexaflexahexagon
hexaflexahexagon / google.sh
Last active February 10, 2022 13:07
# Try and google a prompt, then link the first result
#!/bin/bash
# Try and google a prompt, then link the first result
if [[ $1 == "" ]]; then
echo "Error: Please supply an argument to search for"
exit
fi
input=$( echo $1 | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g' )
@hexaflexahexagon
hexaflexahexagon / password-check.sh
Created December 20, 2021 14:54
# check if a given string was found in the haveibeenpwned breach database
#!/bin/bash
# check if a given string was found in the haveibeenpwned breach database
prefix=$(echo -n "$1" | sha1sum | head -c 5)
suffix=$(echo -n "$1" | sha1sum | cut -c 6- | tr -d ' '-)
output=$(curl -s "https://api.pwnedpasswords.com/range/$prefix" \
-H 'user-agent: asdf' |\
grep -i "$suffix" )
@hexaflexahexagon
hexaflexahexagon / quadratic.sh
Created December 20, 2021 14:54
# Give a, b, and c, solve a quadratic equation using the public heroku quadratic API
#!/bin/bash
# Give a, b, and c, solve a quadratic equation using the public heroku quadratic API
load() {
echo $output | python3 -c "import sys, json; print(json.load(sys.stdin)['$1'])"
}
if [ -z $1 ] || [ -z $2 ] || [ -z $3 ]; then
echo "Usage: $0 a b c"
@hexaflexahexagon
hexaflexahexagon / random-song.sh
Created December 20, 2021 14:55
# Retrieve a random song from Apple's iTunes API
#!/bin/bash
# Retrieve a random song from Apple's iTunes API
# https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/
load() {
# Echo, find key pair, strip to just value, remove leading and trailing "'s
echo $output | grep -o $1'":"[^"]*"' | cut -d':' -f2- | sed 's/^.\|.$//g'
}
@hexaflexahexagon
hexaflexahexagon / github-repos.sh
Created December 20, 2021 14:56
# list all public github repos for a given username
#!/bin/bash
# list all public github repos for a given username
if [[ -z $1 ]]; then
echo Error: Please specify a GitHub username
exit -1
fi
input="$1"