Thursday, April 29, 2010

Process Explorer

Ever wondering if Task Manager for windows is enough.When I was developing some system services or dll packs, it is always a problem monitoring them in the windows system. Process Explore is a really useful tool to make the dirty background jobs apparent.

http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
http://sourceforge.net/apps/mediawiki/procexp/index.php?title=Main_Page

Diff and Merge for Windows

I am not aware of such an elegant tool until recently. I was always reluctant to use KDiff 'cause it is always make me confused.

Check out WinMerge.
http://winmerge.org/

Wednesday, April 21, 2010

Programming Jokes

Two bytes meet.  The first byte asks, “Are you ill?”  
The second byte replies, “No, just feeling a bit off.”


~~~~~~~~~~~~~~~~~~~~~~~~~
How many programmers dose it take to change a light bulb?
None – It’s a hardware problem
~~~~~~~~~~~~~~~~~~~~~~~~~
Why do programmers always mix up Halloween and Christmas? 
Because Oct 31 equals Dec 25.
~~~~~~~~~~~~~~~~~~~~~~~~~
“Knock, knock.”
“Who’s there?”
very long pause….
“Java.”
~~~~~~~~~~~~~~~~~~~~~~~~~ 
Programming is like sex:
One mistake and you have to support it for the rest of your life.
~~~~~~~~~~~~~~~~~~~~~~~~~
A man is smoking a cigarette and blowing smoke rings into the air.  His girlfriend becomes irritated with the smoke and says, “Can’t you see the warning on the cigarette pack?  Smoking is hazardous to your health!” 
To which the man replies, “I am a programmer.  We don’t worry about warnings; we only worry about errors.”
~~~~~~~~~~~~~~~~~~~~~~~~~
Have you heard about the new Cray super computer?  It’s so fast, it executes an infinite loop in 6 seconds.
~~~~~~~~~~~~~~~~~~~~~~~~~
The generation of random numbers is too important to be left to chance
~~~~~~~~~~~~~~~~~~~~~~~~~
Two strings walk into a bar and sit down. The bartender says, “So what’ll it be?”
The first string says, “I think I’ll have a beer quag fulk boorg jdk^CjfdLk jk3s d#f67howe%^U r89nvy~~owmc63^Dz x.xvcu”
“Please excuse my friend,” the second string says, “He isn’t null-terminated.”
Comic

Monday, April 19, 2010

Freezing GridView header. EP3

Finally, there is something works as I desired. (My desire is minimal amount of work, and maximal achievement).

http://johnsobrepena.blogspot.com/2009/09/extending-aspnet-gridview-for-fixed.html

A better explained mechanism can be found here.
http://www.developer.com/lang/jscript/article.php/10939_3696921_4/A-Better-Fixed-GridView-Header-for-ASPNET.htm

Freezing GridView header. EP2

This is a hack: separate the header (as a fixed table) and the data (in a header-less gridview).
The problem is, it is difficult to align the columns, not mentioning that you could not dynamically generate the table as in autogenerate mode.

http://www.aspsnippets.com/Articles/Scrollable-GridView-with-Fixed-Headers-in-ASP.Net.aspx

Freezing GridView header. EP1

Use style sheet only -- put the gridview in a div or a panel that with the container style below. The problem is, it only works for IE. Worst, it may not work correctly in new version of IE. Somehow, it works for most of DataGrid control, as DataGrid is older than GridView.

http://mattberseth.com/blog/2007/09/freezing_gridview_column_heade_1.html


(note: overflow-x or overflow-y are not standard CSS properties. Therefore, MS has their own version of the properties for IE, e.g. -ms-overflow-x:scroll; -ms-overflow-y:scroll)

   

Thursday, April 8, 2010

Online Shopping

Yesterday, tried shopping on taobao. It sucks.

I had tried millions of times to shop online. Basically, find what I want, fill some delivery details, put a credit card number, submit and done. With taobao, it is a pain.
Finding what I want -- the pictures are usually so fake and so pretty while the price is so cheap, made me wonder if it is trustworthy.
Paying my purchase -- in most cases, credit card or cash-on-delivery is not an option. Options are online banking or something similar to bill-pay. Since I couldn't get myself to a convenient store or a post office to pay the bill, I have to try online banking. Most banks have basic online banking service ... charged; and advanced services at some expensive cost. When you want to pay somebody online, if you are lucky that they have an agreement with your bank to cooperate online business, you need to first install some software for that particular bank, then with your national ID number, username, password, passphrase card, and authorization code, you may be able to purchase anything under your payment limit. It takes more than three steps to pay my money! I don't feel protected, I felt totally pissed.

Overall, in China you as a buyer are not trusted; and in the same league, you don't want to trust anybody. Life is difficult for both parties. What a hell.

Wednesday, April 7, 2010

Change web page layout dyanmicaly

For an ASP.NET website, there are two things defining the page layout: masterpage and theme. They can be specified in the page header. For example, 

<%@ Page Title="A Web Page" Theme = "CoolTheme" Language="C#" MasterPageFile="~/SuperMasterPage.master" AutoEventWireup="true" CodeBehind="ExamplePage.aspx.cs" Inherits="WebGUI. ExamplePage" %>

This is static setting of the page layout. The masterpage used is SuperMasterPage.master and the theme is CoolTheme (probably defined in the App_Themes folder by default).
To dynamically/programmatically set them, we shall call upon the Page_PreInit procedure. Notice the order of procedures to be called when loading a page – Page_PreInit takes place before Page_Load. It is the only proper place to declare your masterpage and theme.
In the following example, we set a different masterpage and a different theme for a particular user called “joseph”.

In C#
protected void Page_PreInit(object sender, EventArgs e)
    {
        if (User.Identity.Name == "joseph")
      {
            this.MasterPageFile = "~/NewMasterPage.master";
            this.Theme = "NewTheme";
        }
    }
In VB

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit

 
        If User.Identity.Name.Equals("joseph") Then

            Me.Page.MasterPageFile = "~/NewMasterPage.master"
            Me.Page.Theme = "NewTheme"

        End If
 

    End Sub

Tuesday, April 6, 2010

Fixed an Access bug several months later

As title. Here is the story:
Several months ago, I was asked to inspect a weird bug in MS Access. In the beginning, no one knew what went wrong; just the Access crashed when genenerating a weekly staff-project report. Then I figured out that when a staff called "Brian Ye" was included in the summary report, the report generator crashes. Once again, debugging with VBA was not pleasant. In the end, even after I got some one to help, none of us could figure out what went wrong after a couple of hours. Luckily, "Brian" was just an intern. When he left, problem's solved.

Today, the reporting bit crashed again. This time, it took me only 10 minutes to locate the problem which explains the problem before. Thanks to the induction method.  So today it was about reporting with a staff called "Alan Shaw". See the problem? Probably too difficult, 'cause I haven't mentioned that the Access report uses their initials for its header. So the initials for them are "AS" and "BY" -- yes, they are SQL keywords. That's the problem.

(I twisted the names of the above-mentioned staff slightly.)