Monthly Archive for July, 2009

Easy and powerful natural date parser.

A few months ago, I wrote a patch for Tasque which is a really neat TODO list manager. This allowed you to create duedates on tasks with absolutely no effort

Since my current project (TaskForce) is sort of a TODO list on steroids, I thought I’d pull the patch back out of the deepest corners of gnome bugzilla and use it in my own project, and also decouple it and release it while I’m at it. It accepts a string, and extracts a task and a date from it.

This is a natural date parser for C# – it allows you to specify a task with a due date and it extracts a valid DateTime object and returns it.

Examples:

I’m pasting the XML documentation of the source code.

        /// Original Task string: "GSoC Proposals due before 3rd april"
        /// The Task is:"GSoC Proposals due" and the due 4/3/2009 3:51:09 PM
        ///
        /// Original Task string: "Lab reports due on monday"
        /// The Task is:"Lab reports due" and the due 3/30/2009 3:51:09 PM
        ///
        /// Original Task string: "Date at 8PM this saturday"
        /// The Task is:"Date at 8PM" and the due 3/28/2009 3:51:09 PM
        ///
        /// Original Task string: "New years' on January 1st"
        /// The Task is:"New years'" and the due 1/1/2010 3:51:09 PM
        ///
        /// Original Task string: "Study solid state pysics on tuesday"
        /// The Task is:"Study solid state pysics" and the due 3/31/2009 3:51:09 PM
        ///
        /// Original Task string: "Solid state physics test next tuesday"
        /// The Task is:"Solid state physics test" and the due 4/7/2009 3:51:09 PM
        ///
        /// Original Task string: "April fools' on 1st"
        /// The Task is:"April fools'" and the due 4/1/2009 3:51:09 PM
        ///
        /// Original Task string: "Friend's birthday on Feb 5th"
        /// The Task is:"Friend's birthday" and the due 2/5/2010 3:51:09 PM

Features: * Extremely robust guessing – if you say “Mid term eval due on 1st”, it looks for the first of next month and adds it. * Supports natural constructs – if you say “some task due next tuesday”, the task string is “some task”. If you use on/before/during/this/due, those are treated as date descriptors. Moreover if you say “Fix this bug due tommorow”, the task is “fix this bug”. If you say “Fix bug this friday”, the task is “fix bug”.

Usage: This is written as a simple, uncoupled, highly cohesive class “NaturalDateParser”. Since the name of the class or namespace isn’t mentioned in the functions of interest, you can always extract it and place it in your own code.

To use:

    string input, task;
    DateTime dueDate;
    input = "Mid term evaluations on 6th";</p>

<pre><code>NaturalDateParser.GuessDateFromString(input, out task, out dueDate); // this has to be in the same namespace

Console.WriteLine("Output: {0}, DueDate: {1}", task, dueDate); //Output: Mid term evaluations, DueDate: 07/06/2009 11:28:21
</code></pre>

<p>

Download: To get the latest version of this class, clone the github gist:

git clone git://gist.github.com/140483.git

or you can view it from: http://gist.github.com/140483

The code is licensed under the liberal MIT/X11 license. Use it in anything you wish at your own risk.

Unit tests: I wrote NUnit tests to practice writing the C# tests. If you need to have unit tests for this class, email me and I will send them to you.

A letter to myself

I turn 22 in ~3 hours. Never cared much about birthdays but for the past three years, I write a letter to myself one year in the future, and ten years in the future. I use http://www.futureme.org who’s never forgotten to send me my memorabilia.

Two years ago, I had hit rock bottom in my life so far. I wrote to myself asking to have changed, and last year was a more pleasant email.

Here’s what I hoped to have achieved by this date:

  1. Got an internship at Google or somewhere similar. (I was at Google when I wrote it) [DONE]
  2. Got a tattoo which is 2in x 2in and says “42” and nothing more. [DONE] :)
  3. Clear out all pending courses. [DONE]
  4. Lose last remaining excess weight to a target below 64 kilograms. [DONE]
  5. Learn to stay in the here and now. Focus on the task at hand. [DOING]
  6. Write a good deal of code. [DONE]
  7. Run the 7 kilometers in under 40 minutes [Did it in 31].
  8. Spend more time with friends, and force them if they are busy [DONE]
  9. Migrating the website to Appengine or something. [Meh. if it ain’t broke, don’t fix it]

It’s nice to be able to go back and see what I was up-to two years ago due to the fancy archive feature. It feels good to know that you did what you intended to do, and maybe even a little more.

I’m off to write an email to myself, which will be delivered next year. If you’re reading this – future me, Hello!

Project Conn’r – Easy, open, cross-network communication framework

Close connection - Verbundenheit by alles-schlumpf.One Minute Sales pitch: Conn’r is an open source platform to allow developers to build applications that allow users to exchange realtime information freely between a user‘s client and all the other social contacts from existing social networks – thereby making the humble sign up form redundant. A user with any social network credentials can communicate with another user of the same client as long as they share a common link on atleast one of the many (extendable) supported social networks. This library is being written to prevent companies like Facebook, Twitter, and Google to have sole control over being able to write social applications that exploit their friend graph. With Conn’r – anyone can write an application that works out of the box with all social networks.

Let me illustrate with an example. Suppose I want to write a social whiteboard client application – where users can collaborate with friends and come up with new ideas. I would have to create a new network, add a friend graph database, and make multiple architectures, including a realtime comet-based communication architecture. Last but not least, users will have to sign up and ask others to sign up as well – something which will cause adoption percentage to drop.

If a developer uses Connr to handle all the communications instead, all a user has to enter his/her credentials for any major social network like Twitter, Facebook, MySpace, Google, FriendFeed. The Connr framework will identify all of your friends and send them to a confidential server (which will also be open source). Since the server has also got information of all the other Twitter, Myspace, Facebook, etc users available, it looks for all the relevant connections and connects the users using a jabber bridge.

connr

To illustrate roughly how conn’r works, I have drawn up a rough flowchart. It’s largely self explanatory, and you can download a high resolution version of it or the original .dia source.

The framework does two major functions:

  1. Determine social connections, and find out which of them are connected to the same Connr server.
  2. Abstract a jabber connection by making sure that clients are compatible and to send data of unlimited sizes.

To write an application like Google Wave – with realtime communications between all your friends will become absolutely trivial. We envision a new wave of applications where any user is not limited by what social applications his network provider builds. You can build desktop client apps which use this functionality but also build web-based applications which do not involve a sign up procedure.

The development team:

The project has finished the planning stages. My friend from college Sanket Agarwal is looking into automating Prosody, a blazing fast lua based XMPP server, which we will use to handle the communications, he will start writing the serverside components to match users from various social networks in either C++ or Scala. My personal involvement so far is only the idea, and part of the C#/Mono client library which was extracted from another file-sharing type project I had tried to build earlier.

We will be hosting all our code on Github and I own http://connr.com so I guess the project will live over there. The name was originally for our anonymous chat project but I feel this one has more steam.

(Image from Flickr user alles-schlumpf. Creative commons by-nc-sa)