Skip to content

Instantly share code, notes, and snippets.

View zemanlx's full-sized avatar

Vlastimil Zeman zemanlx

View GitHub Profile
@zemanlx
zemanlx / wordle_solver.sh
Created February 20, 2022 22:31
Solving Wordle with Bash and friends: Your own AI
#!/bin/bash
# List first 10 words
head wordle.dictionary
# List only words that does not contain letters 's' and 'e'
head wordle.dictionary | grep -P "[^se]{5}"
# List only words with 'a' in the 3rd position
head wordle.dictionary | grep "..a.."
@zemanlx
zemanlx / wordle_the_best_word.sh
Created January 23, 2022 09:44
Solving Wordle with Bash and friends: The best starting word
#!/bin/bash
# Test letter frequency counting.
echo "abbey" | grep -o . | sort | uniq -c | sort -nr
# Letter frequency of all five-letter words.
grep -o . wordle.dictionary | sort | uniq -c | sort -nr
# Find word that contains letters from "searo".
grep s wordle.dictionary | grep e | grep a | grep r | grep o
@zemanlx
zemanlx / wordle_create_dictionary.sh
Created January 21, 2022 17:14
Solving Wordle with Bash and friends: Create dictionary
#!/bin/bash
# Install American dictionary
sudo apt-get install wamerican
# See first 10 words
head /usr/share/dict/american-english
# Count words in the dictionary
wc -l /usr/share/dict/american-english
@zemanlx
zemanlx / aws-profile
Last active May 1, 2020 06:59
call awsu (yubikey support) as replacement for python's aws-profile
#!/bin/bash
#
# awsu wrapper around aws-profile with user confirmation for "prod" environments
#
set -o errexit # Exit immediately if any command or pipeline of commands fails
set -o nounset # Treat unset variables and parameters as an error
set -o pipefail # Exit when command before pipe fails
# set -o xtrace # Debug mode expand everything and print it before execution
@zemanlx
zemanlx / .zshrc
Created August 9, 2018 14:10
Google Cloud zsh completion for apt/deb installation
GCLOUD_VERSION=$(gcloud version --format="value('Google Cloud SDK')")
GCLOUD_COMPLETION_FILE="${HOME}/google-cloud-sdk/completion-${GCLOUD_VERSION}.zsh.inc"
GCLOUD_COMPLETION_GITHUB="https://raw.githubusercontent.com/google-cloud-sdk/google-cloud-sdk/v${GCLOUD_VERSION}/completion.zsh.inc"
if [ ! -z ${GCLOUD_VERSION} ]; then
mkdir -p "${HOME}/google-cloud-sdk"
if [ ! -f ${GCLOUD_COMPLETION_FILE} ]; then
wget -qO "${GCLOUD_COMPLETION_FILE}" "${GCLOUD_COMPLETION_GITHUB}"
fi
source "${GCLOUD_COMPLETION_FILE}"