existdissolve.com

the singularity of being and nothingness

Follow me on TwitterRSS Feeds

  • Home
  • About
  • CFAviary
  • ContentBox Modules
    • jsFiddle
  • Gloss

ColdFusion 10: Filter Functions

Feb 20th

Posted by existdissolve in ColdFusion

4 comments

In the vein of my last post on ColdFusion 10’s new ArrayEach() and StructEach() functions, there are some other related functions that help with the very common task of filtering arrays, structs, and list. The new functions are ArrayFilter(), ListFilter(), and StructFilter().

Like ArrayEach() and StructEach(), the new filter methods have a “function” parameter (which can also be either an inline function or a named function). However, unlike ArrayEach() and StructEach() which return nothing, the new filter functions return a new array, list, or struct, respectively.

To accomplish this, you need to return a boolean from the function parameter. If the current array element, list item, or structure value matches some criteria and returns “true”, it will be added to the new returned array/list/structure. Conversely, if it fails the criteria and returns “false,” it will be excluded from what is returned.

NOTE:  The array/list/struct filter() functions return NEW arrays/lists/structures. The original arrays/lists/structs against which the filter() functions are called are unaffected.

An Example

Let’s say that we have a simple set of “circles” for a Google+ account which includes a circle for friends, one for co-workers, and another for family. We might model this data like so:

'circles' = {
    'friends': ['Lucas','Phil','Dave','Brian','Dillon'],
    'coworkers': ['Tyler','Mike','Doug'],
    'family': ['Dean','Jared','Jason']
};

Now, let’s imagine More >

ArrayFilter, ListFilter(), StructFilter()

ColdFusion 10: ArrayEach and StructEach, Hooray!

Feb 20th

Posted by existdissolve in ColdFusion

5 comments

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.

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!).

ArrayEach()

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 >

ArrayEach, StructEach

ExtJS 4: Querying Records in a Data Store

Feb 19th

Posted by existdissolve in ExtJS

3 comments

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 >

ExtJS, Model, Store

Grouping in CFLoop…Finally!

Feb 18th

Posted by existdissolve in ColdFusion

No comments

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:
  • Click to share on Google+ (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Share on Facebook (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)
  • More
  • Click to More >
CFLoop, ColdFusion 10

Learning Ruby: Day 6

Feb 7th

Posted by existdissolve in Ruby

No comments

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.

Exceptions

I’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.

Iterations

The 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 >
Koans, Ruby

Learning Ruby: Day 5

Jan 26th

Posted by existdissolve in Cool Stuff

No comments

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 🙂

Constants

The 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 Statements

Ah, 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 >

Koans, Ruby

CSS3 Infographic

Jan 22nd

Posted by existdissolve in Cool Stuff

1 comment

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:

From Google Politics & Elections

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 Here

So 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 Model

If 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 >

CSS3, Flex-box, Infographic

Learning Ruby: Day 4

Jan 19th

Posted by existdissolve in Ruby

No comments

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.

Symbols

While 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 >

Ruby, Symbols

Chunky Checker: Some CSS3 Fun

Jan 16th

Posted by existdissolve in Uncategorized

1 comment

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 Idea

If 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 Markup

This 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 >
Checkbox, CSS3, HTML, Radio

Learning Ruby: Day 3

Jan 14th

Posted by existdissolve in Ruby

No comments

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 Assignments

With 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 >

Koans, Ruby
« First...«678910»203040...Last »
    • Recent comments
    • Popular posts
    • Archives
    • Tags
    • Categories
    • Adobe (1)
    • Audio (10)
    • Books (8)
    • Chrome (1)
    • ColdFusion (64)
      • ColdBox (13)
        • ContentBox (7)
    • Cool Stuff (42)
    • Ext JS 5 (7)
    • Flex (5)
    • General (28)
    • Into the Box (1)
    • JavaScript (95)
      • AJAX (2)
      • CKEditor (3)
      • ExtJS (59)
        • ExtJS 4.2. App Walkthrough (16)
      • jQuery (1)
      • Sencha Fiddle (3)
      • Sencha Touch (9)
      • Spry Framework (18)
    • Microsoft (8)
    • Mobile (4)
      • Sencha Touch (4)
    • Music (26)
    • Parse.com (1)
    • Philosophy (16)
    • PHP (2)
    • Ruby (6)
    • SharePoint (8)
    • Sitecore (5)
    • Social Media (5)
    • Theology (81)
    • Travel (1)
    • Uncategorized (9)
    • Video Games (4)
    • Web Design (45)
      • CSS3 (3)
      • HTML5 (9)
    • Web Development (12)
    • WordPress (1)
    Adobe AIR AJAX Anthropology API Athanasius Atonement Theology Auto-Tune Blog Action Day CD Review CFScript CFSharePoint Christology CKEditor ColdFusion ColdFusion 9 ContentBox CSS Eschatology ExtJS ExtJS 4 Facebook Forgiveness General HTML HTML5 Javascript Koans Linguistics Music Origins ORM Probability Ruby Sencha Sencha Touch SharePoint Sitecore Spry Spry Framework theming Theology Web 2.0 Web Design WordPress
    • September 2017 (1)
    • May 2015 (1)
    • January 2015 (1)
    • November 2014 (2)
    • September 2014 (2)
    • August 2014 (3)
    • May 2014 (1)
    • March 2014 (1)
    • February 2014 (2)
    • January 2014 (2)
    • December 2013 (2)
    • October 2013 (1)
    • August 2013 (2)
    • July 2013 (5)
    • June 2013 (7)
    • May 2013 (11)
    • March 2013 (1)
    • January 2013 (6)
    • December 2012 (2)
    • November 2012 (4)
    • September 2012 (2)
    • August 2012 (2)
    • June 2012 (2)
    • May 2012 (2)
    • April 2012 (3)
    • March 2012 (1)
    • February 2012 (6)
    • January 2012 (10)
    • November 2011 (2)
    • October 2011 (1)
    • September 2011 (5)
    • August 2011 (11)
    • July 2011 (3)
    • June 2011 (1)
    • May 2011 (4)
    • April 2011 (4)
    • March 2011 (4)
    • February 2011 (4)
    • January 2011 (3)
    • December 2010 (7)
    • November 2010 (10)
    • October 2010 (9)
    • September 2010 (8)
    • August 2010 (19)
    • July 2010 (16)
    • June 2010 (17)
    • May 2010 (7)
    • April 2010 (3)
    • March 2010 (4)
    • February 2010 (3)
    • January 2010 (7)
    • December 2009 (2)
    • November 2009 (4)
    • October 2009 (8)
    • September 2009 (3)
    • August 2009 (3)
    • July 2009 (1)
    • May 2009 (5)
    • April 2009 (2)
    • March 2009 (1)
    • February 2009 (1)
    • January 2009 (1)
    • December 2008 (3)
    • November 2008 (3)
    • October 2008 (4)
    • September 2008 (2)
    • August 2008 (5)
    • July 2008 (6)
    • June 2008 (6)
    • May 2008 (13)
    • April 2008 (4)
    • March 2008 (11)
    • February 2008 (3)
    • January 2008 (5)
    • December 2007 (5)
    • November 2007 (2)
    • October 2007 (10)
    • September 2007 (10)
    • August 2007 (9)
    • July 2007 (8)
    • June 2007 (28)
    • May 2007 (2)
    • April 2007 (2)
    • March 2007 (2)
    • January 2007 (2)
    • December 2006 (2)
    • August 2006 (2)
    • July 2006 (3)
    • June 2006 (4)
    • May 2006 (3)
    • April 2006 (4)
    • March 2006 (3)
    • February 2006 (4)
    • Dragonvale Tips and Tricks (60)
    • A Study Bible to End All Study Bibles (42)
    • ExtJS 4.2 Walkthrough — Part 4: Steppin’ in Some CRUD (33)
    • A Little Taste of Spry 1.6 Goodness (22)
    • The Closing of the Evangelical Mind (21)
    • Where No Man Has Gone Before (19)
    • ExtJS 4.2 Walkthrough – Part 3: Under Control(ler) (19)
    • Thoughts on Christian Ecumenism (17)
    • ExtJS 4.2 Walkthrough — Part 11: Executive Dashboard (17)
    • Sencha Touch Theming: Building Our Custom Stylesheet with SASS (15)
    • Uga: Proverbs 17:15 He that justifieth the wicked, and he that condemneth the just, even they both are...
    • existdissolve: You should be able to find it here: https://forgebox.io/view/jsFiddle
    • Terry Riegel: Hello, Do you have a demo?
    • existdissolve: I enjoy cake. Please send it to me.
    • existdissolve: Your request for permission to my RSS feed has been denied.
    • Lipstick Queen: Just want to say your article is as astounding. The clarity to your post is just cool and that i...
    • sahib: Hey So where can i find that checkLogin Method? i mean in what file. i am trying to implement a...
    • Niall O'Brien: Have the routing issues you mention improved with the latest version of ExtJS?
  • My latest tweets

    Loading tweets...
    Follow me on Twitter!
Mystique theme by digitalnature | Powered by WordPress
RSS Feeds XHTML 1.1 Top
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.