Sexy Data Visualizations

Maybe its the nerd in me, but I really enjoy a great data visualization. Every time I see one of those crazy sets of data, displayed in some crazy hover over, clickable charts, I get excited. In an attempt to some day match one of them I randomly catch myself searching the web for charting libraries. After a couple of months of searching I found a gem, and wanted to send a shout out to the author, and his library – Highcharts!

Highcharts has many great features, here is my top 5:

  1. It is written in *pure* JavaScript – Unlike many of the Flash based charting libraries, Highcharts is written in JavaScript. Why is this such a great thing? Usability, of course! If you are looking to create a data visualization that will need to work on more than just laptop and desktop computers (such as iPad, iPhone, iPod, mobile phones, and game consoles), and need interactivity – JavaScript is your best bet. These charts display beautifully on such devices – check out Campaign Monitor’s adoption of Highcharts for proof. On top of this, the code is well written, and well tested, which results in an extremely fast rendering of each chart.
  2. It’s interactive, with plenty of customization – Highcharts allows the developer to write custom code that is called from multiple events (click, mouseOver, mouseOut, and show are just a few). With this ability charts can become extremely interactive, allowing users to interact with data they otherwise couldn’t.
  3. Developer provides fantastic support – Many projects out there today are just side projects for developers, which is great, but means that support is fairly limited. Torstein Hønsi is developing Highcharts and Highslide full time – so depending on your timezone you can typically get a response within the day for almost any question you may have.
  4. Great documention – Typically the last thing to come out of a software project is the documentation, and even then its always pretty sketch – or just generated docs. Highcharts offers a great demo page, as well as a complete options reference, and how-to page. Nine times out of Ten, I’m able to answer my own question by checking out one of these pages – that tenth time, see bullet #3 ;) .
  5. The price is right – Cheaper than its Flash competitor, Fusion Charts, Highcharts is offered at a great price for what it can offer your company or product. If for some reason you have more than 2 or 3 developers working on your charts it will run you around $500 USD, but chances are if you have this many developers on your products, your return on that investment is quite high as you are charging quite a bit for your product.

As you can see, in just my top 5 reasons, Highcharts is very attractive. There isn’t much of a development community behind the library at this time, so if you want to help contribute to such projects checkout the Rails plugin, or the PHP plugin to offer your expertise!

Posted in Uncategorized | Leave a comment

Trust The Experts

I was just hired to complete X, but every time I share ideas with the client they seem to think they know more than I do, what’s the deal?

Over the last few years I have noticed an ugly trend developing. It seems that in the ever growing (and broad) field of technology, the individuals hired to render services for clients are rarely looked at as the expert – even though they were hired, because nobody in house has the knowledge to complete the task. This person was hired because they are knowledgeable; so regardless of what you think looks good, is a best practice, or is easier for users – you’re probably wrong.

So, next time you hire someone, keep in mind why you hired that person. Don’t tell them you want the logo bigger, the music louder, or more spacing – go do your job, and let them do theirs.

Posted in Uncategorized | Leave a comment

Metadata in Ruby on Rails

I have multiple pieces of data to store that all relate to one row in my database, but I don’t want to create a completely separate data model and/or table. Is it possible to store this data in a single column within the same database row?

I recently had this exact problem, I had a single row in my database that referred to one or many (I am using Rails STI, the amount of data depends on the objects stored within the row) other pieces of arbitrary data. This is most commonly referred to as ‘metadata’ and would typically have its own table of key value pairs and a foreign key; but in my case I wont need it that often, and didn’t want to create another table to handle such small amounts of data. So I thought “there is no way that someone else hasn’t faced this issue”, and naturally turned to Google.

I was surprised at how little I found; what I did find were different discussions about creating metadata for plugins, or even storing JSON in the column (not bad, but how do you search for data in JSON from MySQL?); nothing too helpful, leaving me to fend for myself.

After days of racking my brain I had a thought; XML has standards, it has practical uses, and it’s widely used and understood, so why not store the information I need as a mini XML document? This would allow me to store as much information as I want to, in one column – and using methods within MySQL I can even search the data. Below I will walk you through a simple Rails solution demonstrating how to use this metadata method, built on top of simple Single Table Inheritance (STI).

This example will use vehicles (cars and trucks) as our STI model, and our metadata will store information about each cars specifications.

Basics of our STI classes, with metadata column

Writing to our metadata column
In order for the setter to write correctly, it expects a hash. The data submitted from a form (POST data) is already in the form of a hash, but the reason for implementing this method was to allow for more than one value to be stored here, this requires a little work on our end. Lets say we want to store information about the car that will go on the sticker within a dealership.. We never know what could end up on that sticker, but we have one column to store it.

In order to control what happens to the data within this field, we will need to write a custom setter for the metadata attribute. The setter method that we create will allow us to handle the incoming data in any way we want. The method we need to add to our Vehicle class would look like this

This setter expects a hash from our form, this is because of the method we use to convert the data to XML. Since we are providing the hash to the setter we will need to name our form fields accordingly, this can be accomplished like so

When this form is submitted, the following will be written to the database

As you can see, it looks like a mini XML document, header and all. The beauty of it, Rails has built in functionality to read this data, and SQL has built in methods to search this data!

Reading our metadata column
Now, rails supports all the data types that your database supports as far as retrieving and displaying data, and the default getter methods work perfect for those – unfortunately XML is not one of them. In order to get the data out of our column, in a form that is easily readable by rails, we will add the following custom getter method to our Vehicle class

This getter will retrieve the XML in the column, and return it as a Ruby hash, resembling

Data is this form should be quite familiar, the Hash object is widely used within Ruby and Rails applications. And just like any other Hash, when we want to display this information, we could use something as simple as

Searching this data using SQL
An important aspect of any data, is that it is searchable. Unlike JSON, XML can be searched within a database column using XPATH. Lets say, for instance, that we want to find all cars that are under $10,000.. We can use the following to accomplish that

So there you have it, a relatively easy, clean, scalable way to store arbitrary data associated with a single database row in your Rails applications. Please understand that this is a basic example, if you were to use such code you would want to make sure to take care of the appropriate error checking, and testing.

If you would like to view this post as a working example, I posted a sample app on github.

I’m sure there are many ways of accomplishing this, this method worked for me.. Do you have a better method? Suggestions as to how I can improve this one?

Posted in Ruby on Rails | 2 Comments

How to become a Social Media Expert

I LOVE Social Media, How can I become an expert!?

With the increasing number of people, brands, and apparently even animals using social media to spew out their thoughts, advertisements, ideas, opinions, pictures, etc. everyone sees a huge opportunity to make a quick buck. Realize though that only those whom are considered experts will benefit from Social Media.

Here is how they do it, the best of the best, the most recognized experts out there use this same exact method..

  1. Sign in to Twitter
  2. Click Settings in the upper right
  3. Click the Profile tab
  4. Find the text area associated with Bio, highlight the text within the text area and delete it
  5. Insert “Social Media Expert

DONE! You just became a Social Media Expert on Twitter. The beauty of it all is that this method is so simple, you can do the same thing on Facebook, Foursquare, Gowalla, or any other social network that you want!

Be aware, this method does have a bug, people will not believe anything you say so long as this is in any of your bios, or on your business cards, because in all reality you probably know nothing. The fact of the matter is, you just sit on your computer spamming people with links to your ‘clients’ products, Facebook pages, contests, polls, and blog posts. STOP.

Posted in Social Media | 2 Comments