Wednesday, 31 October 2012

Beware the perils of Javascript

These two links are definitely worth a read I think...

http://oreilly.com/javascript/excerpts/javascript-good-parts/bad-parts.html

and especially…

http://oreilly.com/javascript/excerpts/javascript-good-parts/awful-parts.html

e.g.

Semicolon Insertion

JavaScript has a mechanism that tries to correct faulty programs by automatically inserting semicolons. Do not depend on this. It can mask more serious errors.

It sometimes inserts semicolons in places where they are not welcome. Consider the consequences of semicolon insertion on thereturn statement. If a return statement returns a value, that value expression must begin on the same line as the return:

return

{

status: true

};

This appears to return an object containing a status member. Unfortunately, semicolon insertion turns it into a statement that returns undefined. There is no warning that semicolon insertion caused the misinterpretation of the program. The problem can be avoided if the { is placed at the end of the previous line and not at the beginning of the next line:

return {

status: true

};

Tuesday, 30 October 2012

TSQL Performance Tuning

 

Below is an example of the TSQL you can use to investigate your stored procedure's performance. Best to put this in a snippet if you're using VS 2012 or greater versions of SQL Management Studio I find.

SET NOCOUNT ON

DBCC FREEPROCCACHE

DBCC DROPCLEANBUFFERS

CHECKPOINT

GO

PRINT ' '

PRINT '-- START: ProcName --------------------------------------------------------------------------------------------------------------------------------'

PRINT ' '

SET STATISTICS IO ON

SET STATISTICS TIME ON

EXEC dbo.MyProcNameHere

SET STATISTICS TIME OFF

SET STATISTICS IO OFF

PRINT ' '

PRINT '-- END: ProcName --------------------------------------------------------------------------------------------------------------------------------'

PRINT ' '

GO

Monday, 29 October 2012

Windows 8 - Keyboard Shortcuts

Those of you that know me, will know I'm pretty much obsessed with keyboard shortcuts. So imagine my delight when I came across this new list today whilst reading this review of Windows 8:

Windows logo key + start typing: Search your PC

Ctrl+plus (+) or Ctrl+minus (-): Zoom in or out of many items, like apps pinned to the Start screen or in the Store

Ctrl+scroll wheel: Zoom in or out of many items, like apps pinned to the Start screen or in the Store

Windows logo key + C: Open the charms

Windows logo key + F: Open the Search charm

Windows logo key +H: Open the Share charm

Windows logo key +I: Open the Settings charm

Windows logo key + K: Open the Devices charm

Windows logo key + O: Lock the screen orientation (portrait or landscape)

Windows logo key + Z: Open commands for the app

Windows logo key + PgUp: Move the Start screen and apps to the monitor on the right (apps in the desktop won’t change monitors)

Windows logo key + PgDn: Move the Start screen and apps to the monitor on the left (apps in the desktop won’t change monitors)

Windows logo key + Shift+period (.): Snap an app to the left

Windows logo key + period (.): Snap an app to the right

Monday, 22 October 2012

YSlow CSS inspector

Just installed the YSlow browser extension for Chrome (although versions are available for other browsers too!).

http://developer.yahoo.com/yslow/

Not bad for finding where things on your site can be improved…

image

image

Design patterns

Other than the usual gang of four articles, http://www.dofactory.com/Patterns/Patterns.aspx, today I chanced across this page whilst reading the asp.net mvc best practices wiki, which had some more sample code for design-patterns....

http://wiki.asp.net/page.aspx/276/design-patterns/

How to find the last interactive logons in Windows using PowerShell

Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...