the singularity of being and nothingness
Archive for February, 2012
ColdFusion 10 Beta Examples are Live
Feb 25th
I recently created a free ColdFusion 10 Beta hosting account with Hostek.com. It’s pretty awesome, so you should create one too!
Anyway, with that in place, I’ve uploaded my examples of ArrayEach(), StructEach(), and ArrayFilter(). I’ve also put them out on GitHub, so feel free to take a look if it suits you.
Enjoy!
Share this:ColdFusion 10: ArrayEach and StructEach, Hooray!
Feb 20th
Earlier today, I was looking through the “New Functions in ColdFusion 10” doc, and noticed a few gems: ArrayEach() and StructEach(). These are huge, because until now, there has been something of a disconnect between dealing with arrays and structures in CF, and their counterparts in other languages, like JavaScript. All JS libraries (like ExtJS) have “each” methods attached to basic objects which allows you to treat collections of the same kind of thing in a bulk way. Fortunately, CF10 introduces two very handy new methods to apply an “each”-like process to both arrays and structures.
ArrayEach()NOTE: The ArrayEach() and StructEach() functions act on the original array/struct. Therefore, if you make changes to the array/struct within these functions (as in the ArrayEach() example below), the original array/struct will be affected (thanks Andy!).
So, for example, let’s say you have an array of friends’ names, and you want to make the list all uppercase. Pre-CF10, you might approach this by looping over the array, and executing a function at each iteration. Fine, easy enough, and it works. However, with ArrayEach(), you can ditch the clunkiness of the for-loop, and keep everything self-contained to the array. And, you can execute either an “inline” function, or More >
ExtJS 4: Querying Records in a Data Store
Feb 19th
As you come to use data stores regularly within ExtJS applications, you’ll quickly come to realize just how powerful they are. With very little code, you can create robust data repositories that can not only store complex data, but can (perhaps more importantly) drive components within your applications.
At some point, however, you’ll need to retrieve data from your Store in a query-like manner. That is, instead of looking up a record by a known ID or position within the store, you may need to find one or more records based on a search term, a category, or whatever else is required by your app.
Of course, as with everything else, ExtJS makes this pretty simple. Let’s suppose that we have the following Model:
Ext.define("MyApp.model.Bookmark", { extend: "Ext.data.Model", idProperty: "id", fields: [ {name: "id", type: "int"}, {name: "target", type: "string"}, {name: "title", type: "string"}, {name: "category", type: "string"}, {name: "created", type: "date"} ] });
Nothing to crazy here. Just a simple model with some standard kinds of fields for storing data, in this case, “bookmarks.” Now, let’s More >
Grouping in CFLoop…Finally!
Feb 18th
With the public release of ColdFusion 10 Beta yesterday, I thought I’d play around a bit with some of the new capabilities. One of the features added in this release is the ability to group in query loops using <cfloop>.
As expected, this is pretty straightforward, and has the same capabilities as the <cfoutput> corollary. Here’s a quick example:
<cfquery name="qproducts" datasource="somedatasource"> select * from products order by category,subcategory,product </cfquery> <cfoutput> <cfloop query="qproducts" group="category"> <h1>#category#</h1> <cfloop group="subcategory" groupcasesensitive="true" > <h2>#subcategory#</h2> <cfloop> #product#<br /> </cfloop> </cfloop> </cfloop> </cfoutput>
Pretty simple, but something which I know a lot of people have wanted for quite a while. Well, now you have it!
Share this:Learning Ruby: Day 6
Feb 7th
Ah, back to Ruby. Unfortunately, I had to take several days off for personal reasons…or rather, work invading on personal time. Ugh.
But enough of that nonsense.
This day of Ruby is a short one: exceptions and iterations.
ExceptionsI’ll be perfectly honest: I’m lost on this one. I understand parts of it (for example, that particular errors…like StandardError…are subclasses of other errors), but this is a good example where I think the Koans (or probably my brain) come a little short. If I were to stop here, I’d be completely lost when it comes to handling exceptions in Ruby.
Fortunately, the internet exists, and a quick Google reveals that there a dozens of good articles (like this one) about exception handling in Ruby. So I’ve got some reading to do. And you know what? That’s okay. Part of learning is getting frustrated, hitting a wall, and seeking out the answers. I expected this all along, so no biggie.
IterationsThe Iterations Koan is all about looping over arrays and collections (which have the same methods for iterations, btw). As one might exepct, you have most of the standard operations, like “each”, “find”, “select”, etc. The syntax is pretty straightforward:
myarray = ['one', 'two', 'three'] myarray.collect { More >