Skip to content

Instantly share code, notes, and snippets.

@jorinvo
Last active January 30, 2022 22:20
Show Gist options
  • Save jorinvo/58d4387925d6dee1ba4fcb231301d86c to your computer and use it in GitHub Desktop.
Save jorinvo/58d4387925d6dee1ba4fcb231301d86c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Exit on error
set -e
# On MacOS, make sure shuf command is available
if uname | grep -q Darwin
then
which brew &> /dev/null || echo "please install brew: https://brew.sh" && exit 1
which gshuf &> /dev/null || brew install coreutils
alias shuf=gshuf
fi
# All possible combinations of 4 letters,
# each on one line for streaming and in random order
combinations="$(echo {a..z}{a..z}{a..z}{a..z} | tr " " "\n" | shuf)"
echo "possibilities: $(echo "$combinations" | wc -l)"
# Filter to only names that 404 on github.com,
# 10 in parallel (might still take a while),
# and write them to a file
echo "$combinations" | xargs -P10 -I{} sh -c "curl -sfI https://github.com/{} > /dev/null || echo {}" > github.txt
echo "available on Github: $(wc -l github.txt)"
# Do the same thing for twitter.com
cat github.txt | xargs -P10 -I{} sh -c "curl -sfI https://twitter.com/{} > /dev/null || echo {}" > github-twitter.txt
echo "available on Github and Twitter: $(wc -l github-twitter.txt)"
echo "See *.txt files for available names"
@phuctm97
Copy link

phuctm97 commented Dec 7, 2020

I tried this on macOS Catalina but doesn't work, nothing outputs. Any clue?

@skve
Copy link

skve commented Jan 30, 2022

@phuctm97 remove the && exit 1 from the end of line 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment