the singularity of being and nothingness
existdissolve
This user hasn't shared any biographical information
Homepage: http://existdissolve.com
Jabber/GTalk: existdissolve
Posts by existdissolve
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 >
Learning Ruby: Day 5
Jan 26th
Today’s excursion into Ruby is a short one. The 3 Koans (constants, control statements, and true/false) are pretty basic. However, upon completing them, I am now officially over 50% done with Ruby Koans!
Of course, I am by no means ready to really start doing anything with Ruby. However, I do feel like I am grasping basic concepts, and my journey through the Koans is becoming less of flailing blindly and more of thinking about what I’ve learned and trying to reason through the challenges I encounter. Granted, not impressive, but it is progress 🙂
ConstantsThe first Koan dealt with the concept of constants. The role of constants in programming is pretty well-understood, so there’s nothing difficult to understand about their usage in Ruby…in fact, the Koan dealt mostly with how to access constants (within and outside of their definitions relative to particular classes). I did find a nice, more in-depth explanation of the role and usage of constants within Ruby. Check it out when you have a chance.
Control StatementsAh, what would programming be without control (if, else, for, while…) statements? Probably not worth doing!!
A couple cool things I want to point out about control statements in Ruby.
First, I’m warming to More >
CSS3 Infographic
Jan 22nd
There’s something with me, the weekend, and CSS3…hmm…
On Saturday, Google Politics & Elections posted an interesting infographic about search trends over the last week related to the four remaining GOP Presidential candidates.
Here’s the infographic:
Overall, pretty nice. It makes good use of color, highlights the important details, and avoids loading the graphic with needless frills, pointless content, etc.
The one problem, though, is that it’s simply an image. While it’s nice to look at, it’s kind of boring.
Some CSS3 Up In HereSo as I was internally complaining about how boring the image qua image is, it occurred to me that some simple CSS3 flourishes could really make this nice.
Check Out the Example (note: you’ll need a more recent version of Webkit or Firefox for this to work…)
In this experiment, I’m using a few things I’ve not messed with much in the past: keyframes and the flex-box model.
Flex-Box ModelIf you’re a web designer, you’ve no doubt spent endless hours trying to coax HTML and CSS to do simple things like expand “columns” a particular percentage in width and height. This is a horrible nightmare to endure, and it usually ends in a lot of hacks and more cursing, just to More >
Learning Ruby: Day 4
Jan 19th
I took a couple days’ break from the Ruby train. I had some other things I wanted to do, and darn it, I did them! I also needed some brain-recuperation time. Oh yeah, and I was finishing up the last episode (or 10…) of Nura: Rise of the Yokai Clan.
But now I’m back!
Day 4 of Ruby entails some tasty symbols, regular expressions, and methods.
SymbolsWhile I knew this going in, I’m finding more and more that Koans are a great tool for teaching how to use stuff in a language. What they are not great at, however, is explaining precisely what the “stuff” is.
Symbols are a great example of this gap. They’re scattered sneakily throughout the preceding examples, and seem easy enough to use. However, defining what a “symbol” is by virtue of the Koan itself leaves a bit to be desired.
So I did some reading. I eventually came across a nice article entitled “The Ruby_Newbie Guide to Symbols” by Steve Litt. In this article, Steve makes a helpful, birds-eye exploration of symbols in Ruby, sticking to broad categories and avoiding getting lost in the weeds of over-definition.
I’ll let you read Steve’s article for the full scoop, but my reading of symbols is More >
Chunky Checker: Some CSS3 Fun
Jan 16th
In keeping with my New Year’s resolution to not get involved in “black-hole” projects so that I have more flexibility to pursue fun stuff on a whim, I whipped up a fun experiment in CSS3.
The Main IdeaIf you design a lot of forms, you know that radio and checkbox lists are hard to style. And no matter how perfectly you lay them out, they are still just plain boring. I thought it would be fun to make checkbox and radio lists a bit more fun by going an entirely different route, and by getting a bit more 3D.
Enter “Chunky Checker.” This set of styles takes an ordinary list of checkboxes or radio buttons and converts them into a super-chunky 3D list. As the radios/checkboxes are activated, the particular segment of the list transforms, creating a “depressed” look, sort of as if a button was physically pressed.
The MarkupThis approach is completely, 100% CSS and HTML–no JavaScript whatsoever. Moreover, it uses a pretty standard markup. The following is all that’s needed to recreate the demos:
<fieldset> <legend>Favorite Color:</legend> <input type="checkbox" name="color" value="Red" id="red" class="red"/> <label for="red">Red</label> <input type="checkbox" name="color" value="Orange" id="orange" class="orange" /> More >
Learning Ruby: Day 3
Jan 14th
Wow. Three straight days of the same thing, and I have yet to get distracted or go wandering off into some endless, pointless project. Maybe I’m learning something after all!
Day 3 of Ruby Koans brings 3 new lessons: array assignments, hashes, and strings.
Let the fun begin!
Array AssignmentsWith one significant exception the array assignment koan was pretty straightforward. Dealing with arrays in most languages is pretty straightforward, and the idioms used in Ruby are much of what you’d expect.
A couple interesting things, though.
First, let’s say that you try to access a position in the array that doesn’t exist:
icecream, gummybears = ["Vanilla"] favorite = gummybears
In this example, I’m trying access the “gummy bears” position within the array. However, it doesn’t exist. Instead of annoyingly erroring out, Ruby returns nil. Remember, nil is an object. So no error, but something useful to deal with. Nice.
But the most interesting part in this koan was the brief example of using the “splat operator.” Before deferring to others for an explanation, here’s the example:
first_name, *last_name = ["John", "Smith", "III] last_name = ["Smith", "III"]
In this example, using the splat operator (*) when assigning “last_name” not only assigned “Smith” and “III” to last_name, but additionally transformed them into an More >