Bug Vanquisher

31 May 2007

Nice little tip

Filed under: Tips — Tanveer Badar @ 5:10 PM

We needed to pass some extra information on one web page.

That information was part of a column in a GridView and should have been available to client side script but not rendered. We could not set the Visible property of that column to false. That would not have solved the problem because anything that is not visible isn’t even rendered by ASP.Net to the client.

We thought and we thought like we do in situations like this. Eventually, one trick came to my mind, just like the illumination that ’64 S on a C B’ means 64 squares on a chess board. I told the developer to use a template column, add a HiddenField as ItemTemplate and EditItemTemplate for that column, set the Value property to the information we needed to pass and voila! Problem was solved with only a three pixel wide column displayed. To make that even less noticable, we set the boder style for that column to Transparent, BorderWidth to 0px and even those little horizontal lines were gone.

29 May 2007

The best explanation!

Filed under: Fun — Tanveer Badar @ 12:47 PM

Why mirrors reverse left and right? Eric Lippert provides the best explanation I have seen so far.

“But why then do we all think of mirrors as reversing left and right, if in fact they reverse front-back? Psychologically, humans see a front-back-reversed human as a left-right reversed human. That image of a south-facing person smiling back at you is not an image of a human being at all. Their DNA spirals the wrong way. All their body fat is made out of indigestible Olestra. Their heart is on the wrong side of the body. If we could somehow create a real being who produced exactly that image, down to the front-back-reversed internal structure, there’s no way that they could produce viable offspring with a non-reversed human.

But none of these is apparent at a glance. Since humans have almost perfect left-right symmetry it is extremely easy to interpret an image of a back-front-reversed human as a left-right reversed human. After all, if you were trying to act to look like the person in the mirror, that’s what you’d do – simply reverse your left and right behaviour. You decide what is “slippable” and what isn’t. If you are trying to look like the image in the mirror looks, you’d ignore all that stuff about your DNA and internal organs and reverse left and right, because that happens to produce the image that looks most similar. If humans had different symmetries then mirrors would not appear to reverse left-right at all, because our psychology would be different.”

I never thought about the internal asymmetries in us. :)

A matter of different opinions

Filed under: Personal — Tanveer Badar @ 11:13 AM

Robert McLaws, of Windows-Now.com wrote a patriotic post, which I find pretty absurd. To save you the trouble of going to that link, here is the replica:

To All American Troops, Past and Future: Thank You!

Today, May 29, 2007, 10 hours ago | Robert McLawsGo to full article

Just wanted to take a minute and say “thanks” to all the individuals who have given their lives in the service of the United States military. Their sacrifices enable the freedoms that I enjoy, including the ability to say whatever I want on my blog. For that, I am most grateful. I’m off to spend time with my family today, so everyone have a safe and happy holiday!”

However, I find this thanks message delusional. He talks of the ‘sacrifices’ which are actually an act of terrorism committed by invaders. The freedom he enjoys is founded on the false ideas of wide-spread Islam phobia in the western world. And there is no need to remind that the accusations of WMD in Iraq were incorrect and boldly projected to the world to secure control to one of the biggest oil resources in the world. Moreover, it is not only the Americans who died in Iraq.

Those who died should have thanked their killers that their misery in Iraq ended earlier than the ones still surviving. On Sunday, I was watching JAG on StartWorld. It hosted a story of a military psychiatrist, she was under pressure from the work load of consulting and advising the invaders. Eventually, their nightmares and horrors infested her mind too. They became her own. Now, the reason they gave at the end was increased work load because more invaders were facing front line battle than ever before, support services were given to civil contractors with a resulting decline in quality. I bet even Vietnam seems a vacation resort to all invaders now.

But in the end, I also feel sorry for all those who died. It shouldn’t have been their fate to have war imposed on them so mercilessly. I request when you say your prayers for the invaders who died, please keep in mind the countless innocent victims of Iraq who have their whole lives devastated. Remember the Afghanis. Remember the women who lost their husbands, the children whose joy of life was snatched from them. Remember the virgins whose greatest wealth was either forcibly taken in the name of home searches or they were forced to sell it for ‘only’ $5 in order to survive another day. Don’t forget the prisoners of Guantanamo Bay or Abu-Gharib prison. Or The suicide bombers who give their lives to make the difference.

17 May 2007

What Turing Machines are not!

Filed under: Computer Theory, Decontamination — Tanveer Badar @ 2:15 PM

I read this on Eric Lippert’s blog:

“Because the number of states is so large, it is often more helpful to model machines as “Turing machines”, which can have unlimited internal storage”

Immediately, a pain started in my head. I had to write what follows as a comment and on my blog!

A Turing machine is a Turing machine because it can read/write its storage in random order. This makes it recognize languages of type anbncn. Take away the write capability, it reduces to a FSA, capable of only recognizing an. Strip away the random access, languages recognized reduce to anbn.

Turing machines never have infinite states. No model for a computing machine has infinite states. What can be infinite is

1- input set (can be infinite in any case)
2- output set (can be infinite in any case)
3- memory (aka. internal storage, is infinite only starting from push down automata)

Consider the problem of having infinite states in Raymond style: What would happen if a machine could be constructed which had infinite states?

1- There would be no way to encode those states in any base. A simple state machine can be encoded in ceil( log2(states) ) number of bits. This number is always infinite for infinite states.
2- The machine’s control would alone require infinite storage.

What’s missing?

Filed under: Uncategorized — Tanveer Badar @ 7:23 AM

Try, cry, fry, by, sky, my, rhythm, dry, shy…

15 May 2007

SMTP server at Microsoft Middle East site is down

Filed under: Fun — Tanveer Badar @ 11:56 AM

There is some problem with their smtp server, the registration page is blurting out everything. Their website is hosted in d:\websites, they are running .Net framework 1.1.

See for yourself.

14 May 2007

It gets back to bite in the butt!

Filed under: Bugz — Tanveer Badar @ 1:30 PM

Last week, we are changing the architecture of a project a bit. Some functions returned string messages. Well string messages from all sorts of classes defined in a constant namespace.

I was assigned the job to clean that mess up and have a single class that contained codes for all possible messages. Each function would now return some message code which would latter be looked up through another function. That function was interface specific as there were a number of ways to call those core function. Each interface necessitated its own handling of message codes.

So far so good, I unified the message codes, removed a couple of classes whose sole purpose was to act as a container to some weird error condition. All messages ended up in one class and there corresponding codes in another. Everything was working fine till that moment.

During that entire process, I had to go through almost all the code which made me quite sentimental about the project as it had been written over the past two years by people I never heard of. You could almost associate a personality to a piece of code by simply looking at it.

This had many revelations for me. Unnecessary lines, improperly written loops, things like

bool flag = true;

if( flag )
    return true;
    return false;

The thing I wrote above is very neatly formatted, image this with no indentation and multiple statements on one line.

Since every thing was done successfully and the application worked correctly, apart from two or three codes left from the final lookup function, my spirits were really high. And having seen almost all code written over a long period of time, I noticed some functions took there parameters by reference. Running FxCop identified them as design changes. I went ahead and removed ref from every type which was not a valuetype. But alas, I forgot the check after this breaking change that the application was still working fine or not.

Many use cases were broken. You see the problem was that I removed ref from string parameters too, which were being modified in the function and the caller needed that modified value. You may wonder why string needed that special handling, it is because a string once created, is immutable. Any time you change it to something else, it creates a new string with the new contents and old copy is unmodified.

Here is a little program to demonstrate that. You should see the message You have been bitten in the butt. printed on the command line. [Note: If you also see Even this does not work, you should check you compiler’s sanity.]

using System;

public class Program
    public static void Main( )
        string message = "Message";
        BiteInTheButt( message );
        if ( message != "New message" )
            Console.WriteLine( "You have been bitten in the butt." );
        BiteInTheButt( ref message );
        if ( message != "New message 2" )
            Console.WriteLine( "Even this does not work" );

    static void BiteInTheButt( string message )
        message = "New message";

    static void BiteInTheButt( ref string message )
        message = "New message 2";

This problem will happen with any immutable type. If you want to modify the original object passed in argument, you should pass it as ref parameter. I also suppose the Freezables in WPF behave similarly after they are frozen, no matter what you do with them in the caller, there is simply no way to propagate back the changes you do.

In general, if you pass an immutable type as argument and want any changes made to it to be propagated back, prefix it with a ref!

Done with RTL language support in blogs

Filed under: Rant vs Vent — Tanveer Badar @ 1:30 PM

See my last post, how it has been messed up, the terrible font (perhaps I should edit it to set to something more readable), still more terrible LTR layout of a RTL language.

9 May 2007

مقدور ہو تو ساتھـ رکھوں نوحہ گر کو میں

Filed under: Fun, Personal — Tanveer Badar @ 10:29 PM

آللہ نے اسے بنایا، پہلے ہمیں بنایا، جانے کس چیز کی سزا دی کہ دونوں کو ایک ساتھـ‏‌ اس جہاں میں بھیج دیا- اگر الگ رکھتا تو وہ تو نہ بھگتنا پڑتا جو ستم ہفتہ میں دس دفعہ ہوتا ہے- پانچ دفعہ صبح کے وقت اور پانچ دفعہ شام کو- نکلے بھی اس کی وجہ سے تھے، ایک اپنے ساتھ چار کو لے بھی جاۓ گی-

مابدولت کی نازک سی جان اپنے حصے کی روزی (انگریزی والی نہیں، اگلے کئی تک سال ایسا کوئی حادثہ نہیں ہونے والا) کمانے نکلتی ہے- بس میں وہ بھی ساتھـ ہوتی ہیں اور تھوک کے بھاؤ ہوتی ہیں، جی ہاں صحیح سمجھے، بچیاں، لڑکیاں اور عورتیں- ہر اسٹاپ پر چند چڑھتی ہیں، چند اترتی ہیں اور میرا خون کھولا جاتی ہیں- اب اس کا کیا کیا جاۓ کہ ہر چیز میں مرد عورت برابر مگر بسوں میں چڑھیں گی تو پوری بس نواب زادی کے انتظار میں رکے- اتریں تو ‘ہاۓ اللہ’، چڑھیں تو جان نکلے- ارے بھائی اگر اتنا ہی شوق ہے تو اپنے چونچلے تو چاردیواری کے اندر چھوڑ آؤ-

جاتے وقت پہنچنے کی جلدی، آتے وقت آنے کی، ایسے میں ہر جگہ گاڑیوں کا اژدہام- ہر اسٹاپ پر نازک مزاجی کا مظاہرہ بھی ضرور ہوگا- ڈرائیور سے بھی بھائی کا رشتہ قائم کرنا ہے، ساتھـ جو بچوں کی فوج ہے وہ بھی نہ کھوۓ- چار دمیں جو چھوٹی بہن یا دوست کے نام پر ساتھ لٹک گئی ہیں ان کی بھی ناز برداریاں- بس بھی اپنی پسند کی جگہ رکوائیں گی اور جب تک دفع نہ ہو گئیں، یا اندر نہ آگئیں رکنا بھی ضروری ہے- جی تو چاہتا ہے کہ آگے جا کر ایک لات ماروں، اب اترو بھی، دوسروں کا وقت تو نہ برباد ہو-

شاہراہ فیصل پر جناح اسپتال کا سگنل دس منٹ بند ہوتا ہے، ایک منٹ کیلۓ کھلا، انجن اسٹارٹ بھی نہ ہوا تھا کہ پھر بند، ایسے میں اگر کسی عورت کو بھی اترنا یا چڑھنا ہے تو سمجھ لیجیے کہ یہ دس منٹ، آدھا گھنٹہ بن گۓ ہیں- اگلا اسٹاپ ہے، NICVD، دل کی بیماریوں کا اسپتال، میرا بس چلے تو اس مخلوق کو ہی داخل کرا دوں، رہتی انسانیت احسان مانے گی- پھر آتا ہے، جناح اسپتال اور یونیورسٹی، یہاں بھی ایک غول بس کی جان چھوڑتا ہے- اول تو محترما‎ؤں کو اترنا ہی یاد نہیں رہتا، اگر اتفاق سے دماغ پر زور دے بھی لیا تو دس منٹ لگا دیں گی- آج ایک چڑھیں اور پھر ڈرائیور سے لڑنے لگیں کہ اس نے بتایا کیوں نہیں کہ وہ غلط بس میں چڑھ گئیں ہیں، یعنی قصور کس کا ہوا؟

آفس سے گھر تک کے سفر میں، جو کہ suffer بھی بن جاتا ہے، پندرہ منٹ ایسے ضائع ہوتے ہیں- اگر اختیار ہوتا تو میں عورتوں کی بسیں الگ کروا دیتا کہ اب ان میں آرام سے سوسو کر جانا- آدمیوں کی جان چھوٹتی-

5 May 2007


Filed under: Uncategorized — Tanveer Badar @ 11:28 AM

I just read in a e-zine,

“Digg This: Legal Scare
And finally, let’s explain all this 09-f9-11-02-9d… silliness. This
week, users of a tech site called Digg.com, which publishes user-
submitted links to other sites’ articles and content, posted hundreds
of references to a secret number that can be used to help break the
copy protection in HD DVD movies. In response to a cease and desist
order from the Advanced Access Content System Licensing Administrator,
which controls HD DVD licensing, Digg.com deleted the references to
the number (and many user accounts as well). The result was a user
backlash that saw to it that every post on Digg.com‘s front page
contained the number. Once that happened, Digg.com issued a statement
to its users saying it would cease censoring the posts. How do you use
this code? I have no idea, and I don’t care. But even though the
information is out there, the editors of this newsletter deemed it
inappropriate to publish the number in its entirety, thus the
shortened 09-f9-11-02-9d… version here.”

The thing that sounds suspicious to me how can one number be used to help break copy protection in HD DVD movies? Is this some sort of a back-door? Sony rootkit revisited? Or in the vein of Lord of the Rings; “One key to unlock them all”?

Older Posts »

Create a free website or blog at WordPress.com.