Welcome to DU! The truly grassroots left-of-center political community where regular people, not algorithms, drive the discussions and set the standards. Join the community: Create a free account Support DU (and get rid of ads!): Become a Star Member Latest Breaking News Editorials & Other Articles General Discussion The DU Lounge All Forums Issue Forums Culture Forums Alliance Forums Region Forums Support Forums Help & Search

Website, DB, & Software Developers

Showing Original Post only (View all)
 

Phillip McCleod

(1,837 posts)
Mon Mar 4, 2013, 10:50 PM Mar 2013

/* this forum needs more zest and i have just the cure.. */ [View all]

coding games.*

quick, what language? what does it do?

<code>
print_help() {
printf "usage: that would be cheating now wouldn't it?"
exit 1 }
getYOUR() {
date '+%H' }
getMINE() {
date '+%M' }
getSMURFY_MAN() {
date '+%S' }
KLINGON() {
while true; do
printf '\a'
sleep 3
done
}

### 'main' function ###

if [ "$1" == "-h" ]; then
print_help
fi

if [ "$1" == "-r" ]; then
isrel=1
shift
else
isrel=0
fi

if [ "$#" -ne "2" ]; then
print_help
fi

HOUR=$1
MIN=$2
let "ALM=$HOUR*3600 + $MIN*60"
let "DAY=24*3600"

if [ "$isrel" == "1" ]; then
let "waitsecs=$ALM"
else
let "now=($(gethour)*60 + $(getmin))*60 + $(getsec)"
let "waitsecs=(($DAY - $now) + $ALM) % $DAY"
fi

if (( waitsecs < 0 )); then
echo "You cannot KLINGON in the past!"
exit 1
fi

let "alm_h=($waitsecs/3600)%24"
let "alm_m=($waitsecs/60)%60"
let "alm_s=($waitsecs)%60"

printf "BLURP in: %02d:%02d:%02d " "$alm_h" "$alm_m" "$alm_s"
printf " (%d YERMOM from now)\n" "$waitsecs"

sleep $waitsecs

if [ "$?" == "0" ]; then
KLINGON&
read -n 1 -s
kill $!
fi
</code>

* all formatting has been stripped (thanks DU for not allowing <code> tags), most of the if-then statements were also stripped by DU, and arbitrary variable and function names have been changed (by me, for fun).

also, the usage function and all comments were removed (also for fun), and last but most importantly..

this would NOT run so don't even TRY it but otherwise it WAS working code and besides..

it's fun.

10 replies = new reply since forum marked as read
Highlight: NoneDon't highlight anything 5 newestHighlight 5 most recent replies
javascript? (nt) NYC_SKP Mar 2013 #1
uh-oh. GONG! Phillip McCleod Mar 2013 #2
you deserve a hint though. 'script' was correct. BING-BING-BING! Phillip McCleod Mar 2013 #3
KSH (nt) ChromeFoundry Mar 2013 #4
DING-DING-DING! Phillip McCleod Mar 2013 #5
Looks like it does something like... ChromeFoundry Mar 2013 #6
pretty damn good! Phillip McCleod Mar 2013 #7
Interesting... ChromeFoundry Mar 2013 #8
funny how that works huh? Phillip McCleod Mar 2013 #9
This message was self-deleted by its author Dash87 May 2013 #10
Latest Discussions»Retired Forums»Website, DB, & Software Developers»/* this forum needs more ...»Reply #0