Wednesday, April 29, 2009

Western Digital Passport: Access Denied on Second Computer

My friend Mike recently bought a nice black Western Digital Passport. It's a slick little portable harddrive the problem was it wasn't very portable. Sure he could carry it around, but if he plugged it into a computer other than his it was inaccessible; if you tried to open or explore it gave an "Access Denied" error.

WTF?

Well, it ended up being a fairly simple fix. He updated the permissions on the drive to include the "Everyone" group. For some reason when he first formatted it (NTFS) the only groups that had permission to the drive were his account, "SYSTEM", and "CREATOR OWNER" - but by adding "Everyone" it now works on other windows machines.

So if you're having a problem getting your Passport to work on multiple computers, put it back on the original machine and make sure "Everyone" has "Full Control" access to the drive.

Open "My Computer", right click and pick "Properties" in the context menu. Then select the "Security" tab. Once that is up, click the "Add" button, enter "Everyone" in the field provided, hit "Apply" then "OK".. and voila' you'll be good to go.

Friday, April 24, 2009

When does "0E1234" EQ "00E050" EQ "0"?

You might be thinking never but, as it turns out, you'd be wrong. In CF7 at least this equivalence and many other odd ones can (and will) occur. It is, undoubtedly, kind of crazy and it definitely doesn't make a ton of sense but I'll give you some sample code so you can test it out for yourself. Please try it on CF8 as well and let me know what happens.


<cfparam name="url.idval" default="0" type="numeric" />


<cfset q1 = QueryNew("id,name") />

<cfset QueryAddRow(q1) />
<cfset QuerySetCell(q1,"id","0") />
<cfset QuerySetCell(q1,"name","") />



<cfset QueryAddRow(q1) />
<cfset QuerySetCell(q1,"id","0E1234") />
<cfset QuerySetCell(q1,"name","0E1234") />

<cfset QueryAddRow(q1) />
<cfset QuerySetCell(q1,"id","020302") />
<cfset QuerySetCell(q1,"name","Some Other Row") />


<cfset QueryAddRow(q1) />
<cfset QuerySetCell(q1,"id","00E050") />
<cfset QuerySetCell(q1,"name","00E050") />


<form name="" method="post" action="oe.cfm">
<select name="idval">
<cfoutput query="q1">
<option value="#q1.id#" <cfif q1.id EQ url.idval>SELECTED</cfif>>#q1.name#</option>
</cfoutput>
</select>
<input type="submit" name="btnGo" value="go" />
</form>


If you stick that in a cfml file called oe.cfm and load it you'll notice that all three options with the id "0", "0E1234", and "00E050" are marked as selected. You might be thinking, WTF?

Well, my theory is CF in its' typless glory is treating all of these strings as numbers and, because 0E (or 00E) is scientific notation it is basically treating them all as equivalent to zero (0).

How do you get around this? My simple solution:

<option value="#q1.id#" <cfif "_#q1.id#_" EQ "_#url.idval#_">SELECTED</cfif>>#q1.name#</option>


I wrapped them both in underscores for the purpose of measuring equivalence which forces CF to treat them as strings and voila the expected behavior now occurs.

Monday, April 06, 2009

If You Can't Beat Em...

No, I am not going to say join 'em. I live in Huntington, WV - it's a small city on the western most edge of WV with a population of around 40,000 people. It's a great little place with an abundance of things to do the trouble is it has always been hard to discover what all those things are.

Fortunately, things are changing for the better in that regard. The net is making things much easier and, thankfully, our local newspaper, The Herald Dispatch, is helping everyone by offering up an online event calendar. They have a full time person on staff whose job is almost entirely consumed with keeping the calendar up-to-date. It's fantastic. Sadly, however, it isn't published as an ICS feed; instead the only interface to the system is via their web widget. The staff at the paper are happy to share the widget with websites that want to display the calendar but honestly I just didn't think it was enough.

I really want an ICS feed to be available for that calendar. It has 6000+ events stored in it for the upcoming months and they are each categorized and sub-categorized. By providing a feed for all of these events that can be broken down by category the citizens of Huntington and the surrounding area can keep track of events in whatever fashion they want. If they want to subscribe with Outlook or Google calendar they could and it wouldn't hurt traffic flow via events to the newspapers website at all - instead I think it would have the net effect of increasing traffic.

Fortunately, the folks at the paper agree. In fact they have been great about the idea and instantly bought into it! However, they didn't have anyone available to create the script that would generate the ICS feed from their ad-hoc database of events so I volunteered to do it for them. Amazingly, even though this is an old company, they nimbly accepted my offer and put me in touch with the right guy. That day (last Thursday) I had the schema description, a dump of two months worth of events, and a basic overview of their current calendar's architecture so I could get my work to fold in seamlessly. Last Friday I delivered the first iteration of the script!

Honestly, the script was a piece of cake to write thanks to having a pretty clearly defined standard to write against and the invaluable tool that is the online ICS validator plus a few nudges in the right direction from Wikipedia. Wikipedia has a chart that shows various elements and how they apply to different types of data in the ICS. I used that chart to help navigate the standard which is very lengthy.

I'm not sure when it will go live but I'm super happy the paper was so forward thinking and open to my suggestion and my offer to help. The Herald Dispatch does a great job of being focused on the local community, its news, and needs and I think this is another example that highlights their commitment to the community. I'm thankful that the small team I've been working with has been so helpful and open to my suggestions!