Bug Vanquisher

28 October 2009

How Not To Blog

Filed under: S&G — Tanveer Badar @ 11:07 PM

Beginning your post with something like

Whenever I pick up a new technology I must admit that I feel kind of stupid, like a dummy or a complete idiot.

sends the wrong message to your readers in my books. You are implying that they are inherently stupid, imbeciles and morons. And your unearthly piece of work is too complex for mere mortals to understand.

Here’s a tip, get a life and get off your high horse people. No one wants to be like you. You may be an idiot, we are not. We like our own wits, thank you very much.

Advertisements

28 September 2009

Solution to XmlTextReader’s Fiasco

Filed under: Fun, Tips — Tanveer Badar @ 10:22 PM

He’s not that knowledgeable. Mr. pretentious. And he didn’t try this either:

”, hexadecimal value 0x1B, is an invalid character. Line 46, position 128.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Xml.XmlException: ”, hexadecimal value 0x1B, is an invalid character. Line 46, position 128.

The simple solution is to set CheckCharacters = false; And since you would like to know what the heck am I talking about? XmlTextReader is in the bad habit of failing over Unicode characters.

23 September 2009

Amazing Trace

Filed under: Funnier — Tanveer Badar @ 11:33 PM

3    39 ms    34 ms    42 ms  203.99.170.110
4    42 ms    42 ms    42 ms  221.120.251.9
5    41 ms    42 ms    42 ms  202.125.128.131
6    43 ms    42 ms    41 ms  221.120.250.254
7   174 ms   179 ms   178 ms  166.49.170.17
8   184 ms   178 ms   179 ms  166.49.135.139
9   175 ms   179 ms   178 ms  166.49.208.125
10   269 ms   272 ms   264 ms  166.49.164.65
11   414 ms   417 ms   418 ms  206.223.115.17
12   415 ms   408 ms   409 ms  209.240.199.162
13   422 ms   426 ms   434 ms  207.46.43.3
14   419 ms   417 ms   418 ms  207.46.43.39
15   432 ms   434 ms   443 ms  207.46.43.117
16   441 ms   443 ms   443 ms  207.46.43.184
17   439 ms   435 ms   434 ms  207.46.43.172
18   438 ms   435 ms   434 ms  10.22.8.50

Have you ever seen 10.x.y.z appearing on tracert output before?

16 September 2009

The Off-by-1 Game

Filed under: Bugz, S&G, Tips — Tanveer Badar @ 7:54 PM

Consider this:

for( int i = list.Count – 1 ; i >= list.Count – 50 ; –i , )
.     array [ i ] = list [ i ];

Intention was the get the last 50 terms from list. Ignoring the facts that it will throw a null reference exception if the list is null and an index-out-of-range exception if it contains no elements it also fails to copy all 50 elements. The condition is to be blamed.

Correct way is not to invent your own logic and use what the framework offers.

if( list != null && list.Count > 50 )
    list.RemoveRange( 50 , list.Count – 50 );

For added bonus, consider this paging code.

for( int i = 0 , index = 0 ; i < some_huge_number ; ++i )
{
    page.Results.Add( results [ i ] );
    if( index == 10 )
    {
        pages.Add( page );
        page = new Page( );
        index = 0;
    }
    ++index;
}

This code strives to divide results into pages each with 10 results. Can you imagine what this will do if there were only 9 results?

It will proceed to add those results to page, then, do nothing. Because of the incorrect if condition. Again, the correct way is divide-and-remainder approach as demonstrated here.

24 April 2009

Tales From Interviewer’s Desk

Filed under: Dev inside!, Fun, Tips — Tanveer Badar @ 8:24 PM

Part 1:

How to reverse a string in-place?

Take 1: (Fresh)

string reverse( string str )
{
    char ch = str [ 0 ];
    foreach( int i = 0 ; i < str.length ; ++i )
        Response.RedirectWrite( str [ str.length – i ] ) + ch.tostring( );
}

Take 2: (Big words, no knowledge)

string reverse( object obj )
{
    string str = TypeCaste.tostring( obj );
    stack< ch > s;
    for( int i = 0 ; i < length ; ++i )
        s.push( str.charat( i ) );
    for( i = 0 ; i < length ; ++i )
        str.insertat( 0 , s.pop( ) );
}

Take 3: (2.5  year experience in C#)

string reverse( object obj )
{
    if( typeof( obj ) == "string" )
    {
        for( int i = 0 ; i < obj.length ; ++I )
        {
            char ch = str [ i ];
            str [ i ] = str [ length – i ];
            str [ length – i ] = ch;
        }
    }
    return obj.tostring( );
}

Take 4: (Fresh)

string reverse( object obj )
{
    if( obj == "string" )
    {
        char ch = str [ 0 ];
        for( int i = 0 ; i < obj.length ; ++I )
            str [ i ] = str [ length – i ];
        str [ str.length ] = ch;
    }
}

5 April 2009

Enough!

Filed under: Intelligence :( ?? — Tanveer Badar @ 2:45 PM

Facebook is becoming an information disclosure nightmare. People are too stupid to be handed a public social network for their own good. For example, this just crossed my ridiculously crafted homepage few minutes ago.

"Muhammad just added the birthdays of 15 friends to their MyCalendar.
Muhammad has requested to add the following birthdays to their MyCalendar:"

[more blah blah blah with actual dates]“

My comment:

Tanveer Badar at 14:31 on 05 April
[noun], you should know better. It is information disclosure, and about other people’s personal information you have no right to publish in public.
Please don’t add mine to this application.

What amuses me is that the guy is supposed to be specializing in networking, and security by implication (I think). I shudder to think whose data rests in the hands of such and likes.

Those who take time to read this blog might have noticed there is very little information about me here. You won’t find much about me online because I don’t want you to. But how are you supposed to prevent others leaking information about you online.

4 March 2009

Yawn

Filed under: S&G — Tanveer Badar @ 10:51 PM

.

2 February 2009

From The Forgotten Mail

Filed under: Funnier — Tanveer Badar @ 10:27 PM
Muhammad Usman Ghani

to me, Raza, Faisal, Mehroz

Reply

2026: Microsoft manages to do the impossible by cloning Tanveer Badar
thus paving the path for its own demise.

Tanveer Badar

to Muhammad, Raza, Faisal, Mehroz

Reply

Such modesty. You should have said:
Beginning in the summer of 2019, Microsoft sponsors a project that seeks to unravel the enigma underlying the phenomenon of "The Tanveer Badar" syndrome. For the next two years, they make little progress as the disease symptoms elude them, much like the old world AIDS (Remember, we have colonized far away galaxies. This experiment is being carried on in an alternate reality.). Then, suddenly, in year 2024, they recognize the signs and relate it to an anomaly which happened on 3rd June, 1984. After that, within the next 2 years they achieve the near impossible, a working clone of Usman Ghani who wreaks havoc resulting int he ultimate destruction of human race.

20 January 2009

The Definition

Filed under: Intelligence :( ?? — Tanveer Badar @ 12:07 AM

"Terrorism," the professor had lectured, "has a singular goal. What is it?"
"Killing innocent people?"
"Incorrect. Death is only a byproduct of terrorism."
"A show of strength?"
"No. A weaker persuasion does not exist."
"To cause terror?"

"Concisely put. Quite simply, the goal of terrorism is to create terror and fear. Fear undermines faith in the establishment. It weakens the enemy from within . . . causing unrest in the masses. Write this down. Terrorism is not an expression of rage. Terrorism is a political weapon. Remove a government’s faзade of infallibility, and you remove its people’s faith."

19 January 2009

General Public Notice

Filed under: S&G — Tanveer Badar @ 12:55 AM

I do not entertain business calls after office hours.

Older Posts »

Create a free website or blog at WordPress.com.