Friday, July 30, 2010

DotNetZip - Zip and Unzip in C#, VB, any .NET language

DotNetZip is an easy-to-use, FAST, FREE class library and toolset for manipulating zip files or folders. Zip and Unzip is easy: with DotNetZip, .NET applications written in VB, C# - any .NET language - can easily create, read, extract, or update zip files. For Mono or MS .NET.

You can find more information at codeplex. Download from here.

Thursday, July 29, 2010

How to: Javascript Loading Conditionally for IE

Loading Javascript conditionally for IE. When rendering fixes are needed for IE, you can enclose CSS, JavaScript, or HTML markup in conditional comment tags directed at one or more versions of IE with an "if" statement; IE will then execute the code specified within them, while all other browsers treat them as standard comment tags and ignore them. The "if" statement must reference IE in square brackets as shown below; in this example include script only for IE

<!--[if IE]>
    <script type="text/javascript">
        /*  Do Stuff */
    </script>
<![endif]-->
below example shows how to exclude a script block from IE:
<![if !IE]>
    <script type="text/javascript">
        /*  Do Stuff */
    </script>
<![endif]>
Conditional comments can also be targeted to a particular version of IE, or a subset of versions, like those released prior to IE7 or IE6
<!--[if lt IE 7]>
  <link rel="stylesheet" type="text/css" href="ie_fixes.css" />
<![endif]-->

Hope this helps!

Tuesday, July 27, 2010

How to: Remove empty lines in text using Visual Studio.

Visual Studio has ability to delete empty lines in replace operation using regular expressions.
1.Click Ctrl-H (quick replace)
2. Tick "Use Regular Expressions"
3. In Find specify ^$\n
4. In Replace box delete everything.
5 Click "Replace All".

All empty lines will be deleted.

Regular expression for empty line consist of 

Beginning of line ^
End of line $
Line break \n

Monday, July 26, 2010

Keystroke Function

WIN - Opens the Start Menu

WIN + E - Opens My Computer in Windows Explorer

WIN + Pause/Break - Opens the System Properties dialog box

WIN + U - Opens the Utility Manager

WIN + R - Opens the Run box

WIN + F - Opens the Search for Files and Folder window

WIN + M - Minimizes all Windows

WIN + L - Lock Computer

WIN + B - Selects the first item in the System.Use arrow keys to navigate.

Alt + Tab - Switch between open programs.

Alt + Enter - Opens the Properties page of a selected item

Shift + Delete - Permanently deletes and item
Ctrl + Shift + Esc - Opens the Windows Task Manager

PrntScn - Takes a screenshot of the entire screen, saves it on the clipboard

Alt + PrntScn - Takes a screenshot of the active  windows

F1 - Opens the Windows XP

F2 - Help = Rename selected item

F3 - Search

F5 - Refresh Internet Explorer page

Ctrl + A - Select All

Ctrl + C - Copy

Ctrl + X - Cut

Ctrl + V - Paste

Ctrl + P - Print

Ctrl + O - Open

Ctrl + Backspace - Deletes the entire word to the left

Ctrl + Delete - Deletes the entire word to the right

Ctrl + Right arrow - Moves the cursor to the beginning of the next word

Ctrl + Left arrow - Moves the cursor to the beginning of the previous word

Ctrl + Down arrow - Moves the cursor to the beginning of the next paragraph

Ctrl + Up arrow - Moves the cursor to the beginning of the previous paragraph

Click Shift 5 times - Turns StickyKeys on or off

Thursday, July 22, 2010

Understanding VARCHAR(MAX) in SQL Server 2005

In SQL Server 2000 and SQL Server 7, a row cannot exceed 8000 bytes in size. This means that a VARBINARY column can only store 8000 bytes (assuming it is the only column in a table), a VARCHAR column can store up to 8000 characters and an NVARCHAR column can store up to 4000 characters (2 bytes per unicode character). This limitation stems from the 8 KB internal page size SQL Server uses to save data to disk.

To store more data in a single column, you needed to use the TEXT, NTEXT, or IMAGE data types (BLOBs) which are stored in a collection of 8 KB data pages that are separate from the data pages that store the other data in the same table. These data pages are arranged in a B-tree structure. BLOBs are hard to work with and manipulate. They cannot be used as variables in a procedure or a function and they cannot be used inside string functions such as REPLACE, CHARINDEX or SUBSTRING. In most cases, you have to use READTEXT, WRITETEXT, and UPDATETEXT commands to manipulate BLOBs.
To solve this problem, Microsoft introduced the VARCHAR(MAX),  NVARCHAR(MAX), and VARBINARY(MAX) data types in SQL Server 2005. These data types can hold the same amount of data BLOBs can hold (2 GB) and they are stored in the same type of data pages used for other data types. When data in a MAX data type exceeds 8 KB, an over-flow page is used. SQL Server 2005 automatically assigns an over-flow indicator to the page and knows how to manipulate data rows the same way it manipulates other data types. You can declare variables of MAX data types inside a stored procedure or function and even pass them as variables. You can also use them inside string functions.

Microsoft recommend using MAX data types instead of BLOBs in SQL Server 2005. In fact, BLOBs are being deprecated in future releases of SQL Server.