the singularity of being and nothingness
Archive for January, 2012
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 >
Learning Ruby: Day 2
Jan 13th
Day 2 of my journey to learn Ruby covers 3 koans: nil, objects, and arrays. If anyone is interested in how I’m running the koan tests, I am simply loading the base-level path_to_enlightenment.rb file from Terminal, and I’m using Xcode to modify the individual koan files. Yes, I said it. I’m using Xcode.
Don’t be a hater. It was the program that opened when I double-clicked the first koan. It seems to work fine for what I’m doing. Will I try other editors? Probably. Are there better ones? I’m sure there are (VIM, maybe?), but I’ll never know which is the best until someone leaves a comment and tells me which one is best!
Alright, enough of that. On to the koans!
Crazy, Interesting NilWhen I saw nil, I thought, “oh, this is NULL”. A keyword, placeholder, something special that represents no-thing. In Ruby, though, nil is interesting, if for no other reason than that it is an object. Yep, an object…definitely not “NULL”.
As an object (e.g., nil.is_a?(Object) == true), nil has its own methods. Consider the following:
nil.to_s => "" (e.g., nil to string == empty string) nil.to_i => 0 (e.g., nil to integer == 0)
So in a scenario in which you have to deal More >
Learning Ruby: Day 1
Jan 12th
So, 11 days into the new year, and I’m actually still going pretty strong with my resolution to make time for learning new (to me) development skills. Yay!
Recently, I was working on a small project where I needed to emulate some of the color transformations from SASS in JavaScript. In order to do this, I needed to dig into the source code, written in Ruby. I was able to suss out what I needed easily enough, but the syntax and approach in Ruby intrigued me. So I figured, what the heck, let’s learn Ruby!
Getting StartedI wanted to start small and easy, so after installing Ruby, I followed the nice and accessible “Ruby in Twenty Minutes” tutorial at the main Ruby site. It’s nothing earth-shattering: your typical “Hello World” turned “Say Hello to Everyone” introduction. However, the tutorial is easy to follow, gives you a nice overview of the some of the syntax conventions that are to come, and (at least for me) leaves you wanting to continue with exploring Ruby.
Where to Go From HereAs with any language, the obligatory “Hello World,” while giving you a taste of the language, does very little in the way of actually teaching you what Ruby is More >
ColdFusion Queries to ExtJS Data Models
Jan 8th
I love data Models in ExtJS. They are extremely simple to use, but are amazingly powerful for driving robust JavaScript applications. In fact, I’ve gotten to the point where I use them in just about everything I do, and they are fast becoming an indispensible part of my JavaScript development approach.
A big part of the appeal of ExtJS data Models is their flexibility. While some data “plugins” in other JS frameworks certainly allow you mimic some of the behaviors of a data model, ExtJS’ data Model wins hands down because of its extreme flexibility. With a ExtJS Model, you can quickly and easily create powerful definitions of data objects (fields, data types, associations, validations, etc.) in your application. These models can then in turn be used to craft a data Store, which can themselves be plugged into many of ExtJS’ data components (DataView, Grid, Chart). What you end up with is a super-powerful, deeply-data-driven application in a ridiculously small number of lines of code.
Of course, the perfect complement to the simplicity and grace of ExtJS’s data Model is to “feed” it using ColdFusion. Below, I’ll outline how to retrieve data from CF, as well an extremely easy way (there are More >
Sugar: A Bit of JavaScript Sweetness
Jan 5th
Twitter never lets me down 🙂
Today, I stumbled upon Sugar, Â a really nice–and small–JavaScript library. Unlike monster libraries such as jQuery and ExtJS (which are awesome in their own ways…), Sugar is narrowly focused. It’s niche is simply extending native JS objects with intuitive methods.
So want to capitalize the first word in a string? Easy: string.capitalize(). Want to replace dashes/underscores with spaces? Nothing to it: string.spacify().
I’ve worked up a quick couple of demos of a few of the string methods, just to show how dead simple Sugar is to use. Of course, you should check out Sugar’s API for the full enchilada. Mmmm, enchildas…
ImpressionsWhile I am a die-hard ExtJS user, there is something about the simplicity of Sugar that I really like. While it certainly won’t give you the tools to build a full-fledged web app with components, data grids, and what-not, it’s perfect for the small or one-off websites/pages where JS’ native objects could use some extra lovin’.
The one drawback (and it’s a slight one) is that there does not appear to be a way to do a custom build of Sugar to include *only* those methods which you need. According to their blog, this is because of some internals of Sugar More >
Resolutions and Stuff
Jan 2nd
I’m not big on resolutions. When I’ve made them in the past, I typically last about 3 whole days before they’re broken and forgotten. Besides, there’s something a bit odd about resolutions anyway. After all, why would we wait until a New Year to do something (lose weight, exercise more, etc.), when it makes a lot more sense to do these things *before* the year begins so that we have the benefit of whatever change for the whole year?
Ah, but that’s the neurosis of the Western mind; what can be done about it? Nothing 🙂
But even though I’m reticent about making resolutions, I have been thinking about the year that lies ahead, particularly from a professional standpoint. Over the last year, I’ve been very productive in my professional development. Particularly in relation to ColdFusion, JavaScript and SQL, I have tremendously expanded my competency, and I feel quite comfortable with where I am as a developer.
However, as we all know, complacency can be a silent killer. While it may not immediately harm a person in relation to their employment prospects, it can be detrimental in the long-term, if nothing else than by souring them to the prospects of learning new skills, More >