Not worth creating a project for, and it might be interesting to see what changes people would make.
Non-standard dependencies:
#!/usr/bin/zsh
# Author: @[email protected]
# 2025-02-23
final=(xargs echo)
count=6
while getopts d opt; do
case $opt in
d)
final=(tr 'A-Z' 'a-z')
;;
*)
printf "Password generator based on the correcthorse algorithm from http://xkcd.com/936//n/n"
printf "USAGE: %s [-d] [#]\n" "$0"
printf " -d make the result all lower case; otherwise, each word will be capitalized.\n"
printf " # the number of words to include. Defaults to 6."
exit 1
;;
esac
done
shift $(($OPTIND - 1))
[[ $# -gt 0 ]] && count=$*
shuf -n $((count * 2)) /usr/share/dict/american-english | \
sed 's/'"'"'.*//; s/^\(\w\)/\U\1/' | \
sort | uniq | shuf -n $count | xargs echo | \
tr -d ' ' | $final
What's going on here:
Nearly 30% of the American dictionary (34,242) are words with apostrophes. They could be left in to help satisfy password requirements that demand "special characters," but correcthorse isn't an algorithm that handles idiot "password best practices" well anyway. So, since every word with an apostrophe has a pair word without one, we pull 2·N words to make sure we have enough. Then we strip out the plural/possessives and capitalize every word. Then we remove duplicates and select our N words from the result. Finally, we compact that into a space-less string of words, and if the user passed the -d
option, we downcase the entire thing.
Without the user options, this really could be a 1-liner; that's how it started:
alias pony="shuf -n 12 /usr/share/dict/american-english | sed 's/'\"'\"'.*//; s/^\(\w\)/\U\1/' | sort | uniq | shuf -n 6 | xargs echo | tr -d ' '"
They're not, though.
I'm not an electrician, but I did come across a study a while back that basically said clamp-style connectors like Wago were more reliable and safe than crimping. Not being an electrician, and not really being able to stay awake reading through a paper on the topic, I don't know what qualifiers they used. It was a couple years ago, but IIRC it was a study looking at a sampling of installations and comparing them, so it was probably just saying that, on average, Wago are better because your average electrician won't do as good of a job. It was the basis for some legislation about requiring the use of Wago-style clamps in new installs somewhere.
So, you're probably right: given an expert who's taking the time to do a good job and never makes mistakes, a solid crimp is probably better. And when you're a pro rewiring your own house, you'll probably want to do those instead. However, according to what I remember, counties are better off mandating the use of clamp connectors.
Once again, I'm reminded of the old saying: what do you call the guy who graduated at the bottom of his class in medical school? "Doctor."