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 emit(key, value, sep="\t") | |
STDOUT.puts('' << key << sep << value) | |
end | |
def map(*options) | |
options = [:split, "\t", 2] if options.empty? | |
STDIN.each_line do |line| | |
line.strip! | |
key, value = line.send(*options) |
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
#!/bin/bash -e | |
set -u | |
MAX_LENGTH=14 | |
text="$*" | |
length=$(echo -n "${text}" | wc -c) | |
if [ ${length} -gt ${MAX_LENGTH} ]; then |
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
class DammAlgorithm | |
# http://en.wikipedia.org/wiki/Damm_algorithm | |
TABLE = [ [0, 7, 4, 1, 6, 3, 5, 8, 9, 2], | |
[3, 0, 2, 7, 1, 6, 8, 9, 4, 5], | |
[1, 9, 0, 5, 2, 7, 6, 4, 3, 8], | |
[7, 2, 6, 0, 3, 4, 9, 5, 8, 1], | |
[5, 1, 8, 9, 0, 2, 7, 3, 6, 4], | |
[9, 5, 7, 8, 4, 0, 2, 6, 1, 3], | |
[8, 4, 1, 3, 5, 9, 0, 2, 7, 6], |
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
#!/bin/bash | |
ip_address="$(ip addr show $1 2>/dev/null | awk '/inet / {print $2}' | sed -e 's/\/.*//')" | |
if [ "${ip_address}" ]; then | |
formatted_address="$(printf "%-10s%s\n" "$1:" ${ip_address})" | |
sed -e "s/IP_ADDRESS/${formatted_address}/" /etc/issue.TEMPLATE > /etc/issue | |
else | |
cp /etc/issue.DIST /etc/issue | |
fi |
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
#!/bin/bash | |
LOGGLY_TOKEN='' | |
TAG='ifup' | |
URL="https://logs-01.loggly.com/inputs/${LOGGLY_TOKEN}/tag/${TAG}" | |
interfaces='{' | |
for interface in $(ip addr | awk '/state UP/ {print $2}' | sed -e 's/://'); do | |
ip_address=$(ip addr show ${interface} 2>/dev/null | awk '/inet / {print $2}' | sed -e 's/\/.*//') | |
mac_address=$(ip addr show ${interface} 2>/dev/null | awk '/link\/ether/ {print $2}') |
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
FROM alpine:latest | |
ENV AWS_DEFAULT_REGION us-east-1 | |
RUN apk add --update groff less python py-pip && pip install awscli |