Saturday, June 30, 2012

Google IO 2012 Extended in Malayalam @ Kochi, Kerala

Preface

First of all thanks to my friend Safil for the post title. You will come to know the history of name reading forward.

Day before yesterday(28Jun2012) when we were doing true agile development (true agile means the team is into a room and develop the application without much external disturbances) one of my colleague came and said 'An event called Google IO is going to happen in our Infopark this weekend'.As I was in the mood of creating a framework, I didn't give much attention to that. I replied like, I may or may not attend. But yesterday when I checked the link, I was surprised. As you all know, Google IO is a big event conducted by Google to demonstrate their new technologies. I don't think in the near future, I will get a chance to attend the original event as I am working in Kochi and my company will not sponsor me because I am mainly into Microsoft technology stack. So why should I miss such an event which I can attend near to my workplace. This event  is Google IO Extented. So normally we can expect more, than in the original :-) .Yes I cancelled all the weekend programs including my usual trip to native and started registration process.

Oh. The first hurdle came.Registration has been closed. But there are seats available. Also there was a link present at the registration page to contact the sponsors and its MindSoft Global .I got a very fast response from them. They asked my mobile number and sent me the ticket. Again by end of day, I got a call from them to confirm my presence. Thanks to Jisha, I think that is the name of the lady who helped me. Then the next problem came .The event starts at 9AM .That is the time, when I normally think whether I should wake up or not.Anyway decided to try level best.

Event started

As sun is punctual in it's duties, the day came and I reached there as usual at 9:15AM. Just 15mins late. The event was not yet started. People are standing here and there. The normal Kochi programmer faces are there along with some faces of my colleagues. Wow there are enough tech enthusiasts in my company too. There was a circle formed by the standing people which means Praseed Pai is in the center :-) .The hall is A/C so didn't spend much time at the doors.


The event started by around 9:45AM. One lady gave introduction to the event and she handed over stage to a guy with long hair,modern look. Simply saying in colloquial English a Yo-Yo guy. His entire look says that he cannot be a programmer, QA analyst or manager.50% chance is there for a UX guy. So we can conclude him as an external event management team member. The next unforgettable thing started from there. He just started talking in pure Malayalam. 

Wow nice. As it is Google related program we can expect unexpected. May be Google is introducing a new technology where we can code in our own language. As everybody love their mother tongue, I also love my mother tongue Malayalam and even I am running a Malayalam blog. But why this people whispering each other?


Oh this is not something from Google. He just speaks in Malayalam .I don't think it because he cannot speak in English. May be he is hired to conduct the event in Malayalam. This is an technical event where there will be  people from different states of India who don't understand the language used in other states. Yes that is correct.He asked the audience to introduce themselves and the second guy introduced himself as a developer from Culcutta ,West Bengal. Then the whispering became side talks and one of my friends Shalvin even requested him to talk in English. But it didn't change .The introduction of Audience had completed and he started some small games such as gifts for answering funny questions and tongue twisters and all purely in Malayalam. One of the audience even responded like I am not here to play games. 

Ok. I think its a high level manager, somebody came and explained the situation. The guy who is supposed to come here from Chennai GUG was not able to make it. But he will be addressing through Google hangout. Wow that is great. The first time I am going to see the hang out in action .To be frank Google+ is the only product which I cannot digest and use.

Hi Event management guy, we are extremely sorry if that incident made you feel bad. We were not expecting something what you are best in. May be some expectation setting went wrong. All the best..

What I(We) expected?

So what we expected .Oh sorry I should talk about my expectation. May be because I have only seen the Microsoft related events such as K-MUG sessions, my expectation was, there will be some guys who is closely working with Google technologies such as Android,Cloud,etc... and they will take interesting technological sessions and demonstrate Google's new technology innovations and give some insights to what google is working on, how google does all these things etc...

Since there were no talks about the agenda, I had to ask what is the agenda. The agenda was
  • Teleconference with GUG Chennai Community Manager.
  • Video streaming of original Google IO 2012 videos from Youtube through projector.
  • A session on open source by Cochin university professor Ignatius Kunjumon
  • Showcasing innovative technology products in the locality.
    • Android Oven.
    • Security through smart phone.
    • Apps by MindSoft.

Hangout with Karthik, GUG community manager Chennai

He was supposed to be here.But due to other GUG activities in Chennai he was not able to. If my googling  skills are still strong, he runs a website and tweets frequently. He gave a brief introduction about the GUG communities and the start of Kochi GUG. This event is conducted as part of getting more reach to Kochi GUG. We are in India and as usual there were streaming issues due to internet connectivity and it didn't go in an interactive manner. I believe he will soon come to Kochi to give another enthusiastic session.

After this session there was a Tea break.

Google IO 2012 video streaming in projector

I had downloaded the videos from youtube .But didn't get a chance to watch due to other activities. So decided to watch it in this event. There were people in the same situation and for us this was good. No questions no interactions. Good time to sleep, if you are not interested.

As you know, it is interesting for developers in the beginning when they talk about new Android version 4.1 Jelly Bean. Especially notification changes, cloud notification support,incremental app updates from play store, improved audio etc...But simply saying it is a bug fixed / performance tuned version of 4.0 ICS same like Win 7 came after Vista.

If you are a gadget freak, you will be excited to hear about the new Google tablet and the features in it such as JellyBean, Offline voice recognition, Google Now etc...Google now gives you the power to fire your personal assistant. Didn't understand? Google Now is the application which connects with all sorts of data in Google such as your calendar, maps, transit etc.. and uses the same to help you to take decisions. For example if you are in restaurant and you have to attend a meeting in 10 mins, it will tell you how to reach there? By bus or train or in Car and the route to take. ie you are holding the time in your hand or a program / device is controlling you. But I don't know what will happen to this calculations, if the food you had last time is not digested and caused a 'call of nature'.

After that the video became marketing. A ball named Nexus Q to play music, stream multimedia content from Google Play to your house hold players. Social streaming in Nexus Q enables more than one person to control the TV. If multiple people starts controlling the media player in a normal Indian liquor parties, what will be the minimum time to start people attacking each other for their favorite? God knows.

The Google identity came after this. Some guys from Google jumped from sky and took bi-cycles to ride into the stage. It is true that we can do something like this, if we works in Google. All they were wearing a special type of glass which has camera in the right side. The lady who was there in stage explains or marketing that glass by saying you can take real time moments such as the moment baby looks at Mom's eyes,photos from the tennis player's view angle etc...Isn't it the old spy cam which we are using for years? I wish they would have demoed the terminator type head mount display glass

A session on open source by Ignatius Kunjumon

This was the first 'human in front of' session and conducted by Prof Ignatius Kunjumon from CUSAT. I though he would first tell so many drawbacks about Microsoft and capitalism finally ask or compel everybody to switch over to Linux like any other open source advocates. But that didn't happen. He started with open source and jumped to his favorite subject Python. He gave links to his python works in Github. I had used python scripts in my first company to run the builds and observed that it is really fast to compile and create MSIs. The main message which I got from him is something else.
Code for yourself before you code for others.
This is simple. Make your life easier with your programs before you make others life easier. If you cannot make your life easier with your programs how can you write code to make others life easier.Every developer should think on this.

Innovative Products - Android Microwave Oven

The main take away for me from the event is the idea of MAID. This is the name they have given to their Android oven. This idea is from the young heads of SectorQube. The company deserves special congrats for encouraging and supporting the innovative ideas of it's employees.I wish let it be another Google or more than Google.One more interesting part is this company is started by young innovative just passed out students. Means there is no need to wait for permissions or financial support from bald headed managers to execute an innovation.

Also there is a funny story behind the birth of this idea. I thought I can find a link to that story so that you can read in their own words. But unfortunately, I was not able to find. So according to my understanding here is the story.

Harthal day is celebrated as national holiday in Kerala and it is normal to have 2-3 harthals / month .Oh I forgot to explain about the harthal. It is the way to show protest against government. There are enough political parties here and they will call for harthal even if there are reasons or not. If somebody declared that tomorrow it is harthal, people will plan the harthal day. Parties, house repairing, shop innovations, visits to relatives etc... Because on the harthal day everything including restaurants and transportation will be shut off except hospitals & IT companies. IT companies here refers to software development, BPO, call center support etc...The food and everything else needs to be collected on the day before harthal.

Friends in SectorQube were coding a game targeted for Keralites and suddenly a harthal was declared. So they decided to launch on that day because people will be at home and they can enjoy playing the game. They completed game late night and after that when they look for food, there were nothing left which is ready to eat. They had only a Microwave oven and nobody knows how to cook in oven. All are IT geeks and they used their google skills to download the recipes but those didn't help them since they don't know how to cook. That night passed with hungry stomachs and next morning the idea of MAID had born to help people like them from starving

What is the moral of the story? Starve for one night to get innovative ideas :-) 

Innovative product - Sentinel security

This is from the same company MindHelix which created another innovative product for Indians called Tuk-Tuk meter. They observed Oh not only they, we all Indians can usually see that people are arguing with Taxi / Auto drivers regarding they fare. This software will help us to get an idea about fare so that we can argue better and even call Police to solve the issue. It works based on GPS and calculates the fare using local rates. 

This time the innovation is to secure women and children from attacks and is called Sentinel .It works with a simple button. When the user feels that she/he is lost, or somebody suspected is behind them simple press that button. Immediately mail/sms/whatever will go to concerned parties such as Police / family / friends etc...according to the configuration.

The people behind this even tells that,this cannot assure 100% security because it is based on so many other factors such as mode of attack, the internet availability,battery charge and any downtime in server. They host their services in Windows cloud and we all knew what happened to Windows Azure on leap day this year. But they will be happy, if their innovation saves at least one life.

Products from MindSoft

MindSoft demoed some of their products such as mobile version of their Inventory management product, MyFin a personal financial manager just like all the other free softwares in the market etc...

Conclusion

When we conducted K-MUG events in our office there were similar incidents like A/C was not enough for the hall, lack of internet connectivity etc...But MindSoft did it well. Thanks to all guys in MindSoft for organizing such an event especially the tea & lunch. Expecting more from you guys in future. (Not better food but the events). Keep rocking...

Hope the title will not hurt anybody and will take it in the sense. If not please let me know.

Friday, June 29, 2012

Learning through videos–Seems good

I was not an advocate of training especially video based. According to me as a developer we can learn by doing .Not the other way where we learn first and do things. Whenever I had to learn new technologies I usually google for its features and get an understanding about why that is invented and how to achieve the basic things. Then start practicing samples myself.
There are so many videos available out there and most of them are free. But I rarely see those videos because I cannot wait till the end to get what I want. The instructor will tell so many things which we already know and in between they tell something we don’t know. Most of the things they explain may not be useful in our project. So why should we spent time to hear what we know or what we don’t want? Another drawback of videos is we cannot search for particular  content or voice!!
But recently my current company provided pluralsight.com license to selected employees and I happened to be part of the group. This makes me to start seeing training videos. I selected HTML 5 videos first and completed one basic training. It changed my view about video training little bit. The main benefits I could see are as follows
  • When you go above the designation ladder your coding time will get reduced and meeting time will increase and you may not get much time to have hands on experience in each and every corner of the technology. The videos help us to understand all most all of the features of technology without doing it ourselves and of course when needed we can try it. Being a technical lead or Architect you must know all the options available in the technology before deciding something.
  • Since it is video it can be played at any time.During travelling, when you are waiting for your girl friend or while getting bored etc…
  • If you are smart you can take it parallel with your other tasks. Maximize player when you need something to be seen in the video.
This is not to promote pluralsight videos but to promote the learning through videos. There are so many videos out there in channel9 and youtube

Monday, June 25, 2012

Shared folder and permission for Everyone via C#.Net

This is again from the tool which we did to verify some installers. Don’t ask why the installer is trying to create some shared folders with permission for Everyone.Oh its not a simple read permission, its FullControl!!! Full control to everyone to do anything inside the folders. There is a famous saying in my mother tongue Malayalam which is “No questions on stories because it’s a story” Smile
We are interested in the technical side of the scenario. Here by I just want to show a sample of how to retrieve the file or folder permissions using C#.Net. Its simple as creating Object of DirectorySecurity and iterating through its properties.
Note that this will work for any kind of folders ie with normal folders such as  “c:\windows\system32\” or shared folders such as “\\localhost\dropbox
private bool CheckFolderPermForEveryone(string sharedFolderPath)
{
    DirectorySecurity dsShared = Directory.GetAccessControl(sharedFolderPath);
    AuthorizationRuleCollection authRules= dsShared.GetAccessRules(true, true, typeof(NTAccount));
    foreach (FileSystemAccessRule rule in authRules)
    {
        if (rule.IdentityReference.Value.Contains("Everyone"))
        {
            if (rule.FileSystemRights==FileSystemRights.FullControl){
                return true;
            }
        }
    }
    return false;
}





Please don’t look at the performance or coding style as this really quick code just to make the tool working.

Monday, June 18, 2012

Getting service account of windows service from C#.Net

Again another scenario from the tool which I had to work couple of weeks back. One of installers in the release pack had a windows service installer and that windows service had to be in a particular windows service account other than NetworkService. This obviously came to the tool’s requirement basket.
When we think about the windows service management the first class which will come into mind is the ServiceController. This can be easily initialized using its constructor by passing the service name and we can play around it. But unfortunately this don’t have details about the service account on which the windows service is running . (You can get the service name easily, if you go to the log on tab in service properties). So what to do? Yes our famous WMI apis are there to help.Simply get the object of our service and get the “StartName” property.
private bool CheckWindoesServiceAccount(string serviceName,string serviceAccountName)
{
    //ServiceController sc = new ServiceController("SSBExternalActivator");
    ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_Service where Name='" + serviceName + "'");
    ManagementObjectCollection CollectionOfResults = theSearcher.Get();
    foreach (ManagementObject CurrentObject in CollectionOfResults)
    {
        Console.WriteLine(CurrentObject.Properties["StartName"].Name + " : " + CurrentObject.Properties["StartName"].Value);
        if (!CurrentObject.Properties["StartName"].Value.ToString().Contains(serviceAccountName)) return false;
        return true;
    }
    return false;
}






Happy coding.

Monday, June 11, 2012

Getting time from another machine in C#.Net

This is the continuation of my previous post which is related to a tool we had to write for the production environment. There was a requirement for the tool that the DB Server, Web Server, and all should be at the same time and this post explains about getting time from another machine through C#.Net code.
When we get such a requirement, we can think about so many possibilities like exposing a WCF service, bare port communication via sockets, etc…But the easier way (may be not fully dependable) was issuing a net time command from C# and read the console using Process class.
When we issue the net time command in the normal command window the output will look as follows. We had to retrieve the DateTime object from this raw text.
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\joyg>net time \\[machine name]
Current time at \\[machine name] is 5/25/2012 8:23:54 PM

The command completed successfully.

C:\Users\joyg>

Had to use really bad programming practice of splitting the string with “\r\n” and again split using the word “is”. What will happen to the word “is” when the user runs the tool in a different locale? How can I trust the date-time string if the target machine is in a different time zone? God knows…Anyway I am sharing the code with you. Use it at your risk.

private DateTime ReadRemoteTime(string machineName)
{
    string cmd= "/c " + @"net time \\"+machineName;
    ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd.exe", cmd)
    {
        RedirectStandardOutput = true,
        UseShellExecute = false,
        CreateNoWindow = true
    };
    System.Diagnostics.Process proc = new System.Diagnostics.Process() {StartInfo = procStartInfo};
    proc.Start();
    proc.WaitForExit();
    string consoleOutput = proc.StandardOutput.ReadToEnd();
    //HACK:THis has a high degree of failure in non english cultures.
    string split1 = consoleOutput.Split(new string[] {"\r\n\r\n"},StringSplitOptions.RemoveEmptyEntries)[0];
    string split2 = split1.Split(new string[]{"is"},StringSplitOptions.RemoveEmptyEntries)[1];
    DateTime resultDate = DateTime.Parse(split2,CultureInfo.CurrentCulture);
    return resultDate; 
}

From my mind, I am not able to wish you Happy coding :(

Monday, June 4, 2012

Talking to IIS 7 via C#.Net

Last week, I was thrown into a wired task of creating a tool to ensure that some msi’s are installed properly in the production environment. The software system has around 4 deployment targets such as database server, web server where we keep aspx web pages,application server where the WCF services are hosted and queue processors .Each has its on prerequisites and corresponding msi files to be installed. Since the developers used same system to act like the above four and due to the lack of deployment diagram combined with lack of msi installation testing, none of the guys in production environment were able to setup properly. The escalations happened and finally settled on creation of a tool which will check all the production scenarios after installation. The development team came with their list of items which they usually look when such a deployment issue comes.
There were 41 items in the check list provided and one guy started coding all those conditions in .Net windows app. The scenarios are really funny such as “Make sure IIS is installed in the machine,Make sure some specific folders and files are present after installing msi” .After one day it came to me as the scenarios were getting little harder for that guy.
After looking at the task my first impression was we are re-inventing the wheel .If the msi testing is proper and there is a good prerequisites checklist to the production intra team, we don’t need to write this tool. There were funny questions such  as “We need to verify that the installer has copied particular files to target locations . Then do we need to verify that the RAM is still there or not through this same tool?” .Even if such a tool is needed, do we really need to write in C#.Net? Why can’t we write using windows power shell scripting which is simple and easy to manage? All these questions were answered with single sentence. “Client is not able to install the build which we delivered and setup production environment. This tool needs to be completed by EOD tomorrow.”
The positive side of this is, I got some scenarios to blog.Also a chance to deal with .Net management APIs.So let’s start with the first one where we talk to IIS 7 through C#.Net
IIS Management APIS
Earlier we had to use the WMI to deal with IIS and other system related tasks if we want to do from .Net. But with IIS7 MSFT released an object model based API which can be directly called from C#.Net code. For more details please refer Scott’s blog post about the same.
As you know the gateway to APIs from .Net is dll and here too we need to follow the same. There are 2 main dlls we need to refer.You won’t find the dlls when you just right click on the project and select the “Add Reference” menu item.
Adding references to IIS 7 management dlls
The main dlls are
You may locate the dlls at [Install Drive]:\Windows\System32\inetsrv
Starting IIS7 APIs
The main entry point to the API is the ServerManager instance which corresponds to the IIS 7 web server itself.Please ensure that the ServerManager instance is obtained using OpenRemote instead of normal ServerManager constructor. I don’t know why the normal new ServerManager() is returning some other IIS instance where we won’t get actual web sites and application pools. I had to spent around 30mins to get the actual object of ServerManager, because I was using constructor new ServerManager() to obtain the instance. This is the only one reason for this blog post.Otherwise why should I duplicate the content in web Smile.
Checking for http & net.tcp port bindings of Default Web Site from C#.Net
Our requirement in the tool was to ensure that the “Default Web Site” in IIS has 2 bindings one is normal http with port 80 and other is net.tcp with 808. In normal practice this will be ensured by a installer prerequisite document or by the installer itself.
//Check for port binding of DefaultWebsite http 80 & net.tcp 808.*
private bool CheckPortBinding(string webSiteName)
{
    Microsoft.Web.Administration.ServerManager iisManager = Microsoft.Web.Administration.ServerManager.OpenRemote("127.0.0.1");
    Microsoft.Web.Administration.Site site = iisManager.Sites.FirstOrDefault(webSite => webSite.Name == webSiteName);

    if (site == null) throw new InvalidOperationException(string.Format("Not able to find web site : {0}", webSiteName));

    Microsoft.Web.Administration.Binding httpBinding = site.Bindings.FirstOrDefault(binding => binding.Protocol.Equals("http"));
    if (httpBinding == null) return false;
    if (httpBinding.EndPoint.Port != 80) return false;

    Microsoft.Web.Administration.Binding netTcpBinding = site.Bindings.FirstOrDefault(binding => binding.Protocol.Equals("net.tcp"));
    if (netTcpBinding == null) return false;
    if (! netTcpBinding.BindingInformation.Equals("808:*")) return false;
    return true;
}


Happy coding.