iOSDevCamp 2011 Experience

About two weeks go I attended iOSDevCamp. This is a gathering for people to develop for iOS over 48 hours, and present their projects on the last day of the event. The team I put together consisted of @ngavini and @bearannihilator. We had an awesome time working for 48 hours straight. We had an idea of what we wanted to work on the previous week.

The app we created is a mobile music player that you can use with your friends and listen to music together in realtime. We wanted to focus on small intimate groups of friends. We decided to build it on top of Rdio since we all had Rdio accounts and they have an awesome API. We decided to use the classical groups approach. A user can create a group by adding other Rdio users/followers to it. Once a group is created, you can enter the music room created for that group and listen to music together. Members of the music group can:

1. Play a song for everyone to listen to
2. Add songs to the queue
3. Like/Dislike other members choice in music

The backend was built on NodeJS and MongoDB.

Friday night we headed over to the eBay campus for dinner. We talked about who would take ownership of what components of the app. Once we were all on the same page we started to build out the app.

It was a fun weekend. We weren’t sure if we were going to be ready to present on Sunday. But that morning we decided to go for it. Implemented one last final feature about 2 hours before our presentation and then took the stage. You can view our presentation and demo which is archived on ustream, at around the 58:25 mark: http://www.ustream.tv/recorded/16073539

We ended up winning best crowdsourcing app for crowdsourcing music interests to your close friends (Thanks @Mirego!).

It was a great experience and I can’t wait to attend next year! Check out some screenshots of the app below:

Posted in Programming, Technology, iOS | Leave a comment

DotCloud: Deploying a NodeJS/MongoDB App

I spent most of the night moving my backend code off of EC2 to DotCloud. I thought I would give DotCloud a shot since I received a free Pro account for 1 year. I will however move back to EC2 once I have the time to ramp up on how to properly administer/scale EC2 instances. The documentation on DotCloud is pretty straightforward, however there are a few things that aren’t covered here. I’ll try to outline the whole process of getting a NodeJS/MongoDB app running. To be clear, I am using the node-mongodb-native driver in node.

First thing you want to do is install the DotCloud CLI, which can be achieved by doing:

$ sudo easy_install pip && sudo pip install dotcloud
...
$ dotcloud setup
Enter your api key (You can find it at http://www.dotcloud.com/account/settings):

Once this is complete you are ready to use dotcloud.

There are 3 main files that you need to create when preparing your NodeJS app for deployment:
1. dotcloud.yml – Standard YAML file which describes what components you want for your stack
2. supervisord.conf – Configuration file to specify commands and mappings for the build process
3. packages.json – any npm dependencies

These files will reside in your app directory structure, here is how I have mine laid out:

github-repo-folder/
   backend/
     |_ dotcloud.yml
     |_ app/
       |_ supervisord.conf
       |_ package.json
       |_ server.js
       |_ storage.js
       |_ webservice.js
   ios/
     (front end code here)

So, what exactly do you need to put inside these 3 files?

For dotcloud.yml, I want two services on my stack, nodejs and mongodb, and my nodejs root directory is named “app”. Remember YAML files must have proper indentation also:

$ vi dotcloud.yml
server:
  type: nodejs
  approot: app
db:
  type: mongodb

For supervisord.conf, I specify the command which starts my NodeJS server. The rest of the file is pulled straight from DotCloud’s documentation:

$ vi app/supervisord.conf
[program:node]
command = node webservice.js
directory = /home/dotcloud/current

For package.json, I specify my dependencies that I use in my app, which is only the node-mongodb-native driver.

$ vi app/package.json
{
  "name": "odinapp",
  "version": "1.0.0",
  "dependencies": {
    "mongodb": "0.9.6-8"
  }
}

This is pretty much all you need right now to create and deploy your app. Once you verified your directory structure you can start deploying:

$ pwd
github-repo-folder/
$ dotcloud create appname
Created application "appname"
$ dotcloud push appname backend/

This will kick off the build process. At the end of the output you will see something like:

Deployment finished. Your application is available at the following URLs
server: http://XXX.dotcloud.com/

This is where you can access your app from. However we aren’t done yet. We still need to configure mongodb so that our server can interface with it. First let’s look at our mongodb instance:

$ dotcloud info appname.db
cluster: wolverine
config:
    mongodb_password: VeMC3qpwDrxCkw721A2D
created_at: 1312275748.4701369
ports:
-   name: ssh
    url: ssh://mongodb@01833a91.dotcloud.com:5916
-   name: mongodb
    url: mongodb://root:VeMD6qvwNrxCde723AfB@01833a91.dotcloud.com:5917
state: running
type: mongodb

Yours should look something like this. I replaced my fields here with some dummy data. What you need from this information is the mongodb_password (VeMC3qpwDrxCkw721A2D), mongodb_url (01833a91.dotcloud.com), and the port number (5917). With this information, you can add a user to your mongodb instance so your server code can authenticate and start making calls to it. Start by entering the mongodb console:

$ dotcloud run appname.db mongo
MongoDB shell version: 1.8.2
connecting to: test
> use admin
switched to db admin
> db.auth("root", "VeMC3qpwDrxCkw721A2D");
1
> use odin
> db.getSisterDB("admin").auth("root", "VeMC3qpwDrxCkw721A2D");
1
> db.addUser("steveram", "my_password");
1

These steps in the mongodb console basically just added a new user named “steveram” with read/write permissions to a database named “odin”. This is the user we will authenticate with from our server code. I have a module name storage.js which does all the interfacing with mongodb. Here is a small snippet of how I do that with the node-mongodb-native driver:


var DB_NAME = 'odin',
    DB_ADDRESS = '01833a91.appname.dotcloud.com',
    DB_PORT = 5917,
    DB_USER = "steveram",
    DB_PASSWORD = "my_password";

Storage.save = function(coll_name, data, callback) {
    var client = new Db(DB_NAME, new Server(DB_ADDRESS, DB_PORT, {auto_connect: true}));
        client.open(function(p_client) {
           client.authenticate(DB_USER, DB_PASSWORD, function(err){
               client.collection(coll_name, function(err, collection) {
                   collection.insert(data, function(err, docs) {
                       sys.puts('inserted ' + JSON.stringify(data) + '.');
                       if(typeof callback == "function") callback({"status":"200"})
                       client.close();
                   });
               });
           });
        });
}

And that’s it! Your app should be running on DotCloud now and your server code should be able to talk to your mongodb instance.

Posted in Programming, iOS | Tagged , , , | 1 Comment

Hacking on Node

Update: There might be some downtime with the service because my hosting provider keeps killing the nodejs process. I’m looking into other solutions.

Wow it has been 2 months since I posted here. I’ve been really busy at work with the new Yahoo! Mail Beta that was released about two weeks ago. It was really rewarding to read comments about the product from users and to have the rollout go smoothly. Congrats to everyone on the team for the hard work!

I finally had time some to take a look at node.js. The thing that really caught my attention was the ability to have a server that can handle thousands of concurrent connections on a single process, in JavaScript. Node.js is written on Google’s open source V8 engine. I would suggest watching Ryan Dahl’s (the creator) Introduction to NodeJS video for a great overview.

First I had to decide what I wanted to build on node.js. I knew I wanted to do something that would be useful, but also I that it would really take advantage of how node.js handles concurrent requests and scaling.

I decided to put together a simple service that allows you to ask a question, and you get back an answer. But, I wanted to do this using Twitter. The 140 char limit would hinder me in the length of answers I could return to the asker, and DMing the answer back was not an option for me (because of the restrictions of having to follow each other). I decided to return a voice transcription of the answer. Here is the end result:

AnswerMii Demo from Steven Ramkumar on Vimeo.

If you didn’t catch it from the video, this is how you use the service:

Simply tweet a question to @answermii. Such as “@answermii where do the simpsons live?”. Then check your mentions and you will instantly receive an answer.

I built this using YQL on Yahoo Answers, the Twitter Streaming API, and Google Translate. Right now the mp3 link the service returns isn’t too pretty. I really want to move this to Twaud.io by Dan Webb, however I kept getting 500 internal server errors when trying to use the uploading API, so I’m hoping to look into that again.

I have a node.js server which uses the Twitter User Streaming API to track all tweets with @answermii. Any Twitter user with their tweets protected will have to follow @answermii and get a follow back to receive any answers. All public tweet questions will receive an answer instantly. Once the server receives a question it will simply get answer from Yahoo! Answers, use Google’s text-to-speech service, create and store an mp3 file on the server, and reply the user with that link.

Some problems I ran into were that Google’s TTS service has a 100 char max on it. I had to split the answer text into 100 char chunks, do a tts translation on each chunk, and merge all of the mp3 files before saving it. This causes a few hiccups in the actual voice when listening to the answer. I haven’t thought of a good solution to this yet.

The next steps for this is to improve the answers that get returned. If you try out the service today, there are times where you will get an answer that is either not related to your question, sounds awful if there are alot of links in the text, or you will hear nothing if Yahoo! Answers doesn’t have an answer for you. (For example, if you ask it “How do you make toast”, you will receive an answer telling you that you are an idiot, or something like that. Although one could argue) I also want to return the user multiple answers, and have their question part of the reply Tweet.

I am also going to try to include other sources of information such as Facebook Questions and Quora.

Let me know what you think or how this can be improved! I’ll put up project code onto Github eventually.

Posted in Programming, Technology | 3 Comments

FBGrab: A Facebook Graph API Wrapper

Tonight, on GitHub, I put up a small JavaScript wrapper I’ve been using to query data from Facebook’s Graph API. You can check it out here: FBGrab

One main goal was to make the project’s code easier to read. Instead of having a bunch of FB.api(graphAPIMethodString, callback) calls everywhere, they are replaced with calls such as FBGrab.userInfo(callback) and FBGrab.userPhotos(callback).

Right now, you can’t do any queries about object connections just yet. But I will hopefully have time to include that in there soon.

Posted in Life | Leave a comment

Kaskade at The Warfield

I was pumped to get tickets to see Kaskade in San Francisco on October 1st. I’ve always been a fan of his music but never had the chance to see him live. I hope that he includes alot of his old stuff throughout the night and hopefully some Late Night Alumni too. Either way, I’m really excited for this concert. Here’s some of his stuff that I’ve been really into lately, enjoy!

Kaskade feat. Haley – Don’t Stop Dancing

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Kaskade feat. Mindy Gledhill – All That You Give

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Kaskade feat. Becky Jean Williams – Start Again

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Late Night Alumni – Finally Found (Max Vangeli Extended Remix)

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Posted in Life, Music | Leave a comment

Life in California

It’s been about two weeks since I’ve started living in the real world. The lifestyle here is alot different than what I’m used to back in Waterloo. I’ve learned to live independently and to be more responsible. I was able to find a nice 1br/1ba a couple miles away from work. It is pretty bare right now but I’ve managed to get by so far with a bed and some simple kitchen and bath supplies. I’m hoping to get some more furniture by September. Continue reading

Posted in Life | 1 Comment

Implementing Twitter’s xAuth on webOS

Twitter’s statuses/update API method requires authentication. To do this from a webOS device we need some sort of browserless token exchange to get the access tokens for a user. Twitter has progressed from Basic Authentication, to oAuth, to now xAuth for mobile environments. oAuth didn’t suit well for mobile devices because it requires the user to be sent to the source website for the tokens which then gives it back to the application so it can communicate with the twitter API. This wasn’t good because the user was forced to leave the application to go into the browser.

xAuth

xAuth solves this problem. It allows the application to get the access tokens without a web interface allowing the user to stay in the application.

I will explain the way I was able to implement this in Ten Trends for webOS. Continue reading

Posted in Programming, webOS | Tagged , , , | 1 Comment

CSS3 Transitions – Flip effect for HTML elements on webOS

The number one feature request for one of my applications, Get Answers (Y! Answers), was the ability to view the source of a user’s answer. The problem was I was running out of screen real estate space and didn’t know where to include it. I also realized that this information is secondary and didn’t need to be visible right away. I decided to include the information on the back of an existing HTML element and allow it to “flip” over when the user tapped on it. I am going to explain how I was able to achieve this effect with the current limitations of webkit running on webOS. Continue reading

Posted in Programming, webOS | 4 Comments