dot

packages and services management
Log | Files | Refs | README

commit 05c4cdf9d3c27fed5f32dfadd2592c09c4a43178
parent a0c7d1597e30421900904cefccb2c16f109d9ade
Author: josuah <mail@josuah.net>
Date:   Sat, 12 Nov 2016 12:52:30 -0500

DNA teletyper

Diffstat:
Mbin/dna | 43++++++++++++++++++++++++++++++++++++-------
1 file changed, 36 insertions(+), 7 deletions(-)

diff --git a/bin/dna b/bin/dna @@ -39,7 +39,6 @@ A="\ | | " - G="\ ${f1}O${R} ${f1}O${R} *---* \\\\ / / \\ @@ -70,7 +69,6 @@ C="\ | | " - T="\ ${f1}O${R} ${f1}O${R} * ${f1}O${R} *---* \\\\ / \\ // / \\ @@ -86,15 +84,46 @@ T="\ | | " -dna=$1 +random() +{ + local nucleotide i=1 + + while date +%s | md5sum | cut -c $i | tr [0-9]abcdef ATCGATCGATCGATCG | + while IFS='' read -r nucleotide + do + show_nucleotide "$nucleotide" + done + do + [ $i -ge 32 ] && i=1 || i=$(($i + 1)) + sleep 0.3 + done +} + +show_nucleotide() +{ + local nucleotide="$1" -while [ ! -z "$dna" ]; do - nucleotide=$(printf '%s' "$dna" | cut -c 1) case $nucleotide in A) printf '%s' "$A" ;; C) printf '%s' "$C" ;; T) printf '%s' "$T" ;; G) printf '%s' "$G" ;; esac - dna=$(printf '%s' $dna | cut -c 2-) -done +} + + + +main() +{ + local dna="$1" + + [ -z "$dna" ] && random + + while [ ! -z "$dna" ]; do + nucleotide=$(printf '%s' "$dna" | cut -c 1) + show_nucleotide "$nucleotide" + dna=$(printf '%s' $dna | cut -c 2-) + done +} + +main $@