Navigace



Binary clock in CF

Early today I was looking for some Christmas presents and found a very nice Binary Watch.

I was wondering who uses this kind of stuff, but I'm sure somebody uses. Imagine yourself in a club when that hot chick comes to you asking what time is it. Would you show that nerd piece on your wrist?

On the other hand a ColdFusion Clock would be very nice. So when the hot chick comes to you with that question, you could use your blackberry to say the time.

Nahh... The time is already on your blackberry, but... Well, it was a nice exercise at least.

<cffunction name="getBinary">
   <cfargument name="value" required="true">
   <cfargument name="mask" required="true" hint="Four (Hours) or six (minutes) numbers are returned">
   <cfreturn numberformat(formatBaseN(arguments.value,2),arguments.mask)>
</cffunction>

<cffunction name="isChecked">
   <cfargument name="position" required="true">
   <cfargument name="value" required="true">
   <cfset var marked = "off">
   
   <cfif mid(arguments.value,position,1)>
      <cfset marked = "on">
   </cfif>

   <cfreturn "<img src=" & marked & ".jpg />">
</cffunction>


<cfset hour = getBinary(hour(now()),"0000") />
<cfset minutes = getBinary(minute(now()),"000000") />

And then some crappy HTML to display the clock

<cfoutput>
   <table width="20%" border="1">
      <tr>
         <td colspan="6">Hours</td>
      </tr>
      <tr align="center" id="hours">
         <td>8</td>
         <td>4</td>
         <td>2</td>
         <td>1</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr align="center">
         <td>#isChecked(1,variables.hour)#</td>
         <td>#isChecked(2,variables.hour)#</td>
         <td>#isChecked(3,variables.hour)#</td>
         <td>#isChecked(4,variables.hour)#</td>
         <td>&nbsp;</td>
         <td>&nbsp;</td>
      </tr>
      <tr><td colspan="6"> </td>
      </tr>
      <tr>
         <td colspan="6">Minutes</td>
      </tr>
         <tr align="center" id="minutes">
         <td>32</td>
         <td>16</td>
         <td>8</td>
         <td>4</td>
         <td>2</td>
         <td>1</td>
      </tr>
      <tr align="center">
         <td>#isChecked(1,variables.minutes)#</td>
         <td>#isChecked(2,variables.minutes)#</td>
         <td>#isChecked(3,variables.minutes)#</td>
         <td>#isChecked(4,variables.minutes)#</td>
         <td>#isChecked(5,variables.minutes)#</td>
         <td>#isChecked(6,variables.minutes)#</td>
      </tr>
   </table>
</cfoutput>

And here's the example.

Hope you like it!


Comments
Niqui Merret's Gravatar The only person I know who has one is a woman. She is also a geek and just in case you think that makes her ugly... She is actually beautiful.

To answer you question as a woman - I think its cool :)
# Posted By Niqui Merret | 12/15/06 9:53 AM
Marcos Placona's Gravatar Jez... I think you are the first woman posting a comment into my Blog. Welcome! :-)

But now the big question. This woman who uses the watch. Am I talking to her now?

How was flash on the beach BTW?

Cheers
# Posted By Marcos Placona | 12/15/06 10:02 AM
Niqui Merret's Gravatar Hi Marcos

Her name is Sarah and she does mobile development. I was well impressed and thought about it just for the novelty factor but really can't read binary.

FOTB was amazing. It was so surreal to have dinner at my favorite Brazilian restaurant with a bunch of the speakers and top developers from all over the world.

The speakers were inspirational! You have to make it to next years if you are even remotely interested in Flash!
# Posted By Niqui Merret | 12/15/06 10:23 AM
Marcos Placona's Gravatar Yes, I'll try to do it next year. I used to work with some action script, and sometimes I still do it, but not so frequently.

Talking about the restaurant, I believe I'll eat loads of Brazilian food next week as I'm off to Brazil until the 15th of January.

Cheers
# Posted By Marcos Placona | 12/15/06 10:31 AM

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer.

Search


Calendar

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            

Subscribe

Enter your email address to subscribe to this blog.


Archives By Subject

A Wee Dram 2008 (1) [RSS]
Adobe (18) [RSS]
Adobe Max 2007 (1) [RSS]
Apollo (2) [RSS]
Book Review (2) [RSS]
Books (2) [RSS]
CFDevcon06 (2) [RSS]
CFDevcon08 (2) [RSS]
CFUNITED 2008 (3) [RSS]
CFUNITED2007 (1) [RSS]
ColdFusion (36) [RSS]
Flex (3) [RSS]
Fusebox (2) [RSS]
General Techie Stuff (9) [RSS]
Javascript (4) [RSS]
JQuery (2) [RSS]
Linux (6) [RSS]
Misc (28) [RSS]
Railo (1) [RSS]
Scotch on th Rocks2007 (1) [RSS]
Tag of the day (2) [RSS]
UKCFUG (1) [RSS]

Tags

adobe coldfusion misc

Recent Entries

I'm alive!

Adds


RSS


Add to Technorati Favorites


SpamStop

This blog is protected by the SpamStop plugin and Project Honeypot.
Handled in just over 4 months:
  • Total suspicious visitors: 94
  • Harvesters: 1
  • Spammers: 47
  • and 46 where marked as suspicious.
The last shady visitor was here on November 20, 2008

In just over 4 months this blog was visited 59 times by search engines and other harmless crawlers and aggregators.

More info:
SpamStop plugin
Project Honeypot