This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Output HTML boilerplate code to a file name specified by the first argument | |
# If no arguments are provided, outputs to index.html | |
# example: | |
# html_boilerplate example.html | |
html_boilerplate() { | |
[[ $1 ]] || { | |
echo "usage: $FUNCNAME outfile" | |
return 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def vignere(message, keyword) | |
min_byte = 97 | |
max_index = 26 | |
cipher = "" | |
message.downcase.split("").each_with_index do |char, i| | |
cipher_i = (char.ord - min_byte) + (keyword[i].ord - min_byte) | |
cipher_i -= max_index if cipher_i > max_index | |
cipher += (cipher_i + min_byte).chr | |
end |