dans.blog


The miscellaneous ramblings and thoughts of Dan G. Switzer, II

An amazing time lapse video of GTA IV - Liberty City Beats...

I saw this a week or so ago and thought it was worth watching again. Even if your not a fan of the game, I recommend watching the video just so see what an incredible job the guys at Rockstar did creating a realistic environment.

The video contains no violence and just shows some camera panning around the city. In the first scene, just watch the sky. It's amazing how realistically the clouds move and it's cool watching the occasional plane fly over head.


Liberty City Beats

The author of the video had this to say:

"As I was playing the game, I realized the potential for time lapse filmmaking thanks to the day/night cycle and all the varying weather patterns.

This work was achieved by using one particular motorbike in the game (and the odd helicopter) which offers an uncluttered frame, free of any bodywork in shot. The shots required cramp-inducing holds on the controller for sustained periods of time, in order to get slow and steady shots. Slow pans required delicate movement of the thumb sticks. There is no way to cheat it. Everything is done in-game without glitches, just lots of experimentation and patience.

Fortunately, Rockstar Games gave the means to turn off the HUD, etc, and created a world vibrant enough to allow this type of creative outlet."


TIP: The fastest way to open files in Eclipse...

This is not a new tip, in fact I'm pretty sure I've blogged about it in the past, but the fastest way to open a file is via the "Open Resource" dialog box. Pressing [CTRL]+[SHIFT]+[R] opens the dialog box, which allows you to free form type a search string that will show you all the files that match your search string.

This is extremely handy when you know the name of the file you want to open and have lots of resources or just tons of files in your projects. I deal with several really large projects and this is almost always faster than opening the file via the Navigation View.

image


Songs that still give you the "chills"...

Are there songs that still give you those "chills" when you hear them? Maybe it's just a single note or a lick here or there. There are dozens of songs that still invoke that feeling in me. Songs I've listened to hundreds—maybe even thousands of times.

I was just listening to "No One Like You" by the Scorpions. Even though I've heard that song countless times, the open guitar harmonies still make the little hairs on the back of my neck stand up. I love it! I can't help but listen to that intro a couple of times whenever it comes on my mp3 player.


Selectively running SVN hook commands in Windows

I was working on another SVN hook today and only wanted to run some code if a particular folder was modified, just to save some processing time from unnecessarily running an SVN update process. Here's the little snippet I came up with to run in my post-commit.bat file:

SET REPOS=%1
SET REV=%2
SET WORKING_COPY=C:\local\working\copy\path
SET FOLDER_PATH=/path/as/seen/in/SVN/log/output

REM Check to see if a file in our specified folder was edited
svn log %WORKING_COPY% -v -r "%REV%" | find /i "%FOLDER_PATH%" >
nul
if errorlevel 1 goto notfound
    svn update %WORKING_COPY%
goto end
:notfound
ECHO No updates to the "%FOLDER_PATH%" folder detected
:end
ECHO Finished

The idea behind this is simple. We check the log for the revision that was just checked in to see if it contains a specific string—which in this case is a folder path. If the log does contain the string, we update our local copy. If it doesn't exist, we skip that step and just output a message that says no updates found.

Make sure to check out my other posts on using SVN hooks in Windows for more tips and tricks.


GTA IV Tip: Safely bypassing toll booths...

I haven't seen this tip anywhere (because maybe it's too obvious, I don't know) so I thought I'd share it. You can safely bypass paying your tolls driving straight through the middle gap between all the toll booths on a motorcycle. You need to be on a motorcycle, because it's the only vehicle that will fit. :)

Sometimes I don't feel like outrunning the cops and don't like slowing down to pay the tool, so slipping between the booths saves me a lot of time (although I admittedly have been using taxis more and more often—it's just a great way to quickly get from point A to point B.)


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

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

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...

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

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.