Learn About Doug!
View Doug Boude's online resume
updated 4/22/2009

View Doug Boude's profile on LinkedIn
Link to me!

Follow Doug Boude on Twitter
Follow me!

Be Doug's friend on Facebook
Befriend me!
(I promise not to follow you home)
Contact Doug!
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...
Florida web site design



Czech your Page Rank!
Check Page Rank of any web site pages instantly:
This free page rank checking tool is powered by Page Rank Checker service
Surf's Up!
Visit Egosurf.org and massage YOUR web ego!
My Score: 9,001
Doug's Books

Read (and recommend)

  • Men are from Mars, Women are from Venus
  • The Wisdom of Crowds: Why the Many Are Smarter Than the Few and How Collective Wisdom Shapes Business, Economies, Societies and Nations
  • Blink: The Power of Thinking Without Thinking
  • Head First Design Patterns
  • Transact-SQL Programming
  • What's So Amazing About Grace?
  • Just So Stories (Rudyard Kipling collection)

Reading

  • Prayer: Does it Make Any Difference?
  • Data Mining (Practical Machine Learning Tools and Techniques)
<< December, 2008 >>
SMTWTFS
123456
78910111213
14151617181920
21222324252627
28293031
Search Blog

Recent Comments
Re: Equivalent of SQL "TOP X" in Oracle (by Azzedo at 7/01 4:39 PM)
Re: Small But Seriously Irritating Export to Excel Issue (by dougboude at 6/30 2:47 PM)
Re: Small But Seriously Irritating Export to Excel Issue (by Shannon Hicks at 6/30 1:41 PM)
Re: Disappearing IE Popup Window During Save/Open Dialog (by James Moberg at 6/26 7:17 PM)
Re: Buying a New Home in San Antonio (by ike at 6/26 2:58 PM)
Re: SQL Forward Engineering with Visio 2003 Professional (by Matthew at 6/17 2:33 PM)
Re: Special Character/Unicode Issue in Ajax Data Retrieval (by matt at 6/15 3:34 AM)
Re: My Twelve Steps to a Coldbox App (by Dutch Rapley at 6/12 1:34 PM)
Re: My Twelve Steps to a Coldbox App (by dougboude at 6/12 12:09 PM)
Re: My Twelve Steps to a Coldbox App (by Dutch Rapley at 6/12 11:52 AM)
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS

Powered by
BlogCFM v1.11

17 December 2008
Getting a Complete List of Timezones from Java

I've been doing some research on i18n, locales, timezones, and all that jazz lately. Today I wanted to build a dropdown list of possible timezones, and came across a bit of Java code that I converted to CFSCRIPT. Thought I'd share it in case anybody else finds it useful. I will say that there are a LOT more timezones than I would have ever guessed (592 to be exact), and the results of my snippet probably aren't useful as-is to populate a dropdown; but, at least you do have a way to access what your CF server's JVM knows about, and you can filter it as you like.

Oh, I ran this code under CF8; not sure what it does under earlier versions.

The Code:

<!--- create list of valid time zones using java... --->

<cfscript>

tz = createobject("java","java.util.TimeZone");

aTZID = tz.getAvailableIDs();

today = now();

aTZs = arraynew(1);

for(i=1;i<=arraylen(aTZID);i=i+1){

tmptz = tz.getTimeZone(aTZID[i]);

stThisTZ = structnew();

stThisTZ.id = aTZID[i];

// Get the display name

stThisTZ.shortName = tmptz.getDisplayName(tmptz.inDaylightTime(today), tz.SHORT);

stThisTZ.longName = tmptz.getDisplayName(tmptz.inDaylightTime(today), tz.LONG);

stThisTZ.readableName = tmptz.getDisplayName();

 

// Get the number of hours from GMT

rawOffset = tmptz.getRawOffset();

stThisTZ.offset = rawOffset / (60*60*1000);

stThisTZ.offsetMinutes = abs(rawOffset / (60*1000)) % 60;

 

// Does the time zone have a daylight savings time period?

stThisTZ.hasDST = tmptz.useDaylightTime();

 

// Is the time zone currently in a daylight savings time?

stThisTZ.inDST = tmptz.inDaylightTime(today);

arrayAppend(aTZs,structcopy(stThisTZ));

}

</cfscript>

<cfdump var="#aTZs#">


screenshot of the output:
screenshot of output of timezones retrieved via java timezone object

Posted by dougboude at 7:16 AM | PRINT THIS POST! | Link | 1 comment



16 December 2008
A Look at Male Enhancement
or, The Mythical Man Inch

Allow me to preface by saying that I am well aware that NO MALE reading this post has ever considered, imagined, entertained the remotest thought of, or especially TRIED any of the seemingly popular and wildly successful (according to Ron Jeremy) male enhancement nutraceuticals. I know this is the case...we're all fantastically pleased with our packages just the way they are; no room for improvement there. Lend me your imaginations for a moment though, and let's pretend a few things. Let's pretend that first of all, Ron Jeremy does not speak with cunning lingus, and "Johnson-gro" actually does what it says. Let's pretend also that you actually say to yourself one day while studying your genitalia in a fogged up mirror, "hmmm, I guess I COULD stand to have a LITTLE more penile fortitude", and drop the bucks to acquire the product. And, to top off our imaginative adventure, let's say that after rubbing on a handful of "Cavernous Balm" and rinsing it away, there in all its glorious beauty shone a serpent fit to be enshrined, a full ONE INCH longer! You know, the size of half of your pinky finger; the distance between the 2 and the 5 button on your telephone; the breadth of three lines on your notebook paper.

Now, here's the question, the answer to which I believe dispells every empty, egotistical, low self-esteem driven motivation that moves us and fuels the "phallic express" bosses who thrive on mankind's misinterpretation of his schnitzel:

Would your woman even NOTICE?

Your lovely spousal unit of one, three, five, ten, even TWENTY years: Would she really take note the night you crawl into bed with what you believe to be a brand new weiner? Even in the bright white light of the noon day sun, do you honestly believe that, had you never said a word to her about anything to do with attempting to lengthen your dachsund, that her eyes would fly wide open at what you perceive to be a huge difference in Ol' Stiffy? I'm betting a gabillion dollars that the absolute unquestionable answer is...NO. She wouldn't notice without you pointing it out to her, and even then she'd have to stretch her imagination to try and find concord with you.

Through the eyes of our companions (contrary to our own perceptions sometimes), WE do NOT equal our Wally. Our woman sees us when she looks at us, not solely one small part of us (pun intended). I know, I know, this is a hard concept to conceive; after all, WE see ourselves as our penis, why wouldn't they? Especially when that's the part of us with which we pleasure and become one with her. The fact of the matter is, though, as I'm sure you have all heard continuously, US GUYS are the only ones who really care THAT much about how much our Ballpark Frank plumps when you cook it, not them. The proof being that were you truly able to tack on another whopping INCH, she wouldn't even know that you had. Knowing how very challenging this is for a male to wrap his head around, allow me to toss out an equal analogy from our companion's perspective that I believe will help drive the concept home....

A woman's pride is very much attached to her appearance; not even a topic fit for debate. The skyrocketing sales of bigger boobs, liposuction, rhinoplasty, vulvarian sculpture, etc. solidifies that fact hands down. One aspect with which she identifies herself as beautiful is her hair. Now for us guys, we know that our lady HAS hair, and we like that fact; but I would venture to say that, although we can see the aesthetic complement a neatly coiffed head provides, it is way down on our list of reasons why we are attracted so strongly to her.

Case in point: your lady goes out for the day with a girlfriend to do some shopping, grab some lunch, have some girl time. When she gets home, you're super happy to see her and plant a wet one on her to let her know it. But unless she points it out to you or is gentle enough to drop a few hints here and there, chances are you are NOT going to notice the WHOPPING INCH that she spent seventy five bucks to get chopped off the end of her hair. To her, her hair is her pride and joy, one of the devices by which she measures her own beauty, and the fact that she gave it some attention and paid someone to take off those BLATANT split ends and make it just a wee bit shorter has added to her self-esteem greatly. But for us, though we do see her hair, like to touch her hair, smell her hair... it isn't her hair alone that makes her beautiful to us! In fact, it's rare that we even notice her "girl's hair cut" unless she TELLS us. Why? It isn't because we're blind, or we're not looking at her. It's precisely because we ARE looking at her, and not just her hair, that we do not take special note most times.

You getting it yet? Your woman doesn't care about the dimensions of your outer space, YOU DO; you don't care if your lady dyes, cuts, curls, perms, or straightens her hair: SHE does. I concur that it will take a LOT of mental training and practice for the average male to teach himself to think differently, but guys, it's time we all stop judging ourselves (I say this very generically) by what we perceive ourselves to be or not be packing, and realize that going up one ring size is NOT the ultimate gift. If we spent half as much mental energy on thinking of ways to be better husbands and boyfriends as we do thinking about "what if I were as big as a pop can", we'd have happier partners than we ever thought possible. Investing time in the things she DOES care about...now THAT is "male enhancement".

Just food for thought. :)

Posted by dougboude at 4:03 AM | PRINT THIS POST! | Link | 1 comment
13 December 2008
Movie Review: The Day The Earth Stood Still

Okay, I did what I try NEVER to do and that is to read a movie's reviews before I go to see it. I know, that's what ratings are for, right? To help you make an informed decision about whether or not to invest the time in a particular work. But I prefer to be completely unbiased, aside from whatever impressions the previews tended to give me, before I give myself to a new film. So I did a quick google scan of some of the reviews for "The Day the Earth Stood Still", and saw mostly negative feedback. I have to say, however, that I wonder what kind of lenses those critics used to watch this movie, because apart from what I consider to be a few minor flaws in the plot (rarely does a plot completely satisfy me), this movie was outstanding and i'd have no problem seeing it again tomorrow.

The general plot is that earth is visited by an advanced alien race (just go with it, okay?), who have come to see if it just might be possible to reason with this particular species who is threatening to ruin life for all of Earth's other inhabitants (pollution, war, giving Gore a Nobel, etc.). Well, first thing we do (under a Bush administration, anyway), is try to blow our weary space traveler to kingdom come, shooting him in the chest with small arms fire, and thus sealing the fate of human kind as we know it. The remainder of the movie is spent giving you the pieces of two parellel event lines, one that is an awesome twist on a most timeless story, and the other exploring who we are as a species. In a well planned (by the writers) series of circumstance and coincidence, our self-healed visitor is slowly but surely educated about the "other side" of mankind. Shoot, even one of their own (the only other alien in the movie) who was sent to observe us some 70 years prior consented to the fact that humans were as cuddly and lovable as they were deadly. Some compassionate, logical, teary-eyed scenes later, ET becomes convinced that humankind does indeed deserve the opportunity to evolve at the precipice of his own destruction, and intervenes to stop what would have been our certain demise.

Those scenes of emotion, compassion, logic, reasoning, and tears that I mentioned: all were very believable and flowed seamlessly together. I wish they would have had the sense to give little Mr. Smith a more masculine "do" (long dangly curls on a little boy are somewhat distracting), but the little guy still did an outstanding job in his role as the fatherless child who helps ET connect with his feminine side.

Oh, and I really REALLY loved the sci-fi that was woven in, as far as technologies, special effects (not a whole lot were needed in this particular design, but what was done was perfectly believable in the bounds of my own imagination), and what I believe were some truly original concepts. I won't give away any more of it, but what cooler way can you think of to end all traces of humanity than to create a swarm of auto-reproducing nanobots that behave like locusts and eat not just plant material, but metal, concrete, and flesh? OUTSTANDING!

Oh, one more thing you have to be mindful to do before seeing this movie: erase whatever memory or impressions you may have about the original 1951 version. Just let it go, leave it behind, pretend it was a completely different movie...which it is. Allow this contemporary version of "The Day The Earth Stood Still" to stand on its own merits and I am confident that you will be as satisfied with the investment of time and money as I was.

Posted by dougboude at 1:45 AM | PRINT THIS POST! | Link | 0 comments
Very Useful Snippet

 

<cfset objMojito = createObject("component","bar.drink").init(glassType="24oz");

<cfscript>
   objMojito.add("freshLime",.75).add("crushedIce","toFill").crushAndStir();
   objMojito.add("rawSugar",2).add("crushedIce","toFill").add("puertoRicanRum",2).stir();
   objMojito.add("clubSoda","topOff").garnish();
</cfscript>

<cfset objDoug.consume(beverage=objMojito,rate="moderate",shareWithSpouse=true) />


<cfoutput>#objDoug.getSatisfactionRating()#</cfoutput>

Posted by dougboude at 1:20 AM | PRINT THIS POST! | Link | 2 comments
10 December 2008
Using Database-Driven Configuration Settings in Coldbox
My approach

The Scenario: My Coldbox/Coldspring/Transfer application has settings that I want to make maintainable via a user interface. Now, the Coldbox.xml.cfm file does make provision for me to add as many custom settings as I want to my app, but I don't want to require the end user to know how to edit this xml file (nor would I trust them to). I came up with a solution to this challenge that I'm really happy with, so I thought I'd share some snippets in case it proves useful to others.

Step 1 is to ensure that you have a table designed to hold these configuration settings. My database has a table named "configuration", with the fields ID, settingName, and settingValue.

CREATE TABLE [dbo].[configuration](
 [id] [int] IDENTITY(1,1) NOT NULL,
 [settingName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 [settingValue] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [configuration_PK_UC1] PRIMARY KEY CLUSTERED
(
 [id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF

Of course, make sure this table is registered in your Transfer.xml.cfm file:

<package name="configuration">
 <object name="configuration" table="configuration" >
  <id name="id" type="numeric" generate="false"/>
  <property name="settingName" type="string" column="settingName" nullable="false"/>
  <property name="settingValue" type="string" column="settingValue" nullable="false"/>
 </object>
</package>

Next, I had to find the equivalent of the "onApplicationStart" within my Coldbox app because it is on application start that I wish to read in and load my settings. In Coldbox, this is an interception point named "afterAspectsLoad", which runs during application startup just after all plugins are created (important in my case especially since I'm relying on the "ioc" plugin to get Transfer for me). In order to leverage this interception point,  you'll need to create an interceptor and drop it in to your "interceptors" directory. Here is the interceptor I created that loads up my app's settings:

<cfcomponent name="customConfig"
    hint="I load settings stored in the database"
    output="false"
    extends="coldbox.system.interceptor">
   
 <cffunction name="Configure" access="public" returntype="void" hint="" output="false" >
  <cfset instance.ioc = getPlugin("ioc") />
 </cffunction>
 
 <cffunction name="afterAspectsLoad" access="public" returntype="void" output="false" hint="I load in any application settings from the database">
  <cfargument name="event" required="true" type="coldbox.system.beans.requestContext" />
  <cfset var qryConfigSettings = instance.ioc.getBean("transfer").list("configuration.configuration") />
  <cfset var tmpVal = "" />
  <cfloop query="qryConfigSettings">
   <cfif isJSON(settingValue)>
    <cfset tmpVal = deserializeJSON(settingValue) />
   <cfelse>
    <cfset tmpVal = settingValue />
   </cfif>
   <cfset setSetting(settingName,tmpVal) />
  </cfloop>
 </cffunction>
</cfcomponent>

As you may have noticed, I'm allowing my setting values to be JSON strings if needed, just in case I want to pass in an array or structure of values for a particular setting.

 

 

The last item of business is to let Coldbox know that our interceptor exists. We do this by registering it in the <Interceptors> section of Coldbox.xml.cfm, like so:

<Interceptor class="myapp.interceptors.customConfig" />

That's it! re-initialize your application (&fwreinit=1) and all of your settings will be available anywhere within your app.

 

Posted by dougboude at 3:54 PM | PRINT THIS POST! | Link | 0 comments
Element.show/hide anomoly in Prototype

I am a lover of the Prototype Javascript framework, I must say. But today I found a rather irritating little tidbit that diverted my attention from "real" work. Thought I'd share it just in case it saves someone else a little hair pulling.

The Scenario: You have a button that, onClick, performs an Ajax.Updater call. For aesthetic reasons, you have a hidden div with a spinner gif in it that you unhide while the call is working, then when complete, you hide it again. A common practice, right?

<div id="working" style="display:none;"><img src="images/spinner.gif" /></div>

Well, when I initially laid out my page I just put my css styles inline until I got them the way I wanted. Afterwards I moved the styles out to an external file. That's when I noticed that my "working" div was no longer showing during the ajax call. The call was taking place, the JS function that performed the call hadn't been touched, yet no spinner. Here's my Ajax call:

new Ajax.Updater('targetDiv','index.cfm?param1=bla),{
 method:'post',
 onCreate:function(){
  Element.hide('container1');
  Element.show('working');},
 onComplete:function(){
  Element.hide('working');
  Element.show('container1');
 }
}
);


Having nothing else to try, I removed the style from my external file ( #working{display:none;} ) and put it back inline with my div tag (<div id="working" style="display:none;">...) and voila! I get my spinner again. Ah, one more thing to try...let me put the style back in the external sheet and then modify my onCreate callback function a little:

onCreate:function(){
Element.hide('container1');
$('working').style.display = 'inline';}

Manipulating the display setting more directly, NOW I get my spinner again. Sheesh, so what's the Element.show method doing, anyway? I dig through prototype.js and find that, while the 'hide' method is setting the element's display property to 'none',  the 'show' method is simply setting the display property to ''; nothing, empty string. Which works fine as long as my style is defined inline, but moving to an external style sheet breaks it. I observed this behavior in both IE and Firefox, current versions, so I don't believe it's a browser compatibility issue.

 

The short quick answer is, you have three options for being able to properly show/hide elements using Prototype:


1. keep the display style inline for elements you want to show/hide';
2. move your style external, then use the more direct method of swapping display styles ($('mydiv').style.display = 'inline');
3. move your style external, omitting the 'display:none' item, and use Prototype itself to hide the element on page load, like so:

<script>
 Element.observe(window,'load',function(){Element.hide('loginWorking');});
</script>

If you let Prototype do the hiding, it shows and hides just fine.

 

Thoughts?

Posted by dougboude at 2:49 PM | PRINT THIS POST! | Link | 1 comment
07 December 2008
Coldbox Interceptors and Custom Interception Points Demystified

Although ANYTHING you could ever want to know about coldbox is definitely in its documentation, I find that it is still necessary sometimes to have to piece things together bit by bit..."...line upon line, line upon line; here a little, and there a little:...." as the prophet Isaiah said... in order to fully comprehend them. In this post I'd like to share what I have distilled from the docs regarding the subject of using interceptors and custom interception points in Coldbox.

The Scenario:  you are building your first Coldbox app and you decide that you want to generate your navigation from your database only after the user has authenticated (before that, they get no nav). How we retrieve and/or create our navigation isn't relevant to this post (I'll likely be sharing my navigation interceptor in another post), but WHEN and WHERE creation occurs IS, so allow me to break it on down as I have come to understand it.

If you weren't already aware, an interceptor in Coldbox is simply a CFC with methods that can be executed anywhere in the Coldbox request lifecycle, independent of the logic you already have "hard coded" to run for that event. In terms that we can all probably relate to, think of interceptors in EXACTLY the same way that you think of application.cfc. You know that code within that CFC will run "just because the file exists" and you don't have to explicitly call it in your app. Methods like  "onRequestStart" or "onRequestEnd"...their code automatically gets executed at specifically defined moments in the request's lifecycle simply by virtue of their name and the CFC they happen to live in. Same with a Coldbox Interceptor, except unlike application.cfc, you have to tell Coldbox that your interceptor exists first.


It's important at this point that we briefly talk about interception points in Coldbox. You know what "onSessionStart" is, you know what "onRequestEnd" is, you know what "onError" is, etc. ... well take a gander at "preRender". This is an interception point built in to Coldbox that "happens", or is announced, before content is rendered as viewable. (On a side note, there are a whole lot of OTHER interception points that exist natively in Coldbox; you should take the time to read through the list of them in the docs before you start developing.) In order to take advantage of "preRender" then and make something happen at that point, I have to do three things:

1. Create an interceptor CFC and drop it into my "interceptors" folder in my Coldbox app;
2. Create a method in that interceptor called "preRender";
3. Register my interceptor in Coldbox's "coldbox.xml.cfm" file so that the framework knows it exists.
how to register a custom interceptor...

<Interceptors>
 <Interceptor class="myapp.interceptors.navigation" />
...

Voila! Now every time a request is made, whatever code I have in my "preRender" method in my interceptor will execute! In my case, "preRender" in my navigation interceptor is going to generate and make my navigation available to the rest of the app.

Okay, I said in my scenario description that I only wanted my navigation created IF the user was authenticated. Of course you can guess that my "preRender" method does a check to see if that has occurred or not, and acts accordingly. But, what about the actual login event itself? If you trace the process, the user will be authenticated AFTER the preRender event, and so even though they have successfully logged in, will NOT see the navigation! Not kosher.

I dealt with this by using one of Coldbox's "Custom Interception Points". At first, it seemed like such a  foreign idea that little ol' me would have the power to add an interception point within the request lifecycle. After all, weren't things such as "onRequestStart" items that only the framework or the CF Server itself had the privilege of manipulating? But here's where the mystique of interception points, even those used in application.cfc, went away for me. (Hopefully you are familiar with the children's game "Red Light/Green Light", because my understanding and explanation of an interception point is based on it). An interception point is nothing more than a framework or CF Server playing a game of "red light/green light" with our app. The call to the app (http://myapp/?event=index) is the little kid, running forward like he was told to do. At certain points, though, the framework calls out "greenlight!", and any bit of your code that you had set up listening for "greenlight" (containing a method called "greenLight()") executes, right there and then, independent of the code associated with the event being called, and even before the request itself has completed. In my case, then, all I did was write a bit of code in my login process that called out "onLogin!" as soon as authentication occurred. I then added a method to my navigation interceptor called...what do you think? Yep, "onLogin", that made sure the navigation was available for the user at the end of the request. Here, then, are the steps to adding and using your own custom interception points in Coldbox:

1. Tell Coldbox that you would like to use an interception point called "onLogin", or "onLogout", or whatever you want to call it;
2. Add a line anywhere in any of your handlers (controllers) that ANNOUNCES your custom interception point;
3. Create one or more methods in any of your interceptors named the same as your custom interception point.

That's it! Here are some code snippets of where and how to do each of the three steps above:

1. In coldbox.xml.cfm, in the "Interceptors" section, add a line like the following:

<CustomInterceptionPoints>onLogin,onLogout</CustomInterceptionPoints>

 

2. In your handler (controller), announce your interception point like so:

<cfset announceInterception('onLogin', icData) />

 

(icData is a structure containing whatever values I want to pass along to my interception methods)

3. In your interceptor(s), create a method like so:

<cffunction name="onLogin" access="public" ....

 

That's it! Hope it wasn't TOO confusing...it took me a while to really wrap my head around the flow of it all, but once you do it's not so bad. If anybody has anything to add, or if I've left you scratching your head, please feel free to comment.

Doug out

Posted by dougboude at 2:32 AM | PRINT THIS POST! | Link | 3 comments