Connecting MongoHQ and Node.js on Heroku

I followed a good tutorial that helped me with some Node.js and MongoDB basics. However, I wanted to make the DB connection code more generic, and connect to a MongoHQ hosted database since I was planning on running my app on Heroku.

From samples I had seen using node-mongodb-native, I was still having a hard time setting up an authenticated connection to MongoHQ using the mondodb scheme URI. This URI gets set automatically (process.env.MONGOHQ_URL) by Heroku when the addon is added, or can be set manually on Heroku if you have a pre-existing MongoHQ db you want to point at.

The key turned out to be in the connection method, which takes a URI as opposed to constructing the database object manually from a server object. It stands to reason that I could parse the URI instead, but I prefer this.

I'm surprised I didn't find a good example of this on StackOverflow. So here is the simplistic gist I created.

Quickly Load Scripts Into Java Interfaces

Handy but limited utility class for loading (in this example JavaScript) scripts into Java interfaces.

Usage:

MyInterface foo = ScriptObjectLoader.
                  <MyInterface>loadScript(MyInterface.class,scriptInputStream);

Where you might have a JavaScript file that looks like this:

new MyInterface {
    implMethod1 : function() { ... },
    implMethod2 : function() { ... }
}

Source:

Penny Arcade on Waiting in Line

Waiting in line is a tonic for the soul. For tech and films especially, it's a rare coordinate where you stand a reasonable chance of being able to have a conversation with any person next to you, any "random" person, but they aren't actually random because simply by being in line we have some notion of how their variables might be set. Organisms who (under other circumstances) would be little more than shambling physical obstacles become something akin to people.

This near-perfectly describes my feeling on the 24th, waiting in line at 6:00am.

(via Penny Arcade)

Paid iPhone Applications Tend To Top Rankings Longer Than Free Apps

[image]

App store analytics startup Distimo just released its May report, and zoomed in on the average number of days applications across various categories maintain their top rankings in Apple’s App Store. Analyzing data collected from November 2009 to April 2010, the company found that paid applications in the Top Overall, Games, Business and Entertainment categories stay in these categories for 27, 39, 59 and 38 days on average, respectively.

Zooming to User Location in MKMapView

Couldn't really find a good reference for how to do this on the web.

After reading a bit on the MKMapViewDelegate class, I used the following delegate method to zoom to the user's location once the annotation appeared (edit to taste):

Just make sure to put this code in a UIViewController implementation and set the MKMapView's delegate to this object.

[Update] Found the following question/answer on Stack Overflow which uses key value observing.