Category Archives: Tech

Mindtree Osmosis 2007: An external view

 

 

Last weekend, I attended Mindtree’s annual tech fest, Osmosis. This year they had organized the fest in the unconference style. To quote from their site

“To foster greater participation and to cut through the air of formality, Osmosis 2007 has adopted the “unconference” mode. Unconference merges the distinction between the speaker and the audience, and everyone is a participant.”

Also, this year they opened the doors for external participants, which is why I could attend it. My brother invited me over and we both had a lot of fun, to say the least.

The day began with a talk by Ashok Soota, Chairman of Mindtree. This talk itself was in unconference style. Soota spoke for a few minutes and left the ground open for participants to ask him questions. After the short and sweet talk, unconference sessions began.

The first session I attended had a rather controversial title ‘Are software engineers getting extinct?‘ With great minds like Bagchi, Soota, KK, Partha, Kamran, Desmukh in the room, speakers had a tough time controlling the audience. The argument was basically that the magic of software industry is fading, and with automation being the talk of the town, software might become extinct. The session saw some good participation from the audience.

Twitter session caught my attention next. This session was like an introduction to twitter and micro-blogging. It was not very useful for me because I knew about twitter beforehand. This was more like one-way information flow, there was not much to argue or discuss, so no heated debate here.

I and my Project Manager was the next session which me and my brother wanted to attend. But by the time we reached the room, it was so jam packed, we didn’t have place even to stand. We got to rest our minds for half an hour before breaking for lunch. There was live music by MAG, Mindtree’s very own musical band and they belted out some good numbers.

Post lunch, it was the much awaited session on Google’s Android. It was meant to be an introductory session on Google’s mobile OS and SDK, but the session veered to the debate mode when one person decided to argue about every point the speakers made. The speakers were not prepared for this and it was clearly evident. Some good points made by Mindtree minds about why we need Android at all and why open source is scary!

Another controversial topic – Innovation. After being fed up of the ‘compulsary innovation’ at my organization, I was hoping this session will help in venting out the frustration. Sigh, it only added to it. I saw the same attitude in Mindtree too. People who belong to the innovation team are all ga-ga over it and always inspiring (read as forcing) people to think out of the box and innovate, whereas the rest of the world is fed up of it and cringe whenever they hear the word innovation. We had some good argument about what is an idea, an innovation and an invention.

This was followed by the grilling session of CTOs Vinod Desmukh, CTO of R&D Services and Kamran Ozair, CTO of IT Services. The two minds were bombarded with questions collected previously from Mindtree minds. There were some interesting questions and both of them handled it really well. This session gave a glimpse of how strong both of them are in their respective domains. I was floored.

Mr. Bagchi took over next and gave a totally different speech. The Bagchi on stage was completely different from what I had imagined him to be. The T-shirt clad bald man on stage cracking jokes on his colleagues and sometimes being not so politically right was different from the man who I had seen through his columns in TOI. With this the unconference session came to an end.

This was the first time I attended a fest in this format and honestly, I didn’t know what to expect. The moment I stepped into the conference hall, I knew I was going to like it. The atmosphere was electric and the attitude, contagious. When so many great minds (read as nerds) come together and discuss their passion, how can it be not good? It was a pity to see some girls touching and re-touching their make-ups in rest rooms when such serious debate was going behind closed doors. Apparently some people turned up to have fun in a different way.

The whole thing was organized very well. Every session started on time and ended on time – it is mind boggling to even imagine how this was achieved. Facilities like lunch, coffee, tea, handouts, badges – everything was in its place. As an external participant, I was awed! And I was told the whole credit goes to Shahnawaz Khan. Special thanks to him – he does make it look so easy. The standing ovation he got at the end of the day just goes on to say how much hard work and effort he had put in.

As an external participant, I am in awe of Mindtree. To try something like this and to let outsiders attend, takes a lot of guts. Mindtree took the plunge and came out victorious. I enjoyed every moment of it and this weekend was one of the very few weekends which I consider well spent. Now that the unconference is over, I wish it comes around soon. I can’t wait to attend Osmosis 2008.

Advertisements
Tagged , ,

Removing items in a list while iterating through it

See the following code:

List list = new List();

for (int i = 1; i < 10; i++) { list.Add(i); } foreach (int i in list) { list.Remove(i); } [/source] Do you see anything wrong in this piece of code? No? Okay. Execute this code and you will get a System.InvalidOperationException with the message “Collection was modified; enumeration operation may not execute.”

The first time foreach loop executes, it deletes the first item and in the second iteration, this nasty exception is thrown. Reason? You deleted the first item and the list has changed. If not for the InvalidOperationException , you could have got a IndexOutOfRange exception while traversing the list.

So, how does one delete some items in the list while iterating through the list? I faced this problem in my project today and I couldn’t come up with an elegant solution. I did come up with a hack. I identify all items that need to be deleted and mark them with a flag (I need one iteration here). In another iteration, I create a new list and copy all those items which are not marked.

Sorry, I couldn’t come up with something better. If you have a solution or a better fix, please do let me know. Please note that if I want to remove all items, I can use list.Clear(). I am talking about a scenario where I want to delete only a select few items.

Update:

I read somewhere that if you use for loop instead of foreach, this problem does not arise. True, you will not get an exception, but you might not delete the items that you actually want to delete. Let’s see what happens in our case.

List list = new List();

for (int i = 1; i < 10; i++) { list.Add(i); } for (int i = 0; i < list.Count; i++) { int remove = list[i]; list.Remove(remove); } [/source] You will delete items 1, 3, 5, 7 and 9. After the for loop exits, your list will still have 2, 4, 6 and 8. Surprised? Let's see why this is so. First iteration: i = 0, remove = 1. Deleted item = 1 Once you delete this item, the list has changed. So, the first element in the list is now 2.
Second iteration: i = 1, remove = 3. Deleted item = 3
Third iteration: i = 2, remove = 5. Deleted item = 5

and so on….

So, replacing foreach with a for is not a solution.

Disable Close button in Windows form

To disable that little close button in your Windows form, either you can set the ControlBox field in Properties window to False or or add this two line in the contructor:

this.ControlBox = false;

Same goes for Maximize and Minimize boxes. Set it using Properties window or add these lines:


this.MaximizeBox = false;
this.MinimizeBox = false;

Simple, huh?

Setting up Darwin Streaming Server – Part 2

Part 1 can be found here.

Darwin Streaming Server documentation states that the video clips that need to be streamed should be under the Movies folder. This, on Windows, is C:\Program Files\Darwin Streaming Server\Movies. When the server receives a RTSP request for a video clip, it checks this folder for that file. What is not documented is that the server looks recursively under the sub-folders for the requested video clip.

So, if you have folders like Songs, FunnyVideos etc. under Movies folder, Darwin server will be able to stream all video clips under these sub-folders. Catch: These sub-folders should not contain spaces! If a sub-folder ‘Funny Videos’ is present under Movies folder and you request for a file which is under ‘Funny Videos’, Darwin server will return a 404 Not Found error.

I wonder why this is not included in Darwin Streaming Server documentation.

Main Form loses focus

Apologies if this post comes across as naive. I recently put my foot into the Windows Forms world and I have been learning new things. This might be a problem which all GUI programmers have encountered on day one and also know the solution to it. This post is to those souls like me who make a late entry into this magical world and seem to get lost, err… lose focus.

Problem:

We have a main form called MainForm. Whenever the user clicks a button on this MainForm, a method Copy in a class HelperClass is called. This method Copy uses the kernel call FileSystem.CopyFile to carry out the copying. One reason to use the kernel call is you need not re-write the progress bar and cancel features, just reuse the features provided by the kernel call. This will display the standard Windows file copying dialog with a cancel button.

The problem is, whenever you click Cancel on the file copying dialog, the MainForm loses focus.

Solution:

Since we are using the file copying dialog provided by the kernel, we have no access to the dialog directly. Hence, we cannot set the MainForm as the owner of the file copying dialog.

The solution to this problem is, in MainForm, right after we make a call to Copy method, set the focus back to MainForm.

    Copy(source, destination);
this.Focus();

Problem solved.

How to setup Darwin Streaming Server on Windows

PS: Part 2 of this article can be found here.

What is Darwin Streaming Server?

Darwin Streaming Server is an open source, free to use streaming server from Apple. The commercial version of this server is the Quick Time Streaming Server.

Where do I get it from?

The Darwin streaming server source code can be downloaded here. You need an Apple ID for this. Registration is free – go get an Apple ID for yourself.

How do I install?

Once you download the source code, you will see a install.bat in the root directory. Just double click on it and the batch file will copy the necessary files under C:\Program Files\Darwin Streaming Server. This is all the installation required.

How do I start streaming?

Along with the source code, Apple ships a few sample video clips which are ready to be streamed. All these video clips are under the C:\Program Files\Darwin Streaming Server\Movies folder. You can stream any of these video clips and view it on a player. Open up a command prompt. Go to C:\Program Files\Darwin Streaming Server and start Darwin server by typing DarwinStreamingServer.exe -d. If all is fine, you will get some INFO messages and a message that says ‘Streaming Server done starting up’. This means the server is up and ready to accept client connections.

If you get an error something like ‘WARNING: Another process is already using the following RTSP port: 554’, then the Darwin Service is already running in the background and you don’t have to start the server explicitly.

Your server is ready and all set to stream.

How do I connect using a player?

VLC Player: File->Open Network Stream. Select RTSP and give the URL as rtsp://localhost:554/sample_100kbit.mp4

QuickTime player: File->Open URL. Give the URL as rtsp://localhost:554/sample_100kbit.mp4

If all is fine, you should see an animated ‘Q’ – logo of Quick Time.

More info?

Google is of course there.

Administrator’s guide.

FAQ.

Darwin users mailing list.

Article on software patents

Jeff Atwood has an interesting and thought-provoking article on software patents. Read it if you haven’t yet.

I had goosebumps when I read this:

Think about that for a minute. Seriously think about it. Every time you write code — even a brand new algorithm in a clean room environment— you could be infringing a patent, somehow, somewhere.

Synergy

Two CPUs. Two monitors. One mouse. One keyboard. The equation doesn’t sound feasible? Synergy makes it feasible.

Synergy is an open source tool, implemented in C++ which lets you share a mouse and a keyboard between multiple computers. The application is small and considering that it works over TCP/IP, it is really fast.

Setting up Synergy is very easy. Install Synergy on all machines you want access to. Assign one machine as server and the others as client. What is the difference? The mouse and keyboard which is assigned as server shares the peripherals between all machines whereas the peripherals belonging to the clients are just theirs – there is no sharing.

Matt Cutts introduced me to this nifty tool and now that I have used it for a week, I am wondering how I ever survived without it. Matt gives a good step-by-step description of setting up Synergy. Go over to his blog or see the help page on Synergy Sourceforge. Install it and liberate yourself from managing multiple mouses and keyboards.

Attensa: RSS Reader for Outlook

Working in a company which does not allow employees to use any other email client but Outlook, I was forced to look for an RSS reader which can plug in to Outlook and let me read the interesting blogs on my list.

A quick google pointed me to Attensa. Trusting a few google results, I downloaded Attensa and installed it. I haven’t regretted it. I like the simplicity of it. It sits as a plug-in in my Outlook and has a similar interface as Outlook mailbox. Each RSS feed has its own folder (not mandatory, this is configurable) and all posts will be listed under their respective folders. The frequency of checking for new posts is configurable and so are the alerts. Attensa supports Outlook’s desktop alerts.

The one thing that I hate about Attensa is it’s ‘River Views’ or some such thing. They have tried to give a view from which you can read all new posts of all your feeds. There is so much information on this page and it’s so messy, the moment you see it, you will change the view. If designed well, this view can actually be helpful.

For anybody who is still using Outlook and looking for an RSS reader, Attensa is a good choice.

C#: List of struct

Talking about discoveries, I discovered something about C# today.

Let’s say I have a struct ‘MyStruct’ with an integer as its data member. and I create a list of this type.

List list = new List();

I add a few elements to this list.

list.Add(new MyStruct(10));
list.Add(new MyStruct(20));

If I try to modify any element in this list, that is when things become interesting.

list[0].m_age = 30;

The compiler starts its blaring sirens. Error: Cannot modify the return value of System.Collections.Generic.List<MyStruct>.this[int]’ because it is not a variable

This problem does not arise if you have a list of class instead of a structure. i.e, if I change MyStruct to a class (and call it MyClass to avoid confusion), this error message goes away. Why should it matter for structs and not for classes? I knew the basic difference between these two, one being a value type and the other being a reference type. This knowledge wasn’t enough to crack this puzzle.

A quick googling gave me the answer. The operator [] is actually a function call. When you index a list and get the individual element, you are actually making a function call. You get the individual element as the return value of the function. This return value is placed on the stack and when you try to use the dot operator on this, you are actually trying to modify the return value of the function. i.e. you are modifying a copy of the element and your modifications will not affect the element in the list. The compiler, smart it is, catches this and informs you of the pitfall.

This does not affect a list of class items because class is a reference type. When you use [] operator on a list of class, the [] function is actually returning a reference to the original object and hence your modification on this reference object will cause the original element to change.

Phew! One discovery that was. Next time you are creating a list of structs, remember this little piece of information.

Update:

Beware! If you save the return value of the function in a variable, modify that variable and expect the actual list element to change, that’s not going to happen.

MyStruct s = list[0];
s.m_age = 40; // This will not change the element list[0]

Modifying the variable s is not going to modify list[0].

This poses an interesting question. Once you create a list of structs and initialize it, there is no way you can modify it? I need to find this out. Look out for more updates on this.