Some of the most interesting and challenging projects involve data visualization. It can be very difficult to express data in a clear way and also make the product aesthetically pleasing. There are many different ways of presenting data to users, and choosing the “correct” visualization is not always a simple decision. Having numerous tools at your disposal, or at least greater awareness of what is out there, can help you make a better decision.
I was recently experimenting with a library called jqPlot, jqPlot is a jQuery plugin that supports drawing line, bar and pie charts with many customizable features. The project I was working on involved a device that monitors the temperature of the contents of a kettle during the process of brewing beer. My goal was to show the temperature as it changes over time and also to indicate a prediction of when the temperature would reach a desired target value. Here is what I ended up with:
To produce the chart above, very little html code was required. Read more on Charting Data with jqPlot…
Functional programming has a lot of advantages that have been enumerated over the years. Being a bit of a Pythonista, myself, I can’t help but introduce functional concepts into my Python code. Though Python is not a functional language, it doesn’t mean that your Python code can’t benefit from some of these concepts.
Perhaps one of my favorite illustrations of functional Python comes in the treatment of loops — or more accurately, their removal from my code. Before I demonstrate how to do that, allow me to introduce a very contrived example.
Let’s say you’ve parsed a configuration file into a list of lists, and you need to be able to access a particular settings by keyword. The following snippet does exactly that in a traditional format.
configurations = [["name","Bob"], ["email","firstname.lastname@example.org"], ["template","dark"]]
def get_config_value(desired_key, configs):
for key_value in configs:
if key_value == desired_key:
print get_config_value("name", configurations)
This code works well, but I find the nested statements less than ideal.
Functional Alternative #1 – Generators
Generators simply create iterators (i.e., something you can use in a loop) without constructing a complete list ahead of time. Generators are lazy loaded and are more efficient than their eager-loading cousin, the list comprehension, when working with large data sets.
The following returns the same result as the previous example with one less layer of nesting: Read more on Writing Functional Python…
Here are a few reasons to explore LiveScript. Read more on Graduating from CoffeeScript to LiveScript…
Recently, I’ve been learning the ins and outs of Functional Reactive Programming with Reactive Cocoa. The library comes with a number of operators that can be used to modify incoming signals. In this post, I am going to compare two of those operators:
+zip: can be used to combine two (or more) signals into one new signal that sends a single RACTuple containing both values. This can be very useful when two separate events occur, or when two pieces of changing data need to be processed together.
Read more on combineLatest vs. zip in ReactiveCocoa…
I recently set up a project with hosting on Heroku. However, I had code spread across several repositories that all needed to be deployed to the same place. This is a problem because the process to deploy to Heroku is essentially pushing to a git remote — if I did that across two repositories, they would collide.
One possible solution was git submodules, but they are finicky so I was hoping for something simpler. After a bit of investigation, I discovered that git has a feature called subtrees that could be used to handle this.
Read more on Simpler Deploys with git Subtrees…
Lately, I’ve been working on setting up a Personal Package Archive (PPA) to use when provisioning servers with custom packages.
In order to host packages on a Launchpad PPA, one must first upload signed source packages. Since I use a Mac and keep my PGP signing key on a Smartcard, I needed to find a way to connect my Smartcard reader to a virtual machine running Ubuntu. After a bit of research, I found an easy way to do this with Vagrant, VirtualBox, and the standard precise64 basebox.
Read more on Using a Smartcard with a VirtualBox-based Vagrant Virtual Machine…
Recently, while working on an Ember.js app, I found that I wanted to create a reusable component that manages the editable state of content within it. That is, it would start out by displaying information (initializing its isEditing binding to false), and provide an “Edit” button that would set isEditing to true, so the content wrapped in the component could display its editing interface.
Naturally, I then wanted a way to “subclass” my EditableComponent so that I could create (for example) an AddressComponent that would display a mailing address read-only but allow you to edit it. What I struggled with was finding the best way to pull this off.
I had a few different ideas, two of which didn’t work. Read more on “Subclassing” Ember Components…
Also posted in Web Apps Tagged emberjs