KBD

Keith Devens .com

Sunday, September 7, 2008 Flag waving
All I want is to have my peace of mind. – Boston (Peace of Mind)

Archive: July 02, 2004

← July 01, 2004July 03, 2004 →

Daily link icon Friday, July 2, 2004

Dates and times on my site

I'm in the process of simultaneously templatizing my site and converting all dates I store everywhere to GMT/UTC, which of course impacts on how I have to display dates and times, among other things. So, things are a little funky right now.

For loop idioms

Everyone knows the standard for loop idiom:

for($n=0; $n<@arr; $n++) #...

It turns out there are a few more idioms that people use. First, usually you want to cache the upper bound to avoid having to calculate it every time. That's not as important for a language like Perl or PHP where scalar(@arr) or count($arr) or strlen($str) is a quick operation, but it's very important for something like strlen(str) in C:

for(int n=0,int c=strlen(str); n<c; n++) //...

Another one is the following, which works nicely if you want to count backwards:

for($n=@arr-1; $n--;) #...
← July 01, 2004July 03, 2004 →
September 2008
SunMonTueWedThuFriSat
 123456
78910111213
14151617181920
21222324252627
282930 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 7 posts

Recent comments XML

new⇒Trogdor tattoo!!

Oh, so cute, wowoowow....

Kathy Mead: Sep 7, 6:07am

new⇒I hate Norton Antivirus

Long long live AVG I love you!...

kevin sands: Sep 6, 7:31pm

I hate ASP.NET

CF, why pick that piece of trash?​Cold Confusion. Is it finally​really a OO...

ColdConfusion: Sep 5, 8:36pm

Maps of Iraq

This is for Linda, I will be​visiting that site some time in the​near futur...

Bob: Sep 5, 1:20pm

Girls, please don't get breast implants

Well alright I just read my above​comment and I wanted to add​this...I shou...

76.66.140.8: Sep 4, 7:31pm

Spider solitaire

I don't think the question was​necessarily if there are unbeatable​games.  ...

Jared: Sep 4, 12:44pm

Convert Pantone Colors to RGB and Hex - Color Conversion Chart

The colors on those website don't​seem to relate to the pantone data​we hav...

blah: Sep 3, 10:12am

Generated in about 0.045s.

(Used 7 db queries)

mobile phone