Deleting Data in SQL Server with TRUNCATE vs DELETE commands

TRUNCATE TABLE is a statement that quickly deletes all records in a table by deallocating the data pages used by the table. This reduces the resource overhead of logging the deletions, as well as the number of locks acquired; however, it bypasses the transaction log, and the only record of the truncation in the transaction logs is the page deallocation. Records removed by the TRUNCATE TABLE statement cannot be restored. You cannot specify a WHERE clause in a TRUNCATE TABLE statement, it is all or nothing. The advantage to using TRUNCATE TABLE is that in addition to removing all rows from the table it resets the IDENTITY back to the SEED, and the deallocated pages are returned to the system for use in other areas.

In addition, TRUNCATE TABLE statements cannot be used for tables involved in replication or log shipping, since both depend on the transaction log to keep remote databases consistent.

TRUNCATE TABLE cannot used when a foreign key references the table to be truncated, since TRUNCATE statements do not fire triggers. This could result in inconsistent data because ON DELETE/UPDATE triggers would not fire. If all table rows need to be deleted and there is a foreign key referencing the table, you must drop the foreign key and then recreate it.

Source: Deleting Data in SQL Server with TRUNCATE vs DELETE commands

Simple tool for analyzing IIS logs

The IIS server logs looks something like this:

#Software: Microsoft Internet Information Services 8.0
 #Version: 1.0
 #Date: 2016-04-19 00:47:15
 #Fields: date time s-sitename s-computername s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs-version cs(User-Agent) cs(Cookie) cs(Referer) cs-host sc-status sc-substatus sc-win32-status sc-bytes cs-bytes time-taken

This simple to use tool parses those logfiles and creates a html file that opens in the web browser and presents the data in a nice simple way complete with graphs.

Download “WebLog Expert Lite” for free.

Source: WebLog Expert Download

Setting custom background color on a web page in Chrome

“Care your eyes” – extension for Chrome:

Change a webpage’s background color to reseda or night mode to protect your eyes from intensity of white or other lightness color.

https://chrome.google.com/webstore/detail/care-your-eyes/fidmpnedniahpnkeomejhnepmbdamlhl

 

“Deluminate” – extension for Chrome:

Invert the brightness of the web without changing the colors! Useful as a night mode to darken most bright web sites (like Google), or just for making the web soothing black instead of glaring white. Similar to the “High Contrast” or “Hacker Vision” extensions, but tries not to ruin images by blowing out the contrast or changing the colors.

https://chrome.google.com/webstore/detail/deluminate/iebboopaeangfpceklajfohhbpkkfiaa

Using jQuery to prevent Internet Explorer from accidentally submitting form on enter key

$(function () {
    //page is ready
	
	
		//Prevents users from accidentally submitting form with enter key (e.g. IE problem) 
	    //http://stackoverflow.com/questions/895171/prevent-users-from-submitting-form-by-hitting-enter
	    $(document).on("keyup keypress", "form input[type='text']", function (e) {
	        if (e.keyCode === 13 /*enterkey*/ || event.keyCode === 169 /*enter on numpad*/) {
	            e.preventDefault();
	            return false;
	        }
	    });
	
});

Works in ajax templated context as well.

Create Bookmarklets – The Right Way – Tuts+ Code Tutorial

Bookmarkets can be defined as mini applications masquerading as tiny snippets of JavaScript awesomeness that reside in your browser and provide additional functionalities to a web page.

Today, we’re going to look into creating bookmarklets from scratch and on the way, some best practices to follow.”

via Create Bookmarklets – The Right Way – Tuts+ Code Tutorial.