This blog is now obsolete. Go to scott.arbeitman.id.au for all new content.

0

In My Country There Is Problem

| Thursday, September 27, 2007
Apparently there is a problem in my country too.

0

iPhone: Apple should support Google Gears

| Saturday, September 22, 2007
A major criticism of the iPhone is the lack of an SDK, which prevents developers from writing custom applications. The only way for your application to run is via the mobile Safari web browser as a standard web application (HTML + Javascript). So this really raises the question: what do you want to do with an SDK that you can't already? This isn't strictly an iPhone issue, as we could try to develop a framework for all applications regardless of their target platform, i.e. when should one write a web-based application or write a so-called "desktop" application.

Under most circumstances, a web application is probably preferred because:

  • there is no overhead in installing or updating the application

  • data is stored remotely, so it's accessible regardless of where you are or which computer you are using

  • it will run on multiple operating systems with little extra work



So what's missing? Naturally, there are a few things:

  1. Access to other applications, either currently running or otherwise installed on the system

  2. Using the application when no Internet connection is present, although I tend to agree that also think that this has diminishing returns

  3. Security; individuals often think twice about storing private data on third-party servers



I'm probably in the Apple camp with regards to the first point. We don't want applications to interact with each other (or with the Phone OS itself) because this may have security implications for the owner and the network. I don't want to have an anti-virus running on my phone or iPod, to be sure. And I don't want to risk the possibility of my phone being hijacked to run some scams using my voice minutes. The risk is just too great.

So how can Apple help mitigate the second and third point without introducing a complex SDK? Easy! Apple should support the Google Gears on mobile Safari (and regular Safari, for that matter). With Adobe's support for Google Gears in AIR and Apple's adoption, we may see the Gears API become the de facto standard API for occasionally connected web applications.

Wouldn't that be nice?

1

Great New Feature in Opera 9.5

| Thursday, September 20, 2007
People often tease me for using Opera as my preferred web browser. This hurts my feelings.

Recently, Opera released an Alpha version of their 9.5 release. One important feature that I don't see on any changelog is how Opera offers to remember passwords using its "wand". Now, when you submit a form on any site, Opera, like most browsers, offers to remember your username and password. However, this is now done asynchronously so that the page continues to load in the background.

Why is this so great?

If you're like me, you're never quite sure if you've entered the right username/password combination, and you might be hesitant to save the information until you're sure its correct. Now you can be sure you are saving the right info because you can wait for the form to submit and the new page to load.

It's the little things.
0

Funniest Music Ever

| Saturday, July 21, 2007
For those who remember William Hung of American Idol fame, I strongly recommend checking out "Wing", who has a large catalogue of albums available on iTunes.

Update: Most of you probably already knew that there was a whole episode of South Park about this singer. Despite being a South Park fan, I totally missed that one until now.
0

Building a Better CFLOOP

| Saturday, June 23, 2007
ColdFusion 8 introduces slightly improved looping for arrays, as well a new way to loop over the contents of the file. Unfortunately, I don't believe these changes go far enough and, as I'll demonstrate, even better results can be accomplished even with older versions of ColdFusion.

My improved looping tag uses a little known ColdFusion feature, the <cfexit method="loop" /> tag. When used inside a custom tag, this returns control to the top the tag's "end" execution mode. This is ColdFusion's way of allowing custom iterators.

Here's what the syntax of my array looping tag:


<cfimport taglib="/custom-tags/loop/" prefix="loop" />

<loop:array array="#myArray#" index="i" element="e" cycle:shading="light,dark" cycle:odd="true,false" cleanup="true">

</loop:array>


Let me break it down:

  • array: this is the array you want to loop through, just like a regular CFLOOP

  • index: again, just like in CFLOOP, except this attribute is not required and has no defaults. it simply is not set.

  • element: the current item in the array. By default this a variable called element

  • cycle:variableName: the tag sets variableName to one of the values based on current index. This is inspired by a similar function in Rails. For example, in the above example, the variable odd will either have the value of true or false depending on the iteration number.

  • cleanup: This is perhaps the nicest feature. cleanup will remove references to all variables created during the iteration of the tag. This eliminates the need to var-scope lots of variables inside a CFC. By default, this is true.

Update
I've posted the code on github.
1

ColdFusion and YAML

| Tuesday, April 24, 2007
One interseting thing in Ruby on Rails that's sorely missing in ColdFusion is YAML. For those who don't know, YAML is similar to XML or JSON, and is a way to represent complex data or objects. YAML is extrememly lightweight and less verbose than XML.

After a little server configuration, it's easy to turn YAML text in a file into a ColdFusion structure.

I'm using JYaml as my YAML parsing library, but other options are available. Unfortunately, JYaml requires Java 5, which is not the standard ColdFusion operating environment. To remedy this, download a Java 5 JRE and follow Ben Forta's concise directions. Don't forget to put the JYaml jar file in your classpath and restart your ColdFusion server.

Assuming your .cfm file and .yaml file are in the same directory, creating a ColdFusion structure out of it is a easy as:


<cfscript>
Yaml = CreateObject("java", "org.ho.yaml.Yaml");

configFile = CreateObject("java", "java.io.File").init(ExpandPath('.')&"/settings.yaml");

settings = Yaml.load(configFile);
</cfscript>


Dumping the "settings" variable reveals exactly the structure you were expecting.

One caveat: you may experience unexpected behavior when trying to access your struct's properties using dot notation. Instead, use the "associative array" with square brackets option.

So do this:

value = settings['credentials']['username']

not this:

value = settings.credentials.username
2

Site Layouts and Application.cfc

| Sunday, April 22, 2007
A common problem for any site developer is maintaining a consistent layout across pages. Many frameworks have been designed to simplify this. Model-Glue, for example, can handle this by having the site template as the last view included in the response cycle. This a heavy approach if all you want to do is view decoration.

Let's take a look at solving this using the onRequest method in Application.cfc to capture our outputted content, and then placing it within a template. Here's a skelteton onRequest method:


<cffunction name="onRequest">
<cfargument name="thePage" type="string" required="true" />
<!--- Magic will happen here --->
</cffunction>


For those of you familiar with onRequest, you'll know that if we don't manually included the requested page, ColdFusion won't send any content to the browser. This might strike some people as odd, but it opens a world of possibilities. For example, see my previous post on using Application.cfc as the application controller in an MVC framework.

In this case, instead of invoking a method within the Application.cfc, we'll store what ColdFusion would have outputted into a variable using the cfsavecontent tag. We'll then include another .cfm page, which will have access to all the variables in the onRequest function, including the just-saved content of the included page. Thus, the onRequest magic looks like this:


<cfsavecontent variable="contentForLayout">

<cfinclude template="#ARGUMENTS.thePage" />

</cfsavecontent>

<cfinclude template="Layout.cfm" />


Now, the code within Layout.cfm has access to the contentForLayout variable which contains the dynamic region of your page. A simple layout could simply output the content within the HTMl body:


<html>

<body>

<cfoutput>#contentForLayout#</cfoutput>

</body>

</html>

Naturally, you've have a much more complex layout, where you'd include Javascript, stylesheets, a header, footer, etc.

Another very important consequence of this is that your Layout.cfm has access to all the variables available within your Application.cfc so there is no reason which your layout cannot content dynamic content.