:::: MENU ::::

TreeMapping

A recent school project got us excited to explore the idea of mapping the trees of city of Vancouver in a more practical way. My friends and I had a fruitful meeting today with @daeaves who has extensive information and experience in this subject.

There is a tree mapping platform, OpenTreeMap, to start with. It seems to be a well maintained code, it’s on Python and needs Tomcat for the starters.

Now I have see if we can use it as the base or it’s cheaper to get something started from scratch in-house. We don’t need anything complicated for the first phase, but as usual we enjoy (very) limited resources including time.

David had good insight and useful suggestions that I need to consider too.

We’ll see.


Playing with data structures in Ruby

Sorting

I’ve been trying to sort a mixed array in Ruby the shortest way. Each element of the array by itself is a mixed array of a number and and a hash:

a = [
  [0, {:a=>"31", :b=>"21"}],
  [1, {:a=>"32", :b=>"11"}],
  [1, {:a=>"25", :b=>"19"}],
  [0, {:a=>"12", :b=>"10"}]
]
 
#sort by first item of each row (number)
a.sort{|x,y| x[0]  y[0]}
 
#sort by the first item in the hash
a.sort{|x,y| x[1][:a]  y[1][:a]}

Note: I initially posted this as a question on Stackoverflow and got different but correct answers.

Finding common elements

To find common elements between a number of arrays, simply add them to a hash and use the & operator, which creates a new array from two existing arrays containing only elements that are common to both arrays, omitting duplication. (See Techtopia)

a1 = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [3, 2, 1]]
a2 = [[1, 2, 1], [1, 2, 2], [2, 2, 4], [3, 2, 1], [1, 2, 3]]
a3 = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [3, 2, 1], [2, 2, 2]]
hash = {i1: a1, i2: a2, i3: a3}
common = hash.values.inject{|x, y| x & y}

What I can do with Ruby in just one line fascinates me.




Snow Leopard to Lion; The painless way

Conclusion first!

Let me save you a few minutes (and perhaps hours of suffering on your Mac) and tell you the end of the story in the beginning. Upgrading has been always a tricky way of installing a new operating system. Granted it is smooth enough on a Mac but it comes with its own cons, like wasted disk space and unused files here and there.

So backup your files, which you need to do anyway, and go for a fresh install. Don’t be lazy, it just needs one more hour of your time.

Here is how you do it:

1. Go to Mac App Store (Run the application on your Mac)
2. (Purchase and) download Mac OS X Lion. It’s a big file (almost 4GB), so refilling your coffee won’t hurt.
3. Once the download is complete, open the Applications folder on your Mac and find Install Mac OS 10 Lion icon.
4. Right-click on the file and select Show Package Contents.
5. In the folder find Contents/Shared Support/InstallESD.dmg.
6. Right-click on InstallESD.dmg and select Open with > Disk Utility.
7. Insert a blank DVD and click Burn on the toolbar. Another coffee or maybe even dinner will fill the void.
8. Voila! You now have a bootable DVD of Mac OS X Lion.
9. Boot the system with DVD in the drive while holding the Option key (that is, on your keyboard).
10. After a few seconds you’ll be presented with 2 icons on the display, a hard drive and the Mac OS DVD.
11. Select the DVD (click on the arrow key below it) and follow the instructions. The system will start installing the 12. new operating system

Warning: This process will delete all data that existed on the disk prior to install. Backup your files on an external device first.

Now the story

It’s been more or less a month since Mac OS Lion is out in the wild. As with all new releases of operating systems people react to it very differently. From blind love to pure hate, and well, that’s not quite informative.

One of the best reviews I read about Lion was from Ars Technica, written by John Siracusa. I’d be lying if I say I read it all; it’s a friggin’ book. But I enjoyed the unbiased view of the author and learned stuff too. You might be wondering why do I just woke up from the rock I was living under and started writing about installing Lion.

First of all, it’s not that very safe to upgrade to a new OS the moment it is available for download. The irrationale joy and excitement of a hot-from-the-oven product might burn you. The very early adopters usually share invaluable information about their first impressions and sufferings. Then I didn’t think my old (late 2007 , yes 2007!) MacBook Pro seem to be a bonafide candidate for the job. So I waited until I buy a new laptop, which was 2 days ago. A Core i7 MacBook Pro. It’s a descent machine and I quite like it.

About upgrading to Lion; the laptop came with Snow Leopard installed on it and a free download code for Lion. Instead of just upgrading to Lion I chose to run a fresh install on it to have the peace of mind that no old file will be left abandoned on the system and no library will conflict with a new one. Time will tell.

Now if you excuse me I have to go finish installing the apps I need on daily basis. You can refer to conclusion (top) for a quick tutorial on fresh-installing Lion.