Wednesday, January 12, 2011

Strange behavior with CFThread, expandPath and Virtual directories

Just today I was working on a small project and came across some very strange behavior of the 'expandPath' function. I was experimenting with CFThread in an attempt to do some file operations within threads. Something along the lines of this:



In most circumstances, that should work perfectly. calling expandPath like that will return the current path of the running script. And any file named 'file.ext' will be deleted within a separate thread to the running script.

In the scenario I was working in, I was running a script from a virtual directory. For example http://example.com/threadDemo/demo.cfm, where the actual path of the script was C:\Workspace\Demo\src\demo.cfm.

When expandPath is called from within CFThread , it seems to be taking part of the URL, and appending it onto the end of the end of the actual running location of the script. For example, expandPath('.') is will return C:\Workspace\Demo\src\threadDemo, where threadDemo is a virtual directory configured in the webserver (Alias in Apache).

This causes all sorts of problems, because it's a virtual directory, it may not even exist as a directory anywhere on the server.

The example code I used to test this issue is as follows:



Within the thread, i add some data to an array created outside of the thread. When the thread is created, i pass the usual expandPath from outside, and generate expandPath inside the thread. Both different attempts of expandPath are stored in the array. When the thread finishes, it dumps out the array to the browser.

The behavior that I expected is that the two expandPaths would return the same thing. But it seems like the virtual directory is influencing the path that is generated by it.

This was all developed and tested on Windows with IIS, but the same thing happens on Linux/Apache albeit slightly differently. The Alias seems to replace the directory the script is located on, rather than appending it. I don't want to go around screaming "Bug in CF!" but this really doesn't seem to me like what should be happening in CF.

You can see a demo of this code running at http://cf.thomasstiegler.com/demo1/ . This is the very same code as the example above. Have a look and let me know what you think, I'd like to get some opinions on this.

Friday, August 28, 2009

nocCode RIAForge project fixed.

A little while ago, someone brought my attention to the fact that the project link for nocCode on RIAForge was broken. I just added a new link and fixed up the description for it.

Lesson Learned: Don't use Mediafire.

Check it out at http://noccode.riaforge.org/. Though, i don't work on this project anymore because i don't really have a need for it. I had no idea RDS would work at University.

So now i've been using ColdFusion Builder (Which i love by the way) and using RDS to connect to my home PC for developing whilst at University.

Thursday, March 26, 2009

TweetTrail JQuery ColdFusion Project

Recently i have been working on a new project with Paul Kukiel, called "TweetTrail". The concept of this site (Paul's idea) was to allow users to get a list of the most recent tweeters, in order of activity, for any given search term(s).

For a few days, we both had shared ideas and conceptual code until we had something that worked the way we wanted it to, albeit looking terrible considering it had absolutely no theme/images. Which is where most of my work started.

I did to a fair bit of ColdFusion code, but most the functionality was written by Paul. The bulk of my work for TweetTrail was in the interface design and coding. Having previously been a PHP developer, i can say that if this was to be done in PHP, the code would have been at least three times longer. And the code is so easy to understand.

The JQuery work was really fun. JQuery makes smooth animations and AJAX requests such a snap to do. For the avatar profiles in TweetTrail, all that needed to be done was creating a new div element, position it and use the JQuery fadeIn command.



The code then goes on to load the Twitter profile JSON, parses it and then replaces the window HTML with a bunch of generated profile HTML.

We did run into a few difficult problems with concerning twitter HashTags, mainly with the Apache URL rewrites. Unfortunately you can't put URL Encoded characters outside of the query string.

But after a lot of bugs (Some big, but mostly small), feature additions and hard work. We were able to release TweetTrail to the public last night. And it has been actively being searched since.

You can check it out at http://tweettrail.com. Test it out and give us your feedback. Also, if you like it, Digg it.

P.S. The site isn't quite IE6 or IE7 friendly, and possibly won't ever be

Sunday, February 22, 2009

A week with ColdFusion.

As a bit of a recap, I had only just started learning ColdFusion last week after many recommendations. I was a bit reluctant at first but after toughing it out for a day and pushing myself out of my "coding comfort zone", I really began to see it's advantages.

After breezing through the basics, I wanted to get right into actually creating something useful with ColdFusion. Here at university, just about everything besides HTTP is blocked. I've tried many times to use RDP or VNC to connect to my computer, but never got it to work. To be able to work on my home PC from uni would be awesome.

The idea I had was to create a web based IDE which I can put on my web server at home and access from Uni. That way I can have an easily accessible development server and interface that my university can't block, not to mention a way to lessen the boredom of my breaks between class.

In a nutshell, I wanted to have a directory listing on the left hand side, tabs across the top and the code editor itself taking up the rest.

It didn't take me long to realize that the amount of time spent coding in ColdFusion would be the least in comparison to HTML, CSS and JavaScript. Which would generally be a good thing, but it didn't really feel like it was what I had actually set out to do. Instead, I spent most of my time tinkering with JavaScript code to make a tabbed interface for editing multiple files at once.

I tried to make a lot of excuses to get back to working on the ColdFusion portion of the code, like converting blocks of code over to a CFC to be reusable in other sections of the code. CFCs came in handy when I needed to write path security code, to make sure that people couldn't view folders before the IDEs base folder. It was so easy to use that CFC and adapt it for use in other files.

I've always used a procedural mindset when coding in PHP, so using OOP in web development is actually fairly new to me. Needless to say, I'm enjoying it.

The directory and file management code had made extensive use of the cfdirectory and cffile tags, which are so easy to use, especially for deleting non-empty directories with the recursive tag (Which is pretty troublesome to do in PHP). At the moment they are almost the only tags in use.

Also, making a syntax highlighting and line numbering textarea was fairly easy using the EditArea JavaScript library. All that was needed was a normal HTML textarea, an include for the JavaScript file and a single line of JavaScript code to attach the EditArea to the textarea.


I had also wanted to incorporate new technologies (Or at least new to me...) into this project. Over the last week i had heard a lot of good things about JQuery and decided to have a stab at incorporating it into my project. Using it for animating the IDE's tabs was great and it used so little code for it to do what i wanted it to.

It took just a few lines of JQuery code to make a tab fade out and then have the others slide into place when you close a tab. As well as fading tabs in when you open a new one.

As it stands, I'm really into ColdFusion and JQuery. My experiences with them have been great so far. I'm hoping that I can release a demo and source code of the IDE some time soon so that I can get some constructive criticism. But there are some compatibility issues with Internet Explorer, since most of my work this far has been with Firefox.


Until next time,
-Thomas Stiegler.

Wednesday, February 18, 2009

ColdFusion IDEs

Ever since I've been getting deep into coding in ColdFusion, a question that's been on my mind was "What IDEs are out there to make this easier?". When i first started with ColdFusion, i had been using NotePad++ and the lack of syntax highlighting for CF was a little perplexing.

Paul Kukiel had suggested CFEclipse, which i had downloaded and am currently using. I'm really liking the auto completion and syntax highlighting, but i would like to know what other IDEs there are out there and how well they stack up against CFEclipse. Is Dreamweaver CS4 any good for editing CFM?

Any comments would be appreciated.

Monday, February 16, 2009

ColdFusion?

I've recently been tinkering with Adobe ColdFusion 8 after hearing about it from Paul Kukiel as well as being somewhat pressured into it Mark Drew's Twitter Bot, which likes to insult anything that isn't CF, JQuery, Flex or AS3.

Just yesterday i got CF8 from Adobe's site, and it installed relatively easy. I actually thought it might mess up either XAMPP or my Apache settings. But no, it installed fine and I was in the CF Admin interface in no time.

Considering that I'm mainly a PHP programmer, the idea of scripting with Markup/Tags is incredibly strange to me. At first i thought that it seemed like too much trouble, writing out large tags just to do simple things. But on closer inspection, it seems easier to write complex procedures since CF comes with a lot of pre-written functionality.

When i first looked at CF, i never saw the potential for it to be more powerful than PHP. It just didn't look all that flexible. User defined functions looked ridiculously complicated, but then i found out about <cfscript>.

I also really liked how i could easily include a file with a simple tag. For example: <cf_config>, which would include "config.cfm".

Monday, February 9, 2009

Fast Track USB in Windows 7 Beta (Addendum)

After having my previous hack for the M-Audio Fast Track USB running for a fair few days, I have encountered one or two little problems.

These problems don't detract from the performance of the Fast Track USB in any way, but they can get annoying from time to time.

The most serious issue being that when ever you restart your computer, and plan on using your Fast Track USB, you will have to boot Windows7 into the unsigned driver mode as described in the previous post.

Also, you will have to run the "M-AudioTaskBarIcon64.exe" again. So it may be a good idea to run the driver installer, make a copy of all of the driver contents and put them somewhere easy to find. Just so you don't have to run the installer and dig through temporary files every time you want to use ASIO.

I also did have a bit of trouble getting the ASIO drivers to run after rebooting, for some reason the ASIO control panel didn't want to recognize that I had plugged in my Fast Track USB. Even Windows7 didn't seem to get it. I fixed this just by plugging the Fast Track USB into a different port.

Another small issue I've seen is that when I export an MP3 under FLStudio, I get a few ASIO errors after the rendering is completed. If you get them, just click OK and keep working, since the errors don't seem to mean much because everything still works fine anyway.

Anyway, when M-Audio releases proper Windows7 64bit drivers, I'm sure all of these issues will disapear.