I’ve been writing T-SQL for years, and I’ve often found a case where I want to collapse a rowset containing a single column into a comma separated list. I’ve taken a few swags at it over the years, usually involving using a cursor and an accumulator string. Mostly though, I’ve just passed the whole rowset up the toolchain to my middleware, and dealt with it at the ColdFusion level. However, today I found a case where that just wasn’t an option, so I started digging a bit more, and found a great solution at SQLTeam.com. Here’s the basics of their approach:

Say you have user, and a pile of associated permissions, like so:

CREATE TABLE USER ( 
  userId INT autoincrement not null PRIMARY KEY
  username VARCHAR(100), 
  ... 
) 
 
CREATE TABLE UserPermission( 
  userID INT not null,
  permissionID INT not null
)

Now say you want to get a comma separated list of permissions for a given user. You might think of using a cursor, or some other obscure method, but there’s an easy way:

DECLARE @UserPermissionList VARCHAR(MAX)
 
SELECT @UserPermissions = COALESCE( @UserPermissions +',', '' ) + CAST( PermissionID AS VARCHAR(12) )
FROM UserPermission
WHERE UserID = @UserID
 
SELECT USER.*, @userPermissionList AS PermissionList
FROM USER 
WHERE UserID = @userID

Voila, you’ve got a comma separated list of permissions, without using a cursor. For those of you in the NoSQL crowd, you’ll note that really the COALESCE here is functioning very similarly to a “reduce” function from a map/reduce algorithm. This approach could therefore open up some other interesting avenues for design.

I still wish there was a “JOIN()” aggregate function, but until that happens, we’re not totally paralyzed.

  • Share/Bookmark

There’s other (possibly more elegant) solutions out there on the web, but I came up with this today when faced with trying to set the initial “selectedIndex” of a ComboBox whose contents are populated dynamically.  Unlike HTML, it’s not as simple as just marking one of the “options” as selected, but fortunately, it’s not a lot harder.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<mx:Script>
  <![CDATA[
    private function locateLabel( source : ArrayCollection, label : String )
    {
        for( var i=0; i<source.length; i++ )
        {
          if(source[i].label == label ) return i;
        }
        return 0;
    }
  ]]>
</mx:Script>
 
<mx:ComboBox dataProvider="{model.stateList}" selectedIndex="{locateLabel(model.stateList,model.address.state)}" />

This method triggers binding whenever model.stateList or model.address.state changes, and updates the combo-box position accordingly. To me this is a bit cleaner than sub-classing the ComboBox, which was the primary other method that I saw recommended, but I welcome other suggestions, if there’s an even easier method I’ve missed.

  • Share/Bookmark

I’ve recently been looking at developing a cross-platform application on my Linux system for eventual use on Windows and Macintosh.  AIR became an obvious choice, because it’s solid on Windows and Macintosh, and supports Linux pretty well as well. I’m still in the midst of development, but I thought I’d post some of my original thoughts on JS/HTML AIR development on Linux.

After deciding to develop on Linux, and on AIR, the first point that came up was whether to develop in HTML/JS or to use Flex.  Unfortunately, Adobe has made the decision not to support Flex Builder 3 fully on Linux, and the prospects for Flash Builder 4 don’t look good either, so the main reason to use Flex over HTML/JavaScript (namely, a kick ass development environment) isn’t really there in Linux.  I did check out the Flex SDK version 3 and 4 using Ant (and I’ll post some thoughts on that later) but overall, without Flex Builder, Flex Development on Linux is just less appealing.   Given that there’s some really good tooling out there in Linux for building HTML/JavaScript applications, I’ve decided to use that for my current project.

The first step to developing an AIR application is of course to download the AIR SDK from Adobe.  This is available as a download for Linux.  Extracting files from a tarball is probably pretty familiar to Linux users, but in case you aren’t familiar with it, I’ll give a short instruction set here.

  1. Download the file to your home directory (/home/<username>)
  2. Unzip the directory to your temp directory (mkdir /tmp/air/;cd /tmp/air; tar xvjf /home/<username>/AdobeAIRSDK.tbz2)
  3. Copy the AIR SDK to the “/opt” directory. (sudo mkdir /opt/air-sdk; sudo cp -r /tmp/air /opt/air-sdk/1.5.2)
  4. Create a symbolic link to the “current” AIR SDK (sudo ln -s /opt/air-sdk/1.5.2 /opt/air/current)
  5. Create a script to add the environment variables.
  6. 
    
    #!/bin/sh
    export PATH=/opt/air-sdk/1.5.2/bin:$PATH
    #!/bin/sh export PATH=/opt/air-sdk/1.5.2/bin:$PATH
  7. Setup your environment for your main username.  Basically, add to the end of your .profile file “source /opt/air-sdk/current/setup.sh”

At this point, you should verify (by opening a command window and typing “source ~/.profile”) that your profile is working.  If it’s not, fix it and try again.  Once you’ve got it working, log all the way out of your linux account, and log back in again.  This should make sure that any terminals you launch will have access to the AIR tools (ADL and ADT).

ADL

ADL is the primary debugging tool that you’ll use when developing an AIR application.  adl is a Java program, and takes as an argument the Application descriptor XML for an AIR application.

ADT

ADT is the primary packaging and package signing tool that you will use when “compiling” and “distributing” your AIR application.  The adt tool uses the same application xml descriptor as adl, and requires an SSL certificate.  You may generate your own “Self Signed” certificate, but it will be less trusted than a real SSL certificate. Finally, when packaging an application using adt you MUST be connected to the internet.  ADT verifies the current date with several known timeservers to validate that the certificate is current and not expired.  If you are not connected to the internet, ADT WILL fail.

Next time I will get into a description of my project structure, and how to work with the HTML and JavaScript files that make up the AIR application

  • Share/Bookmark

Yesterday Morning, ColdFusion Builder (formerly known as Bolt) was released on Adobe Labs After a day of fiddling around with it, here are my initial impressions:

Distribution

There are three versions listed on Adobe Labs: Macintosh, Windows 32 bit and Windows 64 bit.  Currently there are no Linux versions available, and from comments on the forums, there is no plan to release a Linux version at launch.  This is very irksome, since about 20-30% of the developers I know use Linux as their primary development platform, especially with the news about CF9′s full support of Ubuntu.  Mark Mandel has managed to put together a tutorial on how to install ColdFusion Builder on Linux, so really it looks like Adobe just isn’t willing to hire someone to maintain and Q.A. a linux release.

Installation

Installation comes in two forks, similar to the Flex Builder.  There is a stand-alone version, which installs a new Eclipse 3.4.2 instance, along with the ColdFusion Builder plugin.  The standalone also appears to contain some bits and peieces of Aptana, such as the HTML, CSS, and JavaScript editors, as well as Aptana’s FTP support.   There is also a “plugin version” which only works with 3.4.2, not version 3.5, or 3.4.1.  This means that realistically, you probably aren’t going to be able to use the plugin version if you’ve got an existing Eclipse install, unless your install is almost bleeding edge, but not quite.

First Impressions

As we’ve come to expect from Adobe, the visual experience booting up and running CFBuilder is very good.  Visually, the application looks very nice.  RDS support is basically required to use ColdFusion builder, so anyone who isn’t doing local development will prettymuch have to beg, borrow or steal an RDS password for a shared development server.  Based on the server admins I’ve worked with, if you or your group don’t maintain your own ColdFusion development server, you’re best off switching to Local Development.  It’s just the only way.

The Snippet support is almost identical to what many of us CFEclipse users have come to expect over the years, right down to the $${variable} substituion.  Unfortunately, while the snippets are stored in an XML format, it doesn’t appear to be the same schema as the CFEclipse snippets.  It’s likely a simple .xsl transform could turn all of your existing CFEclipse snippets into ColdFusion Bulder snippets though.

One very nice feature of the ColdFusion development perspective is the “TailView” component, which allows you to watch your log files for new entries.   This is a capability that Linux and Unix users have been very familiar with for years, but which is astoundingly hard to find on the Windows platform.  Integrating it into the IDE is a very nice touch, and allows you to use <cftrace> for debugging very easily.

Speaking of debugging, the stepwise debugger plugin from ColdFusion 8 is included in the install.  I haven’t used the debugger in ColdFusion 8 extensively, but it appears to be integrated seamlessly with the CFML editor view, so that you can set break points.  I’m not sure whether thats an improvement over the CF8 debugger, but it’s certainly very nice.  One caveat, you must make sure that Line Debugging is enabled in your ColdFusion Administrator.  Of course it requires RDS, but it’s definitely worthwhile.  Additionally, the ability to watch expressions and see variable values is really nice, and the handling of CFCs, structures and arrays works very well.  I’m most impressed with the debugging features.

The “Outline” view in ColdFusion Builder is another feature that CFEclipse users will be familiar with.  Unfortunately, the ColdFusion builder team didn’t choose to include the (in my mind) more useful “Object View” which shows which methods and parameters are available in CFCs.

The code assist does a moderately good job of finding variable names to offer up as code completion when typing.  Unfortunately, it only appears to interrogate the current file looking for variables.  It would be nice if (like the Eclipse PHP Development Environment) it searched the library and execution paths to find which classes and variables were defined, and give you code assist for all variables and methods.  However, given the highly dynamic nature of ColdFusion and CFCs, it’s understandable that this is a huge challenge, and hasn’t been implemented.  It would be a clear advantage though, if the team were to implement it.

The “extensions” are kind of nice, but I don’t see them having a large impact on my day to day coding.  They seem to be a great way to stand up a new application in a short time, allowing you to build large ammounts of code quickly, but for the more common “Brown Field” work that makes up 80-90% of my work days, its probably not going to be of much use.

Summary

The Good – Debugging is amazing.  Really good job here. I know some folks will really like the Word Wrapping, which has been a notable hole in the Eclipse platform for a very long time.  The Aptana integration makes editing JavaScript and CSS along with your ColdFusion code very nice and easy to do.  Youv’e got a good start with the code assistance, and I’m looking forward to what will happen in future versions.  Hopefully there will be some even better things to come.

Low Hanging Fruit – The ability to import a CFEclipse Snippet library or connect to a SnipEx server would be nice.  Implementing the CFEclipse “Methods” style view should be pretty easy, and it’s much more useful than the outline view when working with CFCs.

A bit of a pain – Basically requiring RDS support is a thorn in the side of lots of developers in corporate environments.  Corporate server admins read the CF documents that say that “RDS is a security hole in a production server” and think that means that they shouldn’t let developers have access to it.  It’s a long, hard battle that nobody really wants to fight.  Some bits, like the “Service Browser” offer up entirely unhelpful messages such as “Unable to get meta data for cfc.” without any explaination of what could be done to fix it.  Likewise, I got “Unable to fetch server mappings. Reason :null” in my console on startup… What does that mean?  Nobody seems to know.  Fortunately, most of these errors are in places that don’t affect the core usability of the system, but hopefully they’ll be cleaned up a bit before the final release.

The Bad – The lack of Linux support is really a deal breaker for me.  I do about 50% of my development on Windows, and 50% on Linux.  If I have to choose between using ColdFusion Builder 1/2 the time, and CFEclipse 1/2 the time, or just using CFEclipse full time, I’ll probably go with the CFEclipse option.  The lack of support for Eclipse 3.5 puts this solidly behind the curve when it comes to Eclipse plugins.  This is more of a problem with the Eclipse platform, since each yearly release changes so much that every plugin has to be completely rewritten in many cases, but it would be nice if Adobe were to release a plugin that actually works with the newest stable Eclipse version, instead of constantly trailing one release.  Further, because of its narrow focused Eclipse version, even running ColdFusion Builder and Flash Builder in the same eclipse instance may be a challenge.  A little more version compatibility would be nice.

  • Share/Bookmark

So after getting Eclipse 3.5 and Flex Builder Plugin for Windows to work last week, I dug in yesterday to get it working on my Ubuntu system. After reading an invaluable tutorial, I was still getting some odd errors where Eclispe appeared to recognize that Flex Builder was present (it was in the About Box), but I couldn’t get any MXML or AS editors to open.  Poking in to the directory structure, I found that the $ECLIPSE_HOME/links/com.adobe.flexbuilder.feature.core.link file was incorrect.  It appears that Galileo requires the “path=” to be prepended to the path for the core plugin, but Adobe’s default install doesn’t include that part of the file.  After adding “path=” to my link file, it fires up just fine.   Still no design mode, but if we keep bugging Adobe about it, they might add it into Flash Builder 4 for Linux.

  • Share/Bookmark

Several years ago, I had a Capital One credit card which had Van Gogh’s “Starry Night” as the background image.  It was my “Gas” credit card, that I would put all of my gas on, and since I had a 30 mile commute each way, I got to see it pretty often.  My “Starry Night” credit card was a little piece of joy that I got to see whenever I filled up my tank, helping to lighten up my otherwise annoying task of filling up the gas tank.  A few months later, one of my other card companies (Providian) offered to give me a customized card with Seraut’s “Sunday Afternoon on the Island…” and thus, I was on my way to having a wallet full of impressionist paintings.

Unfortunately, when my Capital One card expired, they sent me a new one with the plain Capital One background, and when I called to request the Starry Night background again, they said that wasn’t available with my card.  I grumbled a bit, but gave up after a while.  The next year, my Providian card followed suit, and so I gave up on my dream of carrying the works of the masters in my pocket.  It was allayed a bit when my wife (then girlfriend) picked me up a “Starry Night” skin for my laptop from Gelaskins but I’ve still been annoyed about the whole situation for at least 4 years.

Recently however, I noticed in my Wells Fargo account that I could request a custom design on my Wells Fargo bank card.  “Fantastic!,” I thought..  “I can finally get Starry Night back on one of my cards again.”  Reading over the guidelines, I noted that it would only accept images which you had the rights to personally.  “No problem, ” I think to myself, “Van Gogh died in 1890, and copyright at the time extended for the life of the author + 50 years, so Starry Night went public domain in like 1940, before I was even born.  I’ve got the rights to duplicate it.”  I browse over to Wikipedia, which has a photo of the painting, which, according to their licensing information is in the public domain because the copyright has expired, just as I expected.  So I download the image, send it to Wells Fargo, and submit it.  They say they will contact me within 5-7 days to let me know if my image has been approved.  “Horray,” I think.  “There’s nothing offensive about this picture, it should be a slam dunk!”

Unfortunately, 5 days later, I recieved an email:

Unfortunately, the design you selected does not meet our Image Guidelines. To select a new design, simply sign on at https://www.wellsfargo.com , click the Access Card Design Studio link on the Account Services page, and try again using a design that meets the following criteria.

 WELLS FARGO IMAGES GUIDELINES

 For all images you must:
 * Own the image or have permission from the owner to use the image on your card

Hrm.  I call the number included in the post, and ask to speak to the person who sent the rejection.  They’re unable to let me speak to that person, so I ask to speak to someone else in the card designer department, and they inform me that I can’t speak to anyone in that department.  I ask the person who answered why I’m not allowed to use the painting on my card.  They explain that I must have permission from the author of the artwork to have it on my card.  I calmly explain that the author has been dead for nearly 120 years, which makes obtaining permissions exceptionally hard.

“Fortunately,” I continue, “Copyright on the image expired in 1940, so it’s currently public domain.”

“But we need to have permission from the artist to use their image on a card.”

“He’s been dead for 119 years.  He isn’t in a state to give permission to anyone for anything.”

A short discussion with her supervisor didn’t yield any more progress, so I’ve decided to just submit the image over and over again until someone from Wells Fargo who is actually involved in the approval process contacts me.  I suspect it may take a while, but I just have to re-upload the image to their site once a week until they do.

  • Share/Bookmark

Eclipse 3.5 (Galileo) has recently been released, so I’m in process of rebuilding my development environment to run on it.  I was happy enough to go use the update sites to re-install CFEclipse and MXUnit, and the StarTeam (our company’s chosen Version Control software) plugin was able to seamlessly update the Galileo instance of Eclipse to include it’s plugin, but I ran into a snag when trying to update the Flex Builder 3 plugin.

When originally installing the Flex Builder 3 plugin for eclipse, I used the default path (i.e. C:\Program Files\Adobe\Flex Builder 3 Plugin\).  When I tried to re-run the installer, It reported that I already had a Flex Builder Plugin instance at that location, and would I please choose another directory.  Not wanting to clutter my hard drive with extra copies of the Flex Builder plugin, I decided to poke around and see what I could do to use the existing Flex Builder Plugin in my new Galileo installation.

What I eventually happened on was a very nice, clean way to install a single instance of an Eclipse plugin, and allow multiple copies of Eclipse use it.   It’s pretty straight forward, and assumes you’ve already got a copy of Eclipse installed, and a licensed copy of the Flex Builder 3 Plugin installed.

First off, navigate into your eclipse directory.  Mine is C:\Program Files\Eclipse\Galileo\ .  This should be the folder which contains your eclipse.exe file.  Under this directory, if there isn’t already a directory named “links”, create one. Navigate into the links directory.  Create a new text file named “com.adobe.flexbuilder.feature.core.link”.  Edit the file, and add the following contents to it:

path=C:/Program Files/Adobe/Flex Builder 3 Plug-in

Close the file, and start Eclipse.  Now go into your Window Menu, select “Open Perspective”, and “Other”, and you should see your Flex Development Perspective listed.  It’s even smart enough to pick up the license key from your previous installation, so you don’t have to dig out the old key to reinstall. However, for some reason, when I did this it lost my installed Flex SDKs.  To fix this, I went to the “Window->Preferences” dialog, and navigated to the “Flex->Installed SDKs” option.  I removed the two entries for “Flex 0.0″ which were listed, and re-added the two existing Flex SDKs: c:\program files\adobe\flex builder 3 plug-in\sdks\3.2.0 and c:\program files\adobe\flex builder 3 plug-in\sdks\2.0.1   You must mark one of these as default by clicking the checkmark next to it on the screen.  After this, click Ok, and you should be good to go.

If you’re doing ColdFusion development, don’t forget to also install the ColdFusion extensions for Eclipse at C:\program files\Adobe\Flex Builder 3 Plug-in\Installers\ColdFusion Extensions for Flex Builder, and JSEclipse is also pretty helpful at C:\program files\Adobe\Flex Builder 3 Plug-in\Installers\JSEclipse

  • Share/Bookmark

I saw a “glassless” 3D TV demo at The Bridge on Friday night when we went to go see Watchmen. Looked pretty cool, but there’s still plenty of kinks to be worked out, like viewable angle, and screen distance considerations. It looks like you still have to be sitting at least 5 feet away from the screen, and roughly centered, (though there appeared to be a “pocket” of space about 45 degrees off center that gave 3D too).

  • Share/Bookmark
Sorry for the late posting, I was out watching Watchmen on Friday, and I was busy soldering together my Microrobot Avoider  and Geocaching on Saturday 
  • Engadget has an article about a Japanese fire department which is employing a semi-autonomous robot for rescues. This track-crawling bot can get past very hot areas, locate people trapped by the flames, and carry them to safety. While on board, the bot can monitor the vital signs of the occupant. This may also be used for earthquake rescue.
  • Hack-A-Day has an interesting video of a multi-mobility robot which can either use hexapod ground motivation, or fly using helicopter blades and motives.
  • Continuing with the Helicopter theme, Engadget has an interesting article about flying drone robots which can be deployed to disaster relief areas to supply a wi-fi mesh network and phone service to areas during emergencies
  • Engadget continues to wow us with stories and videos of household assistance robots.  I especially like the arm design on these robots, which allows for greater angular postions for thier arms that many other designs I’ve seen.  
  • I’m still vaguely skeptical that it’s real, but Muckflash is reporting on a humanoid robot which “kidnapped” an intern who was working with it.  The robot had an powerful behavioral engine which made the robot “love” anyone who it saw, and it chose to block the intern from leaving the room, requiring technicians to come and shut it off to allow her to go home.

In my own robotic news, I picked up a Microrobot Avoider Robo Jr.  and soldered it together yesterday morning.  The torque it generates is a bit disappointing, but I’m hoping to use it as a simple wheeled robot platform.  I’m going to put together an adapter plate to attach either my Ardino or AXE117 board to the chassis to drive it.  

Also, i’m working on putting together the parts for a Jansen Linkage on the same Ponoko cutting i’ve built my adapter plate on.  Once I’ve got everything together, and tested, I’ll open source the plate(s).

  • Share/Bookmark

I’m starting a new feature where I post a blog entry each week about interesting news that I find related to Robots.  The theory is to share ideas, and stimulate the imagination of myself and others about robotics.  Not everything may be directly related to robotics, but it should spur the imagination at least.

  • Tech Digest has a very interesting story about using a mesh of inter-dependent robots with a walking surface on top of them to simulate an endless floor in Virtual Reality a la Holodeck.
  • A friend of mine turned me on to Jansen Mechanical Linkages, which could make some very interesting leg actuators for some walking/climbing robots without requiring the extra degrees of freedom which legged robots typically required.  Related to Jansen Linkages are Klann Mechanical Linkages (which are patented).
  • It’s not exactly new, but while browsing the TED website, I came across a very interesting talk by Robert Full about using animal feet as inspiration for building robotic feet.
  • Engadget has a fascinating story about a woman in New Zealand who has realized mankind’s dream of swimming like a fish with the help of a robotic mermaid tail prosthesis.  Not only does it allow this double amputee to swim, but looks really good while doing so.

Finally, just a bit on my own robotics work.  My latest purchase was a PICAXE 14M experimentation board that I’m planning on using as a motor controller for a simple two-wheel castor mobile robot platform.  It has 4 PWM analog outputs and supports I2C, so I should be able to issue commands to it from an Arduino mainboard.  Unfortunately, I’ve discovered that the PICAXE programming cable/circuit doesn’t work properly with the $10 IOGear USB/DB9 adapter I have, so I’m probably going to have to go track down a serial PCI card for my computer.

  • Share/Bookmark