Story of Google map’s driving directions and a missing turn

Day before yesterday (29th June 2012) evening, I had to travel from a location in Margao (marked as point A in the screen-shot below) to Mickey’s in Colva (marked as point B). As I had not been to the place before, I took help from Google Maps App in my Samsung Galaxy S2 to identify the path between the two points. Google Maps marked the path as shown in the screen-shot below.

With the help of GPS tracking in google map app, I started following the path. Everything went fine till I reached the turn identified with red circle in the screen-shot above. I was surprised to notice that there was no road for the turn at that point.

Fortunately, I was little familiar with this area and thus was able to identify the alternate route which could connect me to point B. Following screen-shot will show you the alternate route.

Luckily, I was familiar with the location and thus, was able to identify the alternate route quickly. But the people who use the app to find paths/directions while travelling to a different state or an unknown location may not be so lucky.

While using the applications like google maps, we all need to remember that it is just a tool, which help us only to find a solution to the problem, but it need not be the best or the most accurate one. In some cases, we may be presented with wrong results as well.

Thus, if you are using google maps to plan your next family trip, make sure you verify all the information properly. Otherwise, your family trip may convert into an interesting adventure trip.

Airtel 3G With Samsung Galaxy S2 : My Alternate Source For High-Speed Internet

Can you imagine life without high speed internet access? Without it, we won’t be able to:

  • Enjoy services provided by sites like Youtube
  • Download free and opensource applications
  • Make video calls through services like Skype
  • Share screens and work from home (I hope you like it)

Seriously, high speed internet adds significant value to our daily life. Like most of my friends in India, I use BSNL Broadband to access high speed internet service at home. It provides pretty good connectivity in terms of speed and quality as shown in the screenshot below:

However, during monsoon period, I often face connectivity issues which can cause problems, especially if I want to work from home. Thus, I prefer to have alternate source of high speed internet connection as backup. I prefer this source to be wireless and stable while providing good internet speed.

While searching for another source of high speed internet access, I came across Airtel 3G. Following screenshot will show you the speeds that I get with Airtel 3G:

These screenshots show that Airtel 3G provides internet with speed which is half of what is provided by BSNL broadband. Depending on the quality of network, I can even get better speed.

To access this internet connection on my laptop, I make use of the “Portable Wi-Fi Hotspot” feature provided by my Samsung Galaxy S2 mobile phone. It’s a great device with lot of good features and this is just one of it.

I have been using the internet provided by Airtel 3G for around a month now and I am pretty much happy with it. Now I use it for most of my regular tasks and rely of BSNL broadband only to download large files.

Understanding and Applying Artificial Neural Networks : Engineering Perspective

Lasts week (15th November to 19th November), NITTTR (National Institute of Technical Teachers Training and Research) had organized a course on Artificial Neural Networks at Government College Of Engineering – Farmagudi, Goa. I was appointed as course faculty for this event.

Personally, I do not believe in concept of teaching. Humans are smart and intelligent animals and as such, they are capable of learning new things themselves based on their experience and observations. Thus, rather than providing a training, I preferred sharing my experience and knowledge on ANN with the members attending the course.

Considering the fact that this event was organized for staff of engineering colleges, the “Joint – Discussion” was titled, “Engineering Solutions With Artificial Intelligence Using A System Popularized As Artificial Neural Networks“.

Generally, we discuss Artificial Neural Networks either in theoretical perspective or in terms of purely scientific applications. However, the world of practical engineering is always different from theoretical or purely scientific perspective. The same applies to applications of ANN in perspective of modern digital engineering.

In this joint discussion, we spent first two days trying to understand the concept of artificial neural networks. To understand it practically, demonstrations were provided using the examples developed in JRuby. The code written for this purpose is now available on GitHub (The link is provided at the end of this post).

For next two days, all the participants were allowed to experiment with the JRuby code. Participants could play around with different training sets while modifying variables like learning rate, momentum, activation functions, number of hidden layers, number of neurons in hidden layers etc. They could also experiment with performing the same training using backpropagation algorithm and genetic algorithm. This helped them in understanding the challenges faced by engineers in practically implementing the solutions using ANN.

On the last day (Friday 19th, November 2010), we concluded the joint discussion by determining the capabilities and limitations of ANN based on the experience and knowledge obtained by participants in four days. At the end, a demo of OCR written in Javascript was given by Tejas Vernekar.

During the joint discussion, some of the alternative non-neural solutions for few problems were discussed as well. A ruby equivalent of spell checker (which uses statistical language processing) originally developed in python was also demonstrated. The ruby equivalent code is available in the code in GitHub Repository.

In case you are interested in JRuby code used during the joint discussion, you can download it from this GitHub repository.

Just Released: Maya Programming Language

Around one year ago, I had started experimenting with concepts of creating programming languages. I first started with building few DSLs (Domain Specific Languages) using Ruby and Boo. It was quite interesting to work on development of DSLs. While doing this, I learnt a lot about how the programming languages are developed.

Eventually, I thought of writing my own programming language. While I was in engineering college as a student, we had a subject on language translators. This subject taught us lot of theory on how languages are compiled or interpreted. However, we never got a chance to write even a simple programming language during our practicals. According to few, it was not possible to write one in one semester’s time.

That turned out to be my main motivation. I decided to write this programming language without using any compiler tools like LEX and YACC. I ended up writing my own lexical analyzer, the grammar parser and the language using the concepts taught to us in engineering college only. I worked on it daily for around an hour and within two weeks, I had the basic language ready.

Today, the code is released under GPL license. It’s available on GitHub at http://github.com/kamatanay/MayaLanguage

I hope it would be useful for students learning language translators.

Why did I name it Maya? Well, that’s the name of my sweetheart wife. Isn’t that a sweet name?

Error in ruby on rails documentation for ActionController::UrlWriter

In Ruby on rails, methods that generate urls from named routes are not globally accessible. For example, you can’t access them from console (script/console). If you want to use these methods from such places, then the rails documentation for ActionController::UrlWriter suggests two ways of doing it. According to this documentation, you can:

  1. Include ActionController::UrlWriter in your class
  2. Call the method directly on ActionController::UrlWriter

When I tried it out, only the first method worked. I was able to use methods generated from named routes in console after including ActionController::UrlWriter. However, it was not possible to call those methods on ActionController::UrlWriter. This looks like an issue with documentation to me.

It might be the case that the second method used to work in earlier version of rails. As rails is constantly being developed, some refactoring might have made the second method obsolete. I hope rails community will fix such issues in documentation soon.

RSpec Matchers: Be careful while testing boolean values

While testing methods that return boolean values in ruby (the ones that end in ‘?’), try to avoid following matchers:

method_returning_true?.should be_true

or

method_returning_false?should be_false

This is because, ‘be_true’ and ‘be_false’ matchers considers ‘nil’ to be false and anything other than ‘nil’ to be true. When we write methods in ruby which end with question mark (‘?’), intent is that the method will return boolean value. To ensure that our tests will always reflect the intent of code, use following to assert boolean values instead of using ‘be_true’ or ‘be_false’ matchers:

method_returning_true?.should == true

or

method_returning_false?.should == false

Simplicity is the best policy

Few days ago I came across a story here. In this story, an assembly line worker suggests a simple, low-cost but highly effective solution to the problem for which engineers had developed a complex and expensive solution. Why am I referring to this story today? Because, I notice lot of people having a misconception that you need to have a complex system to solve a complex problem.

People innovate and develop solutions or machines to reduce human efforts. In other words, machines or solutions are developed to simply our day-to-day activities. By developing complex systems, most of us don’t realize that:

  • Instead of simplifying something, we have actually transferred the problem to another new system: Complex solutions give us an impression that it solves the problem completely. But in reality, it might end up creating new problems for you. This new problem could be in the form of maintenance or in the form of some hidden cost.
  • Complex solutions are often too costly: This means that only few rich people will be able to use the solution.

I am sure that most of us would have heard about interactive whiteboards (also known as smart boards). These boards are quite costly as they would cost you at least few hundred thousand rupees. Due to this high cost, lot of schools and colleges cannot enjoy the benefits of such iterative systems. Now, is there a cheaper and simpler solution to this problem?

Of course there is!!! Johnny Chung Lee, who works as a researcher at Microsoft – Applied sciences, has developed a simple systems that achieves most of the functionality provided by commercial smart boards at fraction of their cost. His project makes use of an IR pen, Nintendo Wii remote and a small software application. You can watch the following video to know how this system works:

Next time, before developing any solutions or systems, try to ask yourself a question: “Is this the only way of doing this? Can there be simple way to do it?”

I am sure you will definitely find an answer :)

After file and photo sharing, it’s time for “code sharing”

If we want to share a file or photos while chatting with our friends on internet using IM tools like GTalk, we use file sharing services available online. These services allow us to upload a file to their servers and give us a link which we can share with our friends. But what if you are a developer and want to share a small piece of code with your friend? You are left with following choices:

  • Paste it in your chat: I know most of us do this when we quickly want to share the code. However, its annoying as it becomes unreadable and makes your code look as if its obfuscated :)
  • Email: This approach is better compared to previous approach, however the recipient wil need to manually compile the code and run it if he wants to know the output.

I won’t say these approaches are useless. But I would like to have a place, where I can put my code fragment and then share it using a link. I can use this link in my gtalk status, chat or even in twitter posts.

Luckily, there is a site called “codepad” that allows us to do exactly the same thing. It allows us to share a piece of code using a small url.

You can try it now at “http://codepad.org/” or take a look at this example code posted by me at “http://codepad.org/XZpSNngW

Finally, one thing I would like to see is support for C# code.

C# 3.5 in Ubuntu

Today, I managed to install Mono 2.4 in Ubuntu 9.04 without affecting Ubuntu’s default mono installation. Thanks to the instructions here (Building Mono 2.4 from source on Ubuntu 8.10), I was able to install latest mono/monodevelop in a parallel environment. Now I can work on C# 3.5 code in Linux as well.

Here is the screen shot of MonoDevelop instance with the code given in this post.

MonoDevelop running C# 3.5 code

Y-Combinator in C#

For last few days, I was trying to use lambda feature of C# to implement Y-Combinator. After few trial and errors, I was able to implement it in C# 3.5. I’m currently posting the code here and in my next blog, I’ll explain how I derived it.

In this code, Y-Combinator function, is used to implement anonymous recursive-factorial function called ‘factorial’.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YCombinator
{
    class Program
    {
        delegate Func RecursiveFunction(RecursiveFunction f);

        static void Main(string[] args)
        {

            Func, Func>, Func> Y = (f) =>
            {
                RecursiveFunction function = (h) =>
                {
                    return (x) =>
                    {
                        return f(h(h))(x);
                    };
                };
                return function(function);
            };

            Func factorial = Y(function=>
            {
                return x =>
                {
                    return x == 0 ? 1 : x * function(x - 1);
                };
            });
            Console.WriteLine(factorial(5));
            Console.ReadLine();
        }
    }
}