Bug Vanquisher

8 December 2007

BigInt For .Net Framework

Filed under: Dev inside!, Tips — Tanveer Badar @ 11:43 PM

Is it there or is not?

The answer was true for beta 1 build of netfx 3.5. It is true if you can manage to run under full trust for beta2 and RTM versions, because then, you can use reflection to create an instance of BigInteger and invoke members.


This value type supports +, -, –, ++, /, ==, >=, >, !=, <, <=, %, *, -, + as supported arithmetic operators.

For functions, it has Abs, Add, Compare, CompareTo (overloaded), Divide, DivRem, GreatestCommonDivisor, ModPow, Multiply, Negate, Parse (overloaded), Pow, Remainder, Subtract, ToByteArray (overloaded), ToString (overloaded) and TryParse (overloaded) to offer. Note, Add, Divide, Multiply, Negate, Remainder and Subtract actually implement functionality for corresponding operators.

There are also a host of convert-from and convert-to operators, performing conversions to and from all built-in numeric data types.

24 October 2007

A Second Without Download Is The Second Most Wasted!

Filed under: Fun, Tips — Tanveer Badar @ 8:01 PM

Installing VS 2008 Beta 2

Filed under: Tips — Tanveer Badar @ 12:15 AM

Here are some tips for installing VS 2008 Beta 2.

  • Stop any search indexing services before you begin, that means any desktop search engine you may have (Google desktop search, Windows Search for Windows XP, Windows Search in Windows Vista, etc.).
  • Verify that you are installing from a trusted source and turn off any anti virus/anti spyware programs you have. (This means all sorts of anti virus programs, Windows Defender if you have is installed on Windows XP or in Windows Vista, Windows LIve OneCare’s AntiSpyware/Antivirus service, etc.)
  • Specifically, for Windows Vista before commencing the installation, install updates for .net framework 3.0 manually and make sure there are no pending restart requirements. And after installing those updates restart manually so that TrustedInstaller does not hog your system for long periods of time. Although the restart is inevitable, but doing things prematurely can save time, at least empirically.
  • Do not attempt installation on any thing less than IGB.
  • Do not attempt to run devenv.exe for large projects on any thing less than 2 GB, because performance sucks even on Windows XP where ambient memory requirements are pretty low as compared to Windows Vista.

16 October 2007


Filed under: Tips — Tanveer Badar @ 2:32 AM

Never ever use vptcl to upload anything. It takes forever, runs < 4 KB, hampers download speed and you can get married and have two kids before anything decent in size will finish uploading.

11 October 2007

How T9 Mode Works?

Filed under: Tips — Tanveer Badar @ 9:49 PM

I got this search string logged today ‘DRAW HEURISTICS FOR T9 DICTIONARY SEARCH’. Must be related to this post.

The algorithm to suggest words in T9 mode is very simple. All you need is a dictionary which stores the number sequence of keys pressed. For example, pressing 4663 can give you these six words: good, home. gone, hood, hoof, hone. The way it should work is to:
1- Store the currently typed number
2- Use it as the key to index the dictionary and get the list of all possible words that can be formed by that number sequence.
3- When the action key is pressed, cycle through that list. Start over.

Let’s say you want to simulate the functionality in a C++ application, here is now you would proceed.

// This code is utterly buggy, entirely untested, written out of the top of my head, in 10 minutes, using notepad, never seen a compiler in its life, some syntax may even be only valid in C# as my exposure to C++ these days is very limited. Use with your own responsibility.

#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

map< string , vector< string > > get_data( );

class T9
    vector< wstring > current_list;
    map< string , vector< wstring > > t9_dictionary;
    int index;

    void reset_list( )
        if( t9_dictionary.size( ) )
            current_list = t9_dictionary.begin( ).first;
    T9( )
        : t9_dictionary( get_data( ) )
        reset_list( );

    void add_word( const wstring& word )
        if( find( current_list.begin( ) , current_list.end( ) , word ) == current_list.end( ) )
            current_list.push_back( word );

    void update_list( const string& current_number )
        if( t9_dictionary.find( current_number ) == t9_dictionary.end( ) )
            t9_dictionary [ current_number ] = vector< wstring >( );
        current_list = t9_dictionary [ current_number ];

    wstring& get_next_word( )
        if( index < current_list.size( ) )
            return current_list [ size ];
            index = 0;
        if( current_list.size( ) )
            return current_list [ index ];
        return L””;

2 June 2007

Run applications during Windows Vista (onwards) setup

Filed under: Fun, Tips, Windows Vista — Tanveer Badar @ 1:52 AM

It’s been a tip season and I am longing to tell you this piece of information for ages!

You can run light weight applications during Windows Vista setup and even things like explorer after the second reboot.

This magic works because Vista’s setup runs in a mini Windows installation called Windows PE-Windows Pre execution Environment. This is a full blown Windows environment that exposes just enough facilities to give you a 32/64-bit GDI based GUI. I tried to take a picture to show you how to do but save/save as in paint didn’t work. Due to COM registration issue in that part of setup, showdocvw.dll was not registered at that point and explorer gave an error (refused to lanuch) and there was no way to save the snap-shot. However, after the second reboot, I was able to run things like cmd.exe, taskmgr.exe, explorer.exe and devmgmt.msc and GOD devmgmt.msc showed devices installing in real time.

The trick to do stuff like this starts with getting a hold of command prompt which can be run by pressing SHIFT+F10 keys. Now, this step is document and recommended only if you ‘really‘ need to have access to a command prompt. I went ahead to tried to run things from that command prompt and most worked. Next you have a choice to run an application of your choice from the command line. Remember that application should not rely on things like COM registration or OLE automation. These things are not initialized properly during that stage of setup.

1 June 2007

An excellent article on dependency properties

Filed under: Tips, WPF — Tanveer Badar @ 5:44 PM

Right from the bowls of WPF SDK team. A superb two article post on dependency properties.

Wha’ happened? Property-changed detection mechanisms in WPF (Part One)

Wha’ Happened Part Two: More Property Changes in WPF

[Edit: A reader rightfully pointed out the mistake I had made thinking these articles were about animations, however, they are about dependency properties and only indirectly about animations because dependency properties can be animated.]

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.

16 March 2007

The way to TLS in CLR

Filed under: Tips — Tanveer Badar @ 7:14 PM

I dug up something about TLS access methods in CLR. Don’t use Thread class’s accessor methods, instead apply ThreadStatic attribute because it takes app-domain, even processor level locks. Read yourself.

14 February 2007

It’s a must have!

Filed under: Tips — Tanveer Badar @ 8:29 PM

It’s a must have!

To die for!

I have been waiting all my life for someone like you!

What more can I say for such a wonderful product, go and see yourself. An assortment of visual tools, one of which allows you to edit .proj, .csproj and .vbproj files in a visual editor. Or you can directly go to the download.

« Newer PostsOlder Posts »

Create a free website or blog at WordPress.com.