Wednesday, March 25, 2009

DOS - Tips for DATE and WINZIP

1. For printing DATE in DOS, we use DATE. The format in which the DATE is displayed varies from profile to profile. If you want to change the format of the date, then go to Control Panel>Regional and Language Options. Go to Regional Options tab and click on the Customize button. Go to the Date tab and change the way you want your date to be displayed. You can also change the Date format using the Date separator in the same tab.
Now go to the command prompt and type DATE to get the date display in the format you desire. This is particularly useful when you want to create a file with DATE in its name. If you have '\' in your date, there would be an error.

2. To winzip a file using DOS, locate your Zip exe. Generally, it is in 'Program Files'. Use the following syntax to zip all the .txt files in the folder F:\test. In this example below, we desire a zip file with the name beginning with Ru appended with today's date. So, the name of the zip file created on 03-19-2009 should be:
RuThu 03-19-2009.zip.
Syntax:
"C:\Program Files\WinZip\WZZIP" "F:\test\RU%DATE%.ZIP" F:\test\*.txt

Friday, December 5, 2008

Splitting string with Delimiter in SQL

DECLARE @FullTask VARCHAR(100)
SET @FullTask = 'Task1-Task2'

If you know there would always be Task2, then the syntax for getting Task1 and Task2 is:
SELECT SUBSTRING(@FullTask, 1, CHARINDEX('-', @FullTask) - 1) AS [FirstTask],
SUBSTRING(@FullTask, CHARINDEX('-', @FullTask) + 1, LEN(@FullTask)) AS [LastTask]

If there is no LastTask, that is @FullTask='Task1' then getting LastTask would give error.

To avoid the above error, the query would be:
SELECT SUBSTRING(@FullTask, 1, NULLIF(CHARINDEX('-', @FullTask) - 1, -1)) AS [FirstTask],
SUBSTRING(@FullTask, CHARINDEX('-', @FullTask) + 1, LEN(@FullTask)) AS [LastTask]

This can be used for any delimiter, even if the delimiter is a space as ' ' instead of a hyphen as '-' in the above example.

Thursday, October 23, 2008

NOLOCK in SQL Server to improve performance

Sometimes it is good to use nolock in SQL Server queries, specially when your query is just reading the records. It does improve the performance of the system. The disadvantage is that one may not be sure that they are getting the data which is currently being updated in the Table i.e. Without lock protection, you cannot be guaranteed that the data isn’t changing during the time that the query is running.

The sytax for using NOLOCK is:

SELECT * from TblName
WITH (NOLOCK)
WHERE col1=col2

More reference on this:
http://blogs.neudesic.com/blogs/phil_scott/archive/2005/12/05/11.aspx

Force SQL Server to use index

If your table has too many indexes, then I figured out that it is better to force your SQL Server query to use the index which is made for that particular query.

To force the use of index,

SELECT *
FROM tablename WITH (INDEX = IDX_1234)
WHERE Column1 = 'value'

In this example IDX_1234 is the name of the Index.

Thursday, September 18, 2008

Filter IIS logging

IIS uses a flexible and efficient logging architecture. When a loggable event, usually an HTTP transaction, occurs, IIS calls the selected logging module, which then writes to one of the logs stored in %SystemRoot%\system32\Logfiles\.

Ref: http://msdn.microsoft.com/en-us/library/ms525410.aspx

In case you want your IIS to NOT log specific web requests, then you can run this script:

CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs CREATE W3SVC/1/ROOT/proj1/WhosHere.aspx IIsWebFile
CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\adsutil.vbs SET W3SVC/1/ROOT/proj1/WhosHere.aspx/DontLog 1

This should remove /proj1/WhosHere.aspx from ever being logged.

If you want IIS to log the page again, then you could replace the '1' with a '0' in the last line of the above script.

Wednesday, September 17, 2008

The Science of PERSUASION

The Science of PERSUASION - how to make the other person feel as if you are just like him/her. Here is how it works:

1. The Principle of Liking: People like those who like them - Uncover your real similarities with people and offer genuine praise
A. Similarity
B. Praise

2. The Principle of Reciprocity: Give what you want to receive – People repay in kind. Smile at someone and he smiles back! Give small gifts to everyone – that makes the other person oblidged.

3. The Principle of Social Proof: People follow the lead of similar others - Use peer power whenever it’s available. Taking testimonials from a similar and already satisfied customer and presenting it to another similar customer helps. Influence is often best exerted horizontally rather than vertically.

4. The Principle of Consistency: People align with their clear commitments - Make their commitments active, public, and voluntary. People should feel committed to what you want them to do. Some people stick to what they commit. Get things in written – Example, if someone commits to a date, ask him to email a memo summarizing things. AND written statements become more powerful when they are made public.

5. The Principle of Authority: People defer to experts – Expose your expertise; don’t assume it’s self-evident. Go to get-togethers to make such discussions which reveal your expertise from your mouth easier – not in a boastful way though.

6. The Principle of Scarcity: People want more of what they can have less of – Highlight unique benefits and exclusive information. Use ‘Loss language’ which says b) works better than a). a) If you do this, then you get this. b) If you do not do this, then you lose all of this. Also, exclusive information is better than widely available data. Eg: This is persuasive: “ I just got this report today. It wont be distributed until next week, but I want to give you an earl look at what it shows” and watch how your listeners lean forward! But remember, not to deceive anyone in this.

Use these 6 principles in combination.

REF: Harnessing the Science of Persuasion by Robert B. Cialdini
- Harvard Business Review Article
Pub. Date: October 01, 2001

Thursday, September 4, 2008

Why use .js file for javascript?

Advantages of writing javascript code in .js file over writing the same in .aspx file under the javascript tags:

1. The code in the .js file can be re-used by different aspx and aspx.cs pages.

2. Once the application using the code is run on the client machine, the .js file sits in the cache of the client and keeps working from there - which could be something useful, specially for cases where you might want to display clock on the web page without a postback; or check network connection constantly on web page and disable the web page buttons in case there is a disconnected network instead of HTTP error messages.

3. This cache re-usage would also speed up the page loading and users of your site would also experience faster page loads.

4. Also, you can hide your javascript code from the users in this way. Users cannot see the javascript code in the .js file when they do 'View Source' on the web page.

About Us