2014-01-11

MySQL - Trim carriage returns (or any characters)

In the following formula '\n' represents a carriage return. You may also want to use '\r' or a combination of both, depending on the type of carriage return (unix/windows).

trim( BOTH '\n' from `FIELD_NAME` )


2014-01-08

TSQL - How to suspend indices/indexes (disable and rebuild)

Disable:
ALTER INDEX [INDEX_NAME] ON [SCHEMA_NAME].[TABLE_NAME] DISABLE;

Enable (recreate):
ALTER INDEX [INDEX_NAME] ON [SCHEMA_NAME].[TABLE_NAME] REBUILD;


Alternate source:
http://blog.sqlauthority.com/2007/05/17/sql-server-disable-index-enable-index-alter-index/

2014-01-02

Javascript - String global replacements

var value = "asdf asdf";
value = value.replace(/a/g,"@"); 
console.log('value: [' + value + ']' );



This statement would only replace the first instance found:
value = value.replace("a", "@");

2014-01-01

jQuery - Load js file programmatically

$.getScript( "assets/file.js" )
.done(function( script, textStatus ) {
console.log( 'textStatus: [' + textStatus + ']' );
})
.fail(function( jqxhr, settings, exception ) {
console.log( "Triggered ajaxError handler." );
})
;

jQuery - Cookie handling (creation, reading, deletion)


(1) Download jQuery
http://jquery.com/download/

(2) Download the jQuery cookies plugin.
http://plugins.jquery.com/cookie/
(3) Create, read and delete.

Create cookie:
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });

Read cookie:
$.cookie('the_cookie'); 

Delete cookie:
$.removeCookie('the_cookie', { path: '/' });


jQuery - Map file not found error (jquery-2.0.3.min.map was not found on this server)

To avoid this, download not only the compressed main jQuery file, but also:

(1) The uncompressed file.
(2) and the "map" file.

These are all available at the jQuery main download page.
http://jquery.com/download/


Google Chrome - Developer tools, evaluating network performance

https://developers.google.com/chrome-developer-tools/docs/network#network_panel_overview

Google Chrome Developer Tools - Open / switch from inspect element mode and browser window

Keyboard shortcut on Mac OS:
CMD + SHIFT + C