Sunday, January 31, 2010

ShowAndTell

I had an idea for an app recently, that helped one to learn complex software. I remember a few years back, trying to understand 3ds Max. Anyone who has ever used Max will remember getting bewildered at the enormous amount of options that Max throws in your face. Although Max is very powerful and gives a lot of control in the hands of the experienced user, it can be very tedious to learn.
The idea I had was to record the mouse movements of an expert who is proficient in the software's uses. We can assume that a user trying to learn a software will most probably have it installed on his machine. So if we can capture the mouse movements of an expert and play it out on the learner's computer, it would be like a video tutorial without all the hassles of recording one. Audio recordings can also be played as and when required.
The hitch?
In order to record mouse movements, we need to set up a global mouse hook. I know how to do it in Windows, but that requires using kernel APIs like SetWindowsHookEx, which I think is crap. I have not figured out how to do this in linux however.
On the other hand, taking control of the mouse is trivially simple. In Java, there exists a class called Robot, which can be used to control the mouse. Similar APIs must exist for other languages as well I am sure.
I will post more ideas for apps that make learning intuitive.

Tuesday, January 26, 2010

A high point on the roller-coaster

We WON! HkB (Hijli ki Bijli) aka Malhar won gold in Sargam, the eastern groups events in Spring Fest for the second time around. It was pure awesomeness, check us out on youtube!
I also participated in Wildfire. We did not win anything as the bands that came were really good, but maybe next year, things might change! We did an original, whose lyrics and vocal melody I had composed. I will put up the recording in some time. Meanwhile, here are the lyrics

Torn

In a world of hate and fear,
despair, misery, everywhere
In the darkness, death awaits
Inside every man, there is a demon of the night

Strong as steel,
burning drive,
an invincible warrior,
with hatred in his eyes,
with a vow so strong,
to spread the blight,
he reads omens,
and strikes on time

With darkness in his heart,
a venom tainted soul,
dreams he tears apart,
reaps evil, wherever he goes

Take the leap,
in the darkness and you'll find,
a demon to possess you,
take over your mind.
With a vow so strong,
to spread the blight,
kill all who oppose,
crush the rest in time.

In your dreams,
in your nightmares it awaits
A demon to possess you
to show you the way
To make a binding oath,
to teach a creed that's sure and true
to do unto others
before they do unto you

Pretty extreme huh? :D

Now I need to learn latex....

Thursday, January 21, 2010

Trying times

Another crazy day, woke up at 7:30 for a morning class, wrote some code, started practice at 9, recorded two songs, finished practice at 4:30 in the a.m. , and now back in my room.
Hallelujah!
BTW, can't wait for Jan 26th for Mass Effect 2. Heard the XBox 360 version got leaked already!

Wednesday, January 20, 2010

A glass half full

Last night was a trying one for many different reasons.
Went to the gym and tried some front squats. The whole thing turned it out to be an epic fail, apparently I had hurt my back a few days ago and that injury resurfaced again.
For some days I had been working on integrating twitter with SMS Invite. Till last night I knew nothing about the Android threading model, asynchronous tasks, and my knowledge of services and activities were feeble at best. The simple problem of executing an http get request exposed my lack of knowledge in all the above topics (not that their knowledge is needed anyway to execute the above task). I spent a solid 5 hours learning the internals of the threading model, handlers, activities, intents, and what you have it...only to realize later that the Uses permissions:Internet was disabled. 0_0
Now if I had been a bit more careful, maybe I would have completed my task much earlier but without the knowledge that I had gained.
Just makes me wonder, is this God at work?

Listening to : Porcupine Tree - Trains

Saturday, January 16, 2010

ASTs and online judges

A very hectic week comes to an end!
Composed the vocal melody of a metal song (will post recorded mp3 somewhere), finished working on the cyclomatic complexity (which IMHO, is the most complicated part of designing any module that measures quality of code), successfully conducted the Algorithmik event at RSM, IIT Kgp 2010 and polishing twitter syncing of SMS Invite. Unfortunately, not much progress on the Latex end :(

Some thoughts:
1) NRefactory is quite well designed (I think) but it did take some time to get the hang of it. I cannot really comment on its ease-of-use as this is the first parser infrastructure I have leveraged for my own projects. I plan to should snoop around a bit more. Getting one's hands dirty with large compiler projects is a great way to learn about compiler techniques. Next stop is LLVM! \m/

2)Must must must learn how to effectively manage a linux based network. Conducting the event smoothly was a pain but we somehow managed. I plan to create an online judge for future events. Lets see how that will get implemented (probably using some CGI scripts).

3)Android is a pain in the ass....

Oh btw, SMS Invite v0.11 beta is out in the market. We have a separate version for CDMA phones as well so some problems encountered while on CDMA networks should be solved.

Signing off...

Wednesday, January 13, 2010

On coffee joints and lousy APIs

A friend of mine claimed about a year ago that he was in talks with the top honchos at Cafe Coffee Day, a hep coffee shop, to open a branch in Kharagpur. I found it hard to believe then. Not my friend's reach, no, but the idea that an urban phenomenon such as CCD could possibly work in the bucolic shit-hole that is Kharagpur. I stand corrected. CCD opened in my campus a few days ago and has already attracted a large crowd (mostly of the Page 3 variety). The fact of the matter is that the spending capacity of the modern Indian youth has increased. As our values become more westernized, our attitudes towards living a frugal life, consuming food items not traditionally considered healthy or "Indian" , change.
Now if that is a good or a bad thing is something that I will not touch upon, because honestly, I do not know. What I do know is that CCD will probably do good business, and may encourage investors to create franchises of other famous food brands like McDonalds and KFC. Generally these fast-food joints are located on or near prime real-estate. Thus, one of the major contributors to their costs are establishment and rent charges. Leasing land in Kharagpur on the other hand is relatively inexpensive. Add to it the fact that at present a lot of land in the IIT campus is not utilized. Hence the costs saved there can be passed on directly to the students. Its a win-win situation!
On a more technical note, I have been working with the Android API recently and I frankly, do not like it much. Sure its much better than the Symbian platform, but I cannot compare it with the IPhone as I have not really used it. The Android API is in a constant state of flux and Google keeps adding and removing stuff. Its not the adding I am concerned about, but the removing irritates me. Many important utility functions pertaining to text encoding have not been implemented which means writing a serious HTTP client is a major pain in the backside.
And of course, code breaks. When a method or class is deprecated it can have an adverse impact on your application if it depends on that method/class. Generally it means that you have to rewrite certain parts to make use of the new replacement. Occasionally it can mean having to completely rethink and reimplement the application logic in the framework provided by the new
API.
I have been experimenting a bit with REST based APIs recently and thought of incorporating a twitter client into SMS Invite. Here is the skeleton code that I came up with. Enjoy!

package com.android.test.webstuff;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.net.URLEncoder;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.ByteArrayBuffer;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloActivity extends Activity {

TextView tv;
String text;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

tv = new TextView(this);
postData();
setContentView(tv);

}

public void postData(){

String Username = "myusername";
String Password = "mypassword";
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.twitter.com/statuses/update.xml");
httpclient.getParams().setBooleanParameter("http.protocol.expect-continue", false);

try {
// Add your data
List nameValuePairs = new ArrayList(1);
nameValuePairs.add(new BasicNameValuePair("status", "test"));
/.setEntity(new UrlEncodedFormEntity(nameValuePairs));

httppost.addHeader("Authorization", "Basic "+Base64.encodeBytes((Username+":"+Password).getBytes()));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);

InputStream is = response.getEntity().getContent();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(20);

int current = 0;
while((current = bis.read()) != -1){
baf.append((byte)current);

}

/* Convert the Bytes read to a String. */
text = new String(baf.toByteArray());
tv.setText(text);


} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}

PS: The Base64 routine converts a byte array of characters to its Base 64 encoding. Its a bit long so I have not posted that.

Saturday, January 9, 2010

Unpowered by Caffeine

That was the would-be tag line of WithoutCoffee, a portal that I am helping out my buddy with. We plan on developing Android apps that would prove useful in the day to day life of smart phone users. Our first app, SMS Invite v0.1 Beta, which is the undergraduate project of my friend, has been released and is getting rave reviews. Which is as it should be considering the effort he put in polishing the product.
Simultaneously he has launched http://www.withoutcoffee.com as well as a blog that we intend to use to connect with our readers. It will mostly focus on short tutorials explaining the working of the different apps we develop and reflections on the experience gained working on the Android platform.
We invite you to give SMS Invite a whirl! Don't have an Android phone? Fret not, because we plan on porting it to the other major mobile OSs that there exist. Feedback and constructive criticism is always welcome.
Remember, with SMS Invite, the party is only an SMS away! :)

Friday, January 1, 2010

Help -> About

Dear Readers
This blog will mainly contain ramblings regarding technology and the events in my life that change my perspective and views. I have never been a good writer, mainly because I did not have anything to write about. However I am convinced that blogging may be useful as a tool of introspection and help us learn more about ourselves because we are forced to THINK, which is the logical precursor to an ACT, which is the making of a HABIT. (I have started rambling already :)
Either way, happy new year to you folks and all the very best for your future endeavors.
Sincerely
diffoperator