Skip to content

Unit conversion extension for Alfred

I’m pretty much a fan of unit conversion tools. Everywhere I read references to measurements of temperature, weight, speed. These are often given in imperial or US units, but I’m more familiar with the metric system. I often resort to Google for this, because they had this very clever idea of incorporating a unit conversion tool into their search engine. The problem was that I could only use this while online, and an offline alternative was an essential need.

Then it hit me. What if Alfred be able to do it? I’m a developer, and Alfred is extensible, so I got onto a new project to develop an Alfred extension to do this, just like Google does. Today I think my project is stable enough so I decided to go public with it. You can download the extension here.

How to use it

I’m assuming you’re already an Alfred user with the Powerpack installed. You’ll also be needing Growl to be able to see the results of your queries. After downloading and installing this extension, you can trigger unit conversions with the keyword cv (as in convert). You can change that to something else of your preference, of course.

Unit Conversion with Alfred

Performing a unit conversion query with Alfred

Using it is simple. You open the Alfred command window, type the extension keyword and the query and press ENTER. You’ll see the results shown in a Growl notification, and you’ll also get the results copied to the clipboard.

As for the queries and how to phrase them, I won’t make an exhaustive explanation here. I rather prefer to list here some examples of valid unit conversion queries that you can perform. This will give you an idea of how to phrase queries and a sample of the variety of units supported out-of-the-box. The following are examples of valid queries. Be sure to type them in Alfred preceded with the keyword for the extension.

  • 10 km in miles
  • 100 kph in miles per hour
  • 50 pounds in kg
  • 134.5 seconds in minutes
  • 200 milliliters in cubic centimeters
  • 2 acre foot per year in liters per day
  • 3 newtons in lb ft / square second
  • -40 fahrenheit in celcius
  • 1 megaparsec in astronomical units
  • 6.5e17 decays per minute in megabecquerels
  • 10 gallons in liters

Note how you can refer to units by their long or short name, and also how unit prefixes (like kilo-milli-, etc.) are supported too. Long unit names can be given in plural or singular form.

You can also convert sums of quantities…

  • 1.5 weeks + 2 days in hours
  • 2 miles, 3 furlongs and 25 yards in km
  • 100 km/h, 10 m/s and 2 feet per minute in miles per hour
  • 3 hours 15 minutes in seconds

…or omit certain parts of the query. The following are valid queries too. Try them to see the results.

  • 3 leagues
  • ounces in grams
  • parsec
  • 3 minutes 23 seconds

The math is performed internally without loss of precision, so you get very accurate results. Also, you can work with really large or small numbers. Try the following queries:

  • 1 cubic parsec in cubic picometers
  • 1e-50 meV in petajoules

Supported units and measurements

From the examples above you can get an idea of the range of units and physical properties it supports. I won’t list all the units here, but just to give an idea, this extension supports units over a wide variety of physical properties, most of which are listed below.

Most common properties
Length (distance), time, temperature, mass (weight), area, volume, density, speed, accelerationangular velocity, momentum, force, pressure, work (energy), powerplane angle, solid angle, amount of substance.
Electricity and magnetism
Electric currentelectric charge, voltageresistance/conductancecapacitancemagnetic flux, inductance.
Light and radiation
Luminous intensityluminous fluxilluminance, luminous energy (quantity of light), radiation doseionizing radiation, radioactivity.
Other properties
Catalytic activityreciprocal lengthacoustic impedance and resistance, thermal resistance, dynamic viscosity, molar concentration, mass flow, volumetric flow.

In addition to physical phenomena, this extension also supports conversion of currency and units of digital information, such as data size and data rate (e.g. bits, bytes, kilobytes, kbits per second). In this last case, in addition to the SI prefixes, it also supports binary prefixes like kibi-, mebi-, etc.

A note about currency exchange rates

In the case of currency conversion, the extension will attempt to update currency exchange rates from the Internet at most once every hour, but it keeps a local cached version. The extension can only update the cached version when it’s used, even if it is not used for currency conversion. But if you spend many hours or days without triggering the extension while being online, you’ll end up with outdated currency conversions.

Also note that currency exchange rates given by this application are for information purposes only. It will always be approximate to what you’ll actually get when exchanging money. For your information, currency exchange rates are obtained by the extension from a wonderful public API hosted at openexchangerates.org, which is based on the currency bot project.

What’s next

First of all, enjoy it. You can also contact me to send feedback, bug reports and suggestions of improvements and new features.

If you’re a developer, you can also contribute to the unit conversion engine that powers this extension. It’s an open source Java library that I authored and published on github. You can check it out here.

Download the Alfred Unit Conversion Extension

Categories: Software.

Tags: , , ,

Unit Conversion for Alfred and Java

Have you ever tried typing unit conversion queries in Google’s search box? You’ll get something like this.

Google Unit Conversion

Performing unit conversion queries using Google's search box.

Imagine if you could that offline, or even be able to have this functionality available to incorporate it in scripts or other programs as well. Imagine you could have this functionality as an extension in Mac’s AlfredApp.

Introducing Metric: A Unit Conversion Library for Java

I needed this functionality to develop an extension for Alfred, the most wonderful Mac launcher, and I wanted it to work offline, without having to retrieve the results from Google or another online source. So I created a Java library that’s capable of performing unit conversion queries expressed in natural English. I called it simply Metric, made it open source, and published it on Github. You can clone it, fork it, play with it or contribute back if you will. The code is fairly well documented and organized. The library includes some supporting sub-libraries that may be used independently in other projects, including a plural/singular inflector for the English language.

Metric meets Alfred

The original goal of developing a library like Metric was to use it as an Alfred extension. Alfred (http://www.alfredapp.com/) is a wonderful productivity application for Mac, much like Quicksilver or Google’s Quick Search Box, but  a little bit better in my opinion. You can grab a copy of Metric as an Alfred extension here. After you install this extension, you can type unit conversion queries on Alfred using cv as keyword.

Unit Conversion with Alfred

Performing a unit conversion query with Alfred

This Alfred extension shows the results of the conversion using Growl, but I guess if you already have a Mac chances are that you Growl installed. If not, you can get it here.

Links and resources

Categories: Programming, Software.

Tags: , , , , , , , , ,

Skip Lists (a.k.a. Balanced Trees are overrated)

Programming computers is fascinating.

A couple of days ago I was introduced to a new data structure I did not know before. It’s called a skip list. It’s a sorted linked list, where the nodes are linked at different levels, forming increasingly sparse chains, each of which skips more nodes, and therefore is faster to traverse, allowing search algorithms to hop over parts of the list when searching. That’s why they’re called skip lists.

The concept was shown to me during a job interview. They briefly introduced me to the concept of skip lists using an image. It is said that an image is worth a thousand words, and in this case the assertion holds:

Continued…

Categories: Programming, Whatever.

Tags: , , , ,

Steve, we have a problem!

One of the coolest features of Apple’s iDevices, specially the iPad, is the ability to recognize the orientation of the device and adjust the rotation of image on screen accordingly. But what happens if we take the iPad to the International Space Station?

Well some guys did something very similar. They took an iPad for a ride in a Zero-G parabolic flight, similar to the well-known NASA’s Vomit Comet. Can you guess what happened to the iPad? Surprise!

Maybe not as serious as the problem that Jim Lovell and his crewmates had on Apollo 13, but a problem indeed. I was really not surprised at all, since I expected no more, but it’s nice to see that someone actually gave it a try.

Categories: Whatever.

Tags: , ,

Opera 11 brings tab stacks and some improvements

Opera invented tabs and many other innovations that other most successful browsers have adopted over the years. In fact Opera is the browser that has lead more innovative features than any other browser. And yet somehow this browser –my favorite one till Google Chrome appeared– has never been considered a major one except in some niche markets.

Personally I always considered it the best browser ever, although with great grief I had to hand over that title to Chrome, which has everything really worth taking from Opera, plus several improvements that were hard to ignore. It was the first browser able to claim being nearly as fast as the Norwegian big O, plus sandboxing, well-achieved extensions framework, uncluttered interface and a great attention to detail from its designers.

But I didn’t throw away Opera for this. Today I took a glimpse of what’s expected for their upcoming 11th edition, and I have to say I was impressed but not surprised at all: I expected no less from the best browser vendor in the world.

Opera 11 beta brings up several improvements over past versions. Keeping up with the competition is the least they could, and they seem to be doing really well in terms of features: better HTML5 support, smaller installer, better performance, safer browsing, secure and informative address field, private navigation mode, and a great new overdue addition which I haven’t yet explored in its entirety: extensions. Continued…

Categories: Internet, Software.

Tags: , , ,

Taking notes the simple way

Recently I’ve been playing around with a few note-taking applications, specially with support for mobile devices such as my iPhone and a simple way to keep notes in sync with my laptop or desktop computers.

I was most recently getting along with PlainText, a note-taking iPhone app that stores your notes in a folder in your Dropbox account. It’s a very simple yet powerful concept, specially for those of us who already use Dropbox. Instead of having yet another syncing environment for notes, they already take advantage of the Dropbox user base out there.

The interface is simple and visually appealing, yet out of the ordinary. The notes are always in sync between the iPhone and the computers thanks to Dropbox, and I can get to organize my notes into folders. No more nasty notes from the default iPhone notes app getting into my mail (whoever thought that notes were related to mail is insane). Continued…

Categories: Software.

Tags: , , ,

The most hilarious moment on The Big Bang Theory

You gotta love Jim Parsons on this scene. For me it’s the funniest scene on the whole series so far. It makes me laugh every time I see it. I hope you enjoy it too.

Update: Unfortunately the Youtube video above is not embeddable, so it cannot be played within this site :-( Simply click on it to be given the option to open it on Youtube instead.

Categories: Whatever.

Tags: , , , ,

A new way to manage your passwords

In this ever increasing digital world with lots of useful services on the Internet, keeping track of your passwords is a daunting task. Many people end up using one or two passwords for everything, or are otherwise constantly resetting their passwords via email.

Luckily there are lots of different choices of password managers, softwares that will help you keep a secure database of all this information, sometimes even in a way that they help you collect your passwords as you use them in your browser, autofill login forms, and even generate new random passwords for you.

This is all great, but I am not convinced. Random passwords generated and filled into forms, all done by a software tool? I end up not really knowing my passwords. What if the tool ever fails, or its database gets corrupted? What if my hard drive melts and after the fix I get a clean install with no passwords database? I also do not like the idea of passwords being stored digitally, not even encrypted.

So I ended up with a small password managing system that I designed myself. With it you can still use a conventional password manager, but in a slightly different way. Continued…

Categories: Software, Whatever.

Tags: ,

Five reasons to love Objective-C

Objective-C was always a distant name for me, a blur memory from lists of languages read somewhere. I recall having a very subtle curiosity for the name. It’s like saying two things in one. First, it’s like adding objectivity to C, but also the objective word gives a hint that objects and Object-Oriented Programming are somehow involved. It’s a nice and insightful word play with the pun intended.

Objective-C provides most of the benefits of C++, plus some more benefits that C++ does not provide at all. And I am not talking only about Simula vs. Smalltalk philosophical differences here, but about stuff that C++ could have actually had without breaking its Simula-like philosophy. Some of the features/reasons I will enumerate below fall under this category. Continued…

Categories: Programming.

Tags: , ,

Import your iPhone address book into the iPhone simulator

When you are developing an iPhone application that works with the system-wide address book, it’s sometimes useful to have already some entries to play with when testing the app. Suppose then that you are testing in the simulator, which comes with no contacts at all. You cannot sync your simulator with iTunes, and the simulator is not integrated into your Mac Address Book, so you have to start creating some contacts manually.

Well, not exactly. If you have a real device (and you should anyway, if you are developing for the platform) and this device has lots of contacts in it, then you can copy the internal address book files into the simulator’s file system in your Mac. I actually got the tip from this blog post after searching on Google a little bit, but it did not worked for me exactly that way. I’ll let you know why. Continued…

Categories: Programming, Software.

Tags: , ,