Politics, Programming and Possibilities
29 May
I love digg, but I can’t stand how they make me go to the site for every single article. Use this feed from Georgy Woods instead:
And by the way, if you aren’t already using one, and if you visit several websites a day to “keep up on the news” or to find out if one of your friends has posted some news lately, you should definitely use a feed reader, like NewsFire on the Mac, or Google Reader on the web. (Leah, I’m talking to YOU
)
18 May
I just had a little revelation about my role in the world. I am the handyman of the 21st century—the Mr. Fixit of information technology. While I don’t boast that I have solutions to everything, I’ve come to accept that being a “computer geek” is a high demand position—not just in the corporate world, but in the home as well. And I really do like helping out. Here are a few recent experiences that brought me to see the light.
While preparing for a trip to New York, my sister-in-law, Leah, emailed a letter to all of our family members to organize the agenda etc. One of the plans was to go to see a Broadway show while in NY. Leah asked if I would try to find discount tickets to a show since I seem to know all of the “good places” to look. Since we had just found discounted tickets to Wicked the week earlier, it seemed natural that I might find a similar offer in NY. Unfortunately, I wasn’t successful this time, but I felt honored to be the “guy who knows how to get cheap tickets.” Being able to navigate the web, it turns out, is a very useful skill even outside of the programming world.
As I was driving to the airport this morning to drop Kelty off (she is going to NY for 3 weeks to be with her Mom), she mentioned how grateful she was that my line of work was so useful. Just yesterday, she had accidentally formatted our camera’s SD memory card, erasing gigabytes of irreplaceable pictures and video footage that we had taken recently. She was upset with herself for having done it, and having checked the Canon SD1100’s manual for hope, we had concluded that the photos were really gone. Well, almost. It turns out that even a “format” of the card will not erase the pictures (unless it’s a low-level format, which was not our case). Using a $21 card reader and this free but obscure software, we were able to recover all of our precious memories. Once again, tech skills came in handy.
Then, just as I was sitting down to write this article, I got another call. This time, Leah’s computer would not shut down. Windows had gone through the shutdown procedure but had frozen at the last moment, leaving the system on (you know how it goes). Anyway, I explained that you can just hold the power button down for several seconds and it will force the computer to turn off. And so the opportunities to serve in the home flourish.
What I feel must be something like the handyman’s feeling when he can fix a leaking faucet, replace the spring in the garbage can lid, or maybe rewire a light switch. It’s not that difficult, but the domain knowledge is just specialized enough that it seems somewhat magical to someone outside the domain.
Do we have a new title for this new century handyman? I don’t know. Maybe you can just call me Mr. Fix IT.
15 May
The dubious links have finally been cleaned up from my blog’s feeds. A search reveals none of the key words (e.g. loans, ringtones, porn) that were there before, so all evidence points to things being back to normal.
For the record, I tried to clean things up manually at first, but that quickly became an awful chore: more then 200 posts had been magically “edited” and the nefarious links inserted at the end. So I wrote a script to clean things up, using Ruby and Sequel:
db = Sequel.mysql ‘inquirylabs_wordpress‘,
:user => ‘user‘,
:password => ‘password‘,
:host => ‘localhost‘
posts = db[:wp_posts]
posts.all.each do |p|
posts.filter(:ID => p[:ID]).update(
:post_content => p[:post_content].gsub(
/(<font|<div\sid=wp_internal).*
(porn|
payday[-\s]loan|
home[-\s]loan|
ringtone).*$/x, ““)
end
Much better.
Thanks to those of you who helped me to identify the problem and, recently, to see that I hadn’t scoured all of the dark corners of the website.
29 Apr
I’ve been told that jQuery has been around since January of 2006. At some point during the last year, many developers within the Ruby community began to embrace it as an alternative to Prototype and Scriptaculous. Many of the programmer friends I look up to in the Merb community, specifically, are big advocates of jQuery.
So this post is an attempt at summarizing the strengths I’ve found in jQuery as opposed to the two other javascript libraries that I’ve worked closely with: mooTools and Prototype / Scriptaculous. My motivation for this is a soon-to-be-made decision regarding the javascript library that will be used in a browser-based application that I’m working on at a company in Chicago. The application needs a simple user interface and fairly powerful front-end. I’ve advocated the use of jQuery, and thought it would be useful to set out the reasons for my preference here on the InquiryLabs blog.
There is a fine set of documentation at jquery.com. Scriptaculous hasn’t seen much improvement in its documentation in over a year. Prototype’s documentation is (in my opinion) pretty, but still lacking.
It uses as its central paradigm the idea of “querying” the DOM for the desired elements and returning a collection (like a dataset, but with DOM elements) and then acting on the result, or set of elements. The reason it can be concise is that the element sets are chainable. For example:
documentreadyfunction
for var i = 0; i <= 6; i++
$‘h‘ + i + ‘ [@id]‘eachfunction
$‘<a class=”anchorlink”>\u00B6</a>‘
attr‘href‘‘#‘ + thisid
attr‘title‘‘Permalink to this headline‘
appendTothis;
;
;
(Hat tip, lucumr) In the above example, anchor tags are added to all headlines in the document. Note the clever use of chaining which reduces the size of the code, yet retains its expressiveness.
Whether it’s a simple function or an entire plugin, jQuery is built for extending. The ability to query for “element sets” and then act directly on those results is not limited by the core code. Since it’s so easy to add custom functions to element sets, it becomes natural. For example, I found that I often needed to add or subtract a value from a CSS property. I solved this problem by extending the jQuery core element set, like so:
var value = parseIntthiscssproperty;
return thiscsspropertyvalue + delta + “px“;
;
Using the above code, I can query for a set of elements and adjust the height property (for example) in one fell swoop. This will now add 5 pixels to the height of each “rack-item” element:
$‘.rack-item‘cssDelta‘height‘5;
According to Jeff Robbins and John Resig, the Drupal team chose it over Prototype because it is a mere 15k compared to Prototype’s 80k. The Dojo library is even larger.
Update:I decided to test this out myself to see what results I’d get. Resig’s comment was probably from jQuery’s earlier days when it was a micro framework. As far as I understand, it’s still possible to compress the jQuery library down to 18k or so, but that’s possible for Prototype, too. In fact, my tests show that un-gzipped, compressed code gets both down to 51k using Dojo’s ShrinkSafe online app.
Update 2:Thanks to Peter Higgins below for commenting on the size of Dojo. For comparison, its compressed (but un-gzipped) size is 77k.
Feedburner, Technorati, Drupal, Edgewall Trac, etc.
Here are some examples of the concise nature of jQuery, taken from the jQuery blog:
// AJAX Updater in Prototype:
‘placeholder‘url method: ‘get‘parameters: par ;
// AJAX Updater In jQuery:
$‘#placeholder‘loadurl + par;
// Note: This example doesn’t deal with the obvious
// iteration benefits we get if we wanted to load the
// response into every <p> object, for instance.
// Adding a class to an element in Prototype:
ElementaddClassName‘element‘‘className‘;
// Adding a class to an element in jQuery:
$‘#element‘addClass‘className‘;
// Adding a class to a group of elements in Prototype:
$$‘.element‘eachfunctionnode
ElementaddClassNamenode‘className‘;
// Adding a class to a group of elements in jQuery:
$‘.element‘addClass‘className‘;
“That last one is the clearest example of the difference in methodology. Because jQuery is passing messages to jQuery objects, the code is barely changed. jQuery doesn’t care that we’re now adding a class to a group of objects instead of one object; the underlying code is the same (add the class to the set of elements in the object). Prototype, on the other hand, requires an iterator.”
“And as your code becomes more complex, jQuery’s scales easily, while nested loops become the norm in frameworks like Prototype.”
29 Apr
Extraordinary as it may seem, my loving and persistent wife, Kelty, has finally graduated from BYU! I’m so happy for her, and relieved to finally see her on the other side of the divide. Now we just have to get me over there
Here’s a 3-minute video I made for her. Feel free to share this moment with us and send her your thoughts!
6 Apr
I just love being there to capture on video what Kelty does. Watch for a segment in this clip when Pedro (Kelty’s horse) rears up, and she masterfully keeps everything under control.
5 Jan
Here’s a tribute to my wife that I made from our video footage. You’re awesome, Kelty! Thanks for teaching me a bit too
P.S. The video is also available directly on youtube here.
3 Sep
This was a song that my mother in law, Ginger, heard when she was younger. She later named her last child and my wife, Kelty, after the reference in it:
oh the days of the kelty dancers
oh the ring of the piper’s tune
all for one of those hours of gladness
gone, alas, like my youth too soonwhen the boys begin to gather in the glen of a summer’s night
and the kelty dancers will be filled with joy and utter delightoh to dream of it
oh to think of itoh to dream of it
fills my heart with tears
It was a beautiful thing to hear Ginger sing this the other night. I seem to be able to find the things I post here, so I’ve posted it since I never want to lose it ![]()
31 Mar
It’s spring time and the weather is starting to beg me to go outside! I went for a bike ride this afternoon and quite enjoyed myself. It was almost like I was 10 again—I biked through the now empty yard where a house once stood (it burned down about 6 months ago) and watched kids playing in various parking lots (I live in an area with quite a few apartment complexes). A couple of neighbor kids seem to have gotten their hands on a couple of gas-powered remote control race cars. All of their friends were gathered around to watch the duel. That looked like fun!
I hope this finds all of you well. Good luck to those of you finishing off the semester at school. Endure to the end, eh? ![]()
28 Jul
It’s been almost two months since my last post, and that makes it about time I wrote again. I’ve been silent on this blog primarily for three reasons:
I will post about each of these items separately.