Tuesday, August 18, 2009

Google And Microsoft : Twin Effect

The evidence can be found everywhere. Headlines, headways and in some people's head.
The pattern is recognizable given that one have been around since DOS days.
Google, the company that was once just associated with "search" is no longer staying where its domain is. It has tentacles that reaches far and wide but with one clear difference. The community don't realize it or maybe they do but they sure don't hate it.

Perhaps MS's reputation and brand was so powerfully seared into the hearts and minds of computing folks that we could only identify MS as the only possible gigantic sofware company that we could hate. One that squashes its competitor mercilessly using various "partnership" tactics through the history of IT. Novell...Nescape....scandisk....C++ builder...Word Perfect...Quattro Pro....OS/2......Isn't scandisk just a program, yeah, so was Netscape browser. Sure some of these companies survived but became obscure tech names, a fraction of what they could have been.

Times are changing indeed. Windows Mobile is losing out. Microsoft Live Search is a joke. A victim of its own game in an ever changing world. Its rare to hear MS losing in an area that it plans to focus or profit from but the new kid in town is nothing like MS have seen. Previously everyone had to fight MS in MS own turf...and since that turf is the OS itself, it was rarely a fair fight. Its 90% of the World's desktops dear, get real. But what if you challenge MS in a very unlikely place...the cloud?

When MS IE7 could not open the Google Wave page and Chrome could use it perfectly (ok firefox and other browsers worked somewhat) , you get a very familiar feeling. This creepy Dejavu feeling just jumps out of the page into your lap.

Android phones? Google Doc? GMail for Corporates? GAE hosted domain.

China always had a long history of bad Emperors and those who attempt to topple them. Given such power and position, it was usual for Emperors to behave like morons and do what they want regardless of the citizens sentiments. Heck an Emperor gets to have 600++ wives!

But Chinese History also teaches us one thing, topple one Emperor, the one taking over his place is no better.

Saturday, August 15, 2009

Google Wave Hackathon Malaysia

Today i attended the Wave hackathon. Some lucky fellas here are supposed to be the first in Malaysia to get google wave accounts (for the sandbox) .

Nazrul (the founder of MYGTUG) gave an overview and everyone quickly surfed and googled for more info . Basically for most of us, its the first time we are exposed to this Wave thing. This whole idea of blurring the line between emails and chats is boggling but opens up a whole new way of using "emails".

Due to some problems faced by other participants, somehow my "robot" was the only one demo-able at the end of the day. I guess my decision to just use the robot for fun things turns out to be easier to implement, Java programmers also complained about some issues with the api and Wave's unstability in handling certain events.

I went in with Python and i was using WingIde Pro, that must have been a real time saver since the autocompletion and module search gave lots of revelation of how some of the Wave Api works and fixes most easy errors. The problem is that you can't do a local test, so all the code must be uploaded before you can test it , simple errors will be a waste of time.

Here are some "traps" to avoid in creating a "robot" :-

1. If you add a capability to the robot AFTER you already uploaded your first robot, you will need to bump the version in your "whateverrobot.py" under the _main_ so that Google Wave will recognize that you are supporting a new event handling.
Java programmers will need to modify the capabilities.xml file to bump the version.

2. Don't just use the Tutorial example in creating Blips, you will end up modifying the blip
that the user posted instead of creating a new one since that is what the Tutorial example does.
You will get something like "User and robot" in the blip which is probably not what you want, instead just : newblip = root_wavelet.CreateBlip().GetDocument()
You can also try blip.CreateChild() if want it to appear below the original blip.
You must use the Tutorial example to learn and do the first upload though! Just don't
copy everyline when u want to do your actual one.

3. Upload the tutorial example so make sure all your other setup is already working.
You will need to setup a Google Application Engine account and a choice of either
Python or Java. (for Python i was using ver 2.5.4). Setting up Google Application Engine requires a valid and real mobile phone (it will sms a validation code).

4. IE.7 is unsupported!! Yeah, i guess Google is doing to Microsoft what Microsoft used
to do to some companies. So make sure you just stick to Chrome when participating.

Overall, it was a pleasant and enjoyable event.

Here is the robot i wrote (for those who have google wave account) :


Have Fun!

Thursday, August 6, 2009

Too much support?


I got this screen this morning when searching for something in MS.
Did MS just redirected all support calls to online search? ;-)

Monday, August 3, 2009

C# calling C DLL routines (YET ANOTHER ONE)

I am totally baffled on the examples given by sites on how to call C routines in DLL via C#.
Not only are many of them repeating one same example after another, you soon realize they are not very helpful when you want to do something that is common like passing a structure with all kinds of types inside.

So here is one example that serve as an answer to MANY of the pinvoke/calling C apis problem :- ( i wanted to say 90% but i can't justify or prove it ;-))

I got this example structure that has :

struct ToughCallDef
{
char * ptrName; // this will contain some return string values
int ptrNameLen; // normal integer
MEMBLOCK somestruct; // a structure
ANOTERBLOCK* structpointer; // structure pointer
int* ptrtoMyInt; // integer pointer
char * ptrID // this must be supplied
};

Just translate it this way :-

[StructLayout(LayoutKind.Sequential)]
public class ToughCallDef
{
IntPtr ptrName;
MEMBLOCK somestruct; // you need to define MEMBLOCK also
IntPtr structPointer;
IntPtr ptrtoMyInt;
IntPtr ptrID;
}

And if the call requires a reference to this "ToughCall" :

[DllImport("anotherc.dll")]
public static extern int Call_C_API(ref ptrToughCall);

define it this way instead :

[DllImport("anotherc.dll")]
public static extern int Call_C_API(IntPtr ptrToughCall);


Basically anything to do with Pointers, regardless of whether its integer *, char *, structure reference etc, just use IntPtr.


1 . If the member is a "char *" that you expect return values you point the IntPtr this way :

szReason = new StringBuilder(100);
zReason.Append(' ', 100); // empty string with spaces
ToughCall.PtrName = Marshal.StringToHGlobalAnsi(m_szReason.ToString());


2. If the member is a "char *" that you need to assign a value before passing in :

ToughCall.ptrID = Marshal.StringToHGlobalAnsi(StringVar);


3. If the member is a structure pointer, you assign it this way :

ANOTHERBLOCK o = new ANOTHERBLOCK();
ToughCall.structPointer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(ANOTHERBLOCK)));
Marshal.StructureToPtr(o, ToughCall.structPointer, true);



4. After calling the C routine you will need to do the following to get the values :-
  1. If its a string, use :
    string s = Marshal.PtrToStringAnsi(ToughCall.PtrName)
  2. If its a structure use :
    Marshal.PtrToStructure(ToughCall.structPointer, o);
  3. Free any allocated strings/struct pointers via :
    Marshal.FreeHGlobal

That's it.