Most Retro Coffee Table Ever... NES Controller Coffee Table

Categories: Potpourri

Oh snap. Someone built a giant work NES controller that doubles as a coffee table. Pretty sweet:

Here's video of the coffee table in action while they play Super Mario Bros.

Getting the URL/web folder path in ColdFusion

Categories: HTML/ColdFusion, Source Code

Raymond Camden blogged about a question someone had about getting the folder path for the current template. While Raymond addressed how to get the OS path, how would you get the URL path? So, if you had your user was on the URL http://www.example.com/some/folder/and/file.cfm, how would you go about getting the "/some/folder/and/" path?

While there are always many ways to solve a problem, I've tried to come up with a solution that should work for any version of ColdFusion from 6.0 and above. I wanted to avoid using CGI variables (since those vary by webserver,) so I went with using getPageContext() instead.

Here's the solution I wiped up:

<cffunction name="getWebPath" access="public" output="false" returntype="string" hint="Gets the absolute path to the current web folder.">
   <cfargument name="url" required="false" default="#getPageContext().getRequest().getRequestURI()#" hint="Defaults to the current path_info" />
   <cfargument name="ext" required="false" default="\.(cfml?.*|html?.*|[^.]+)" hint="Define the regex to find the extension. The default will work in most cases, unless you have really funky urls like: /folder/file.cfm/extra.path/info" />
   <!---// trim the path to be safe //--->
   <cfset var sPath = trim(arguments.url) />
   <!---// find the where the filename starts (should be the last wherever the last period (".") is) //--->
   <cfset var sEndDir = reFind("/[^/]+#arguments.ext#$", sPath) />
   <cfreturn left(sPath, sEndDir) />
</cffunction>

If you just call getWebPath() it will return the current web folder path for the current base template.

We use a regular expression to strip out additional path info information that can sometimes be present for people using SEO-friendly URLs. For example, the URLs on my site appear like: http://blog.pengoworks.com/index.cfm/2006/9/27/CFMX-UDF-Parsing-a-URI-into-a-struct which returns a path of /index.cfm/2006/9/27/CFMX-UDF-Parsing-a-URI-into-a-struct. We need the regex to find the last period in the string and assume everything else is additional path info. The default regex should work in the vast majority of cases, but you can adjust it for the corner cases.

You can also manually supply a path such as: #getWebPath('/index.cfm/2006/9/27/CFMX-UDF-Parsing-a-URI-into-a-struct')#. This would return "/" as the web path.

Anyway, hopefully some of you will find this little UDF useful.

Week 11 - Nikki got the "Ok" from the surgeon...

Categories: Personal

I haven't really had much to give in terms of updates on my Black Lab Nikki's recovery. The first couple of weeks were a bit rocky, but after that things calmed down and recovery was just slow (but generally uneventful.) She really handled being couped up much better than I imagined she would. She's just such a high energy dog, I thought she'd drive us crazy being confined to her kennel. I think the fact that I took her on 4-5 walks a day helped a lot. While most of the walks were relatively short (mostly just up and down our street,) it allowed her to get out and burn off some energy.

On Wednesday I took Nikki for her 10 week checkup (which was actually on week 11.) The surgeon who performed the double bilateral TTA is doing a paper on healing after the 6 week period, so I've been taking her in every couple of weeks to get new X-Rays done. Since this was part of a research paper he's working on, they haven't been charging for the visits or X-Rays.

After looking at the X-Rays, he gave us the "Ok" to let Nikki resume normal activities. She's allowed to do whatever she wants, but he wants us to limit her amount of activity for the first couple of weeks. He basically wants us to keep physical activities under 2 hours—which quite frankly shouldn't be an issue.

So, last night I finally got to play fetch with both our Labs in the backyard. She's running a little funky still—she short of hops her back legs. I expect as she's able to really stretch things out and regain complete range of motion of her back knees she'll return to full stride. The doctor warned us she'll probably show signs of limping for the first couple of weeks if she plays hard and not to be concerned unless it doesn't go away after a night's rest.

Well our pocket book is much lighter, we finally got our Nikki back. :)

UDF: Convert ColdFusion Date to JavaScript Date Object

Categories: HTML/ColdFusion, Source Code

I had the need to convert a ColdFusion date/time stamp to a JS Date Object. I thought serializeJSON() function would handle this, but it turns out it treats CF date/time variables as strings. The toScript() function will convert CF variables to JS Date Objects—provided that the date/time variable is in ODBC format (i.e. {ts '2008-05-02 13:32:16'}.)

However, I wanted something that would work for anything that ColdFusion saw as a Date object, so I just whipped out this little 4 line helper function:

function jsDateFormat(date){
   if( isDate(date))   return 'new Date(#year(date)#, #(month(date)-1)#, #day(date)#, #hour(date)#, #minute(date)#, #second(date)#)';
   else return "null";
}

If ColdFusion doesn't see the date as a date object, then it'll set the date/time to "null". To use this function you just do:

<script type="text/javascript">
var today = <cfoutput>#jsDateFormat(now())#</cfoutput>;
</script>

This would then generate the following:

<script type="text/javascript">
var today = new Date(2008, 4, 2, 13, 32, 16);
</script>

Obviously this is pretty straightforward, but it's saved me a lot of repetitive typing today and simplified the readability of my code.

Outlook errors when retrieving mail from POP3 server

Categories: Potpourri

A problem I've been having more and more frequently is that I'll get a piece of spam in my POP3 account which Outlook is unable to process. This causes Outlook to keep downloading the same messages over and over from the server and it's unable to grab the latest messages.

Fortunately I found a nice little freeware utility years ago called Vallen POP3 Mail Checker that allows you to connect to a POP account and remove delete messages setting in your spool. This little utility works really great and doesn't require any installation—you can just unzip the exe into a folder and run the pop3.exe.

This little utility is also great for checking other miscellaneous POP3 accounts. I use it to occasionally connect to account that are set up for automation, so I can delete a message if it's causing problems with the server.

Anyway, since I just had to run this program again to delete some spam from my mail server, I thought I'd post about this great little tool.

Extreme Reunion, New Album and Summer Tour...

Categories: Music

Well, this isn't exactly news, but it's news to me. Extreme has wrapped up a new album and is planning a Summer Tour (rumored to be with King's X and possibly Living Color.) The album is scheduled to be released "Spring 2008."

Now this news really excites me. I thought III Sides to Every Story and Waiting for the Punchline were two of the best albums in the 1990s and was extremely sadden when they decided to part ways. If you listen to Extreme's albums from their first album to their last, they just kept getting better and better. So I'm really excited to see what the new album we be like.

Being a big fan of Extreme, I followed Gary and Nuno's post-Extreme careers pretty closely. While I've always loved Nuno's guitar work, I was never a big fan of his post Extreme work. I thought Schizophonic was a decent album. I've listen to all his other projects (Population One, Mourning Windows, Dramagods,) but nothing really hooked me like his work with Extreme.

Gary Cherone on the other hand has done several things I've really loved. I thought Tribe of Judah's Exit Elvis was a great album. I also really dig the EP he put out titled Need I Say More—which is sort of an adult contemporary, funk, pop thing. The song Love Got Left Behind's got this really cool funk/Sade vibe to it. I actually really love all the songs on that EP (which you can buy/download from either iTunes or Amazon,) but don't expect anything that really resembles Extreme (except for maybe the title track, Need I Say More which definitely has a When I First Kissed You/More Than Words vibe to it.)

Anyway, here's to hoping the new Extreme album continues the excellent trend that Pornograffiti, III Sides and Punchline all set.

UDF for converting a PDF page to Images using CF8 & Java

Categories: HTML/ColdFusion, Source Code

I'm working on a project where I'm trying to create thumbnails for documents the user uploads. Since CF8 has introduced the <cfpdf /> tag, I thought it would be pretty straightforward to turn page 1 of a PDF into a thumbnail image—turns out I was wrong.

While the <cfpdf /> does work, it was causing me to jump through some various hoops some of which I could easily overcome. The issues I had were:

I'm F*cking Obama!

Categories: Humor

This is a really well done parody of the Sarah Silverman song...

Preview: jQuery Multicolumn Dropdown Plug-in

Categories: jQuery

One of the UI components I'm in need of from time to time, is a hierarchy tree where the user needs to select an option. While there are plenty of "tree" scripts, they take up a lot of screen reality and involve lots of clicking. I've always thought I could come up with a better UI component, so we started working on script that would create downdown component that supported hierarchical data.

The problem with doing a dropdown is that if you have a lot of data (which is often the case for us) data really quickly rolls off the screen. To resolve this issue, we split the list into multiple columns when there's too much data. Here's a screenshot of what the dropdown looks like:

Multicolumn Dropdown Screenshot

This is for all the "Ladies of the World" (and the men too...)

Categories: Humor, Music

CNET is giving away downloads to two Flight of the Concord tunes—Ladies of the World and Business Time. If you're unfamiliar with this band, the best way I can describe it funny funky melodic music.

Keep an eye for more contests like I ran yesterday...

Categories: Personal

Yesterday I ran an announced "contest", which was a simple post of "Speak the word." Although know one knew it was a contest, Jim Priest won being the first person to correctly respond with the answer "Revolution." Jim won a gift off his Amazon Wishlist.

For those of you who don't understand the answer, it's a reference to the song Speak by Queensryche—off their masterpiece Operation Mindcrime. While this was a pretty obscure reference, I knew enough of my readers had pretty similar tastes in music so I thought someone would get the reference. I was a bit surprise Jim got it right off the bat, but it's also what I was hoping would happen.

I got the idea while walking my dog over lunch and listening to my iPod. One of my good friends and I used to play a "game" where we'd just walk up to each and quote some random lyric and you were expected to answer. So, I might pass him in the office and whisper "Speak the word" and I'd expect him to whisper back "Revolution." Anyway, I thought I'd post something to my blog and see if anyone else got the reference. I then decided to make it into a little contest.

I plan to run more of these seemingly random contest, so keep an eye for them. They'll be cryptic postings and I'll provide clues if needed. I'm not sure how often I'll run the contests, but as long as your reading my blog on regular basis, you won't miss it.

As far as the content for the contests, who knows what it'll be. I'll try to make them either broad enough for everyone or at least try to make sure I'm not focusing on a specific genre. I won't do anything to explicitly mark the entry as a content, but it'll be something that appears very cryptic or sound like a riddle. You'll just have to keep reading daily to watch out for the contests. :)

Speak...

Categories: Music

The word.

Finished jQuery Tablesorter mod for Collapsible Table Rows

Categories: jQuery

I've been pretty quite the past two weeks. I've been really plugging away doing a lot of client-side UI programming in jQuery. I'm working on a complete revamp of some portions of our application and than means modernizing the UI.

One of the tasks I needed to accomplish was to create a UI component that would allow for sortable, collapsible table rows. jQuery already has a very good (an official) plug-in for sorting column rows called tablesorter.js. The Tablesorter is part of the jQuery UI project and allows for sorting of multiple columns—which is a really nice feature.

However, the current tablesorter.js codebase does not have anything in place to allow for "children" rows—which is needed to provide a collapsible architecture. Essentially I need a way to tell certain rows that they belong with the row above.

After playing around with some different variations I finally came up with a solution that worked elegantly and had minimal impact on the Tablesorter codebase. The way I solved the problem is to add a class to "children" rows, which tells the Tablesorter plug-in to include the row as part of the last row that does not have the "child" class. This allows me to actually have multiple children rows, that are all grouped together and ignored by the sorting algorithms.

I'm working with Christian Bach to get the mods added to the official codebase—and it looks like that might happen as early as next week. I've upload my Tablesorter mod and an example of implementing collapsible rows.

The example uses the "Pager" add-on for Tablesorter, just to show my mod attempted not to break backwards compatibility.

If you have any comments, please leave them. They will only help me and Christian in the long run.

Robotic Tennis Ball Cannon is Truly Dog's Best Friend...

Categories: Personal, Technology

I can't even tell you how much my yellow Lab would love this toy. If we set this up in our house, I'd never see her again.

Frozen in Grand Central Station...

Categories: Humor

This video is a couple of months old, but I just came across it (actually my mom sent me a link it.) This is another Improv Everywhere video. The premise on this video is that 200 people all go into Grand Central station and all freeze at exactly the same time and resume exactly 5 minutes later. I'm sure it would have been very freaky to witness in person.

Very cool!