Friday, January 1, 2010

Re: [BLUG] New Years Countdown timer

I modified this some to work with zsh and so that it doesn't crash if
you start it after the new year ;)

Also, I tried running it shortly before midnight last night, only to
find that my clock was a couple decaseconds (not deciseconds!) off. I
poked at ntpdate frantically, but my wife and parents were trying to
hand me a glass of champagne already, so I decided there were more
important things to spend the last few seconds of 2009 on ;)

In the spirit of keeping modifications to open source things out
there, I've included my [only slightly] modified version below. Maybe
there should be a clause for "Sorry, you missed it already" instead of
saying "Happy New Year!" when run at this point..

while V=$((`date +%s -d"2010-01-01"`-`date +%s`)); do \
if [[ $V -le 0 ]]; then \
toilet -f smmono12 --gay 'Happy New Year!'; \
break; \
else \
clear; \
toilet -f bigmono12 --gay $V; \
sleep 1; \
fi; \
done;

P.S. one of my later BASIC programs over a decade ago (a few years
before I really discovered linux) was a new year countdown timer. I
think I was preparing it for y2k, but I'm not sure anymore. It was
much longer and more complicated than this script, since I didn't know
about / have utilities like date and toilet, much less regexes (which
I did all by hand, ugh).

--
Jonathan

2009/12/30 Steven Black <blacks@indiana.edu>:
> I ran the script and found (1) I didn't have figlet installed, and (2) it
> suggested I install either figlet or toilet. I installed them both, but
> I think I like toilet's default letters better.
>
> In fact, here's my extended edition of the command (wrapped to be easy
> to read, but with line-continuation so you can copy/paste):
>
> while V=$((`date +%s -d"2010-01-01"`-`date +%s`)); do \
>    if [ $V == 0 ]; then \
>        toilet -f smmono12 --gay 'Happy New Year!'; \
>        break; \
>    else \
>        clear; \
>        toilet -f bigmono12 --gay $V; \
>        sleep 1; \
>    fi; \
> done
>
> I think the --gay toilet is just thing the any New Year's bash.
>
> Cheers,
> Steven Black
>
> On Wed, Dec 30, 2009 at 06:43:48PM +0000, Mark Krenz wrote:
>>
>>
>> This is what I just posted to the climagic account on twitter and
>> identi.ca:
>>
>> while V=$((`date +%s -d"2010-01-01"`-`date +%s`));do if [ $V == 0 ];then figlet 'Happy New Year!';break;else figlet $V;sleep 1;clear;fi;done
>>
>>  Of course I was limited to 140 characters.  Anyways, I thought some
>> people here might appreciate this little snippet.
>
> _______________________________________________
> BLUG mailing list
> BLUG@linuxfan.com
> http://mailman.cs.indiana.edu/mailman/listinfo/blug
>

_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: