Sunday, August 26, 2007

Substitute Control

.Net 2.0 has come with bunch of new controls. Many of the controls looks like composite control of existing 1.1 control or enhanced 1.1 controls - basically after studying the market or taking look at the open source framework etc.

Substitute control is one of the new control in the stack. As we all know, the caching has been very significant concept in the web. Caching itself is a very broad topic. Caching can be done at various level - like browser side, proxy caching, server caching, database caching, kernal caching, page caching, control caching,application level, etc.

It is possible to cache page content using output cache directive. So in such case if you want a portion of the site not to come from cache but be processed all the time, then Substitute control is handy.

Friday, August 24, 2007

NGen Optimization

We all know ::: > .Net Languages > Compiled > MSIL > Compiled to Native machine code (JIT)

Ngen is an utility from Microsoft that let you precompile the MSIL code for the native platform code. This way the JIT processing is by passed and code performance quicker. But always this may not be right.

There are couple of things - one is code compilation to native code and other one compiling and code optimization. JIT is smarter than just the compilation portion. JIT does lots of runtime optimization depending upon the memory, CPU architecture, etc. Basically, JIT adjust itself to the current runtime. So before we jump and start believe that NGen is going to benefit us, it is better we do our home work.

Friday, August 10, 2007

Drupal set up - see it running!

I have not worked with PHP before nor Drupal.

But there was project running in my company in Drupal. I have been hearing about this project a lot and it was so interesting for me to listen to their work like running Apache, PHP and MySQL.

Excitement is the platform. For last few years, I have been completely in to Microsoft platform, this open source stack really excited me. Before I was working in MS platform, I had oppurtunity to work in Java, PostGreSQL and other non-MS stuff and so thought would try once again.

I have tried to briefly describe about how to set up drupal quickly.

Setting up Drupal: (All these links may go invalid later, but visit each of their site, it is easy to find the download)
1. Download drupal
2. Download PHP, say 5:
3. Download Apache
4. Download MySQL. Download "mysql-essential"

Step1: Install Apache.
Pretty straight forward, the wizard will guide you. You can register Apache as windows service. Command to register Apache as service
"httpd.exe -k install -n "

Edit httpd.conf: Configure the default document.

DirectoryIndex index.html
DirectoryIndex index.php

Step2: Install MySQL.
Pretty straight forward as well. Follow the Wizard.

Step3: Install PHP
Extract PHP zip to a convenient location, say c:\php. Add c:\php to PATH variable. Hook php to Apache. Edit httpd.conf and add these lines
#PHP Configuration#Begin
# For PHP 5 do something like this:

LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini

PHPIniDir "C:/php"
#End PHP Configuration

Step4: Configure PHP to use MySQL
If you are using PHP 5+, MySQL is not enabled by default. To enable SQL, edit php.ini. First modify the extension directory and set to
extension_dir = "c:\php\ext"
Enable the Mysqli extension

Step5: Creating database for drupal and make note of the database, username and password

Step6: Extract the drupal download to somewhere under Apache installation. Edit the httpd.conf of apache to point to the drupal directory. Eg.
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/drupal"

Make sure MySQL is running and Apache is running as well.

Now it is time to install the drupal. Type http://localhost:8080/ (*Assuming apache running at 8080). This should show you the Database configuration page. Enter the database, username and password, rest is taken care. It creates default tables and data and finally shows up the drupal administration page. Wow!!! I may not be totally correct. But this is what I did and it worked :). There is guy who has gone deep in to drupal, I shall discuss with him and put more info here.

SPOIL yourself!

SPOIL = Stored Procedure Object Interface Layer.

There has been many attempt by Microsoft and others to reduce the work of the developer and emphasis the concept of Rapid Application Development. I guess the intention is lesser you let the developer to code, lesser is the bug count.

SPOIL helps us to build a object oriented layer over database. Idea is that developer might never have to write ADO.Net to interact with their database. Say the stored procedure will become a object and will be strongly .net typed, thus reducing the coding effort and runtime errors. So, application would setting the values of the SP by properties.

Without SPOIL, it would be like shifting from the OO paradigm to functional, to call the SP and handle the output. It would involve writing length and error prone code.

But this did not really catch the attention of industry.

Enable default document in Apache!

This is simple stuff to write and do but when you start something new, it is always interesting. In IIS, we can enable default document. This would mean if someone hit the url like http://localhost/test/sample/ without specifying the actual page they are shooting at, the IIS must be able to return a default page. So you can configure that easily in IIS using Inet Manager.

To do the equivalent in Apache it is, we need to add the below line in the httpd.conf

## DirectoryIndex: sets the file that Apache will serve if a directory# is requested.


DirectoryIndex index.html

DirectoryIndex index.php

Thursday, August 09, 2007

Kill the beep!!

I was working with MySQL other day in my laptop. Whenever I make a mistake with query I get a beep sound which is pretty loud. So, instead of learning the correct syntax, I was thinking if I can stop this annoying noise.

This beep sound is created by ASCII BELL (character 7). To kill the the beep do a 'net stop beep' at the command line in Windows. :)