Posts

Ye Olde Scala Presentation to Honolulu Coders

I presented the wonderfully named " Scala: Java, Erlang, and Ruby’s Hot Three Way Love Child " Scala presentation to the Honolulu Coders back in 2007. I went looking for the actual presentation online, and I'm not sure I ever posted it. I had a brief fling with Scala as I was looking for multi-core friendly environments to build data processing frameworks. I came away being very impressed and look forward to deploying Scala in a future project. After Erlang and Scala, I started programming in a functional style back over in my Ruby code. I consider the experiments a win for that fact along. This post is to prove that I knew Scala before it was cool. :P

Extending Hadoop Pig for Hierarchical Data

I've been playing with Hadoop Pig lately, and having a fun time.  Pig is an easy to use language for writing Map Reduce jobs against Hadoop. Our data is very hierarchical, and we calculate a lot of aggregates for self nodes, their children nodes, and self plus children.  We have a few tricks up our sleeves for SQL for handling these types of aggregates, but of course with Map Reduce an entirely new way of thinking is required. Luckily, Pig allows for easily created User Defined Functions (UDFs) that extend the Pig language.  I was able to take an existing Pig UDF, TOKENIZE, and alter it to suite my needs. Specifically, our data looks like this: 111,/A/B/C 222,/A/B 333,/A/B/C We need to answer questions such as "How many records for A and all of its children?" In this case, the answer is three. We also need to answer "How many records for just A?" which is zero, or "for just C?" which is two. Our strategy is to take the path (eg /A/B/C )...

Mac OS X, Hadoop 0.19.1, and Java 1.6

Image
If you're excited, like I am, about Amazon's recent announcement that they are now offering Elastic Map Reduce you probably want to try a quick Hadoop MapReduce application to test the waters. I found out quickly that if you are on a Mac (as I am) you'll need to perform a few quick configurations before things work correctly. Below is what I needed to do to get Hadoop running on my Mac with Java 1.6. This post assumes you are running the latest Mac OS X 10.5 with all updates applied. Enable Java 1.6 Support To enable Java 1.6, open up the Java Preferences application. This can be found in /Applications/Utilities/Java Preferences. You will need to drag Java 1.6 up and place at the top of both the applet and application versions. Open up a terminal and type java -version and you should see something like the following: java version "1.6.0_07" Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153) Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07...

Ext JS, Checkboxes, and Ruby on Rails

I am currently building a web application that makes heavy use of wizards and forms built with Ext JS . I am sending the form's values as JSON over to a Ruby on Rails server. Thanks to Rails 2.2.2, the JSON is automatically converted into an parameter hash. For a little background to the problem I am about to describe, HTML checkboxes are notoriously difficult to work with, because if the user does *not* check the box, then the browser will not send a value when the form is submitted. This makes it difficult to handle a state change from checked to unchecked. Rails makes this a bit easier because it will render both a hidden field with a value of "off" as well as the original checkbox. If the user checks the box, both values are sent but Rails will use the value from the checkbox (and not the hidden field). If the user does not check a box, only the hidden field's value is sent, which means the "off" value is sent. However, when using Ext JS to r...

Rails Builder Is Slow But Easy To Fix

For the impatient: Go install the fast_xs gem if you use Builder in Rails. The long story: I was using New Relic RPM to watch Errorlytics , and noticed everything was humming along just fine, except... the Atom feed of new 404 errors was taking an extremely long time. Request times of 800ms were not uncommon. RPM told me that the view rendering was taking most of the time, which made sense because I had already ensured that all the queries were by index. Errorlytics uses the Atom Builder to construct the Atom feed, and generally I like it. However, I had my doubts after learning it was the bottleneck, and I was hoping I wouldn't have to rip it out and write the XML by hand. After a bit of Googling around, I was lucky enough to run across Speed up your feed generation in Rails . This post details the same issue, in that the Builder had some major performance issues. Thankfully, the author of that post did all the hard work. They learned that installing the fast_xs gem is the ...

Errorlytics Captures and Fixes 404 Page Not Found Errors For Drupal, Wordpress, PHP, Rails, and Java

For the past several months, I've been working on Errorlytics, a Software as a Service that captures, analyzes, and helps you fix 404 Page Not Found errors for your Drupal, Wordpress, PHP, Rails, and Java web sites and applications. The original idea came from my friends and partners at Accession Media ( SEO and Internet Marketing experts ) and New Evolutions ( web application engineers ). Errorlytics is both a small plugin installed on your web site or application, and a hosted service which captures, processes, aggregates, and fixes 404 page not found errors. If you run a site with Drupal, Wordpress, straight PHP, Ruby on Rails, or Java, then Errorlytics can help you. After installing the open source (and small) plugin, you let the hosted service begin to capture the 404 page not found errors. You can then begin to handle those errors by telling Errorlytics where you want to redirect your visitors. The next time a visitor encounters a 404, they will be transparently redirecte...

Display Javascript Confirmation When User Leaves a Web Page

Update : the original code did not work in Internet Explorer 6 or 7. This is because change events for form elements do not bubble in Internet Explorer. That is lame. In any case, the included code has been tested for Firefox 3, Internet Explorer 6 and 7. Our customer wanted to warn users that if they leave the current page with unsaved changes, those changes will be lost. The requirement is to only show an alert/confirmation when the user has changed the form but did not submit the form. However, don't forget that if the user changed the form but then clicked Submit, no confirmation or warning should be displayed (as they are saving the changes before they leave the page via the submit.) The following Javascript is one way to do it. Note that I am using both Prototype and Ext JS in this snippet. Ext.onReady(function() { Ext.namespace('Dses'); Dses.formChanged = false; $$('form.watch-for-changes').each(function(form, index) { form.getElements().each(fu...