Tuesday, April 18, 2017

Deferred objects in jQuery

Deferred objects in jQuery

Deferred objects in jQuery represents a unit of work that will be completed later, typically asynchronously.
Once the unit of work is complete, the deferred object can be set to resolved or failed.
A deferred object contains a promise object.
With the promise object you can specify what is to happen when the unit of work completes by setting callback functions.

Wednesday, February 22, 2017

Find table size, row and column in sql server

CREATE TABLE #temp (
table_name sysname ,
row_count INT,
reserved_size VARCHAR(50),
data_size VARCHAR(50),
index_size VARCHAR(50),
unused_size VARCHAR(50))
SET NOCOUNT ON
INSERT #temp
EXEC sp_msforeachtable 'sp_spaceused ''?'''
SELECT a.table_name,
a.row_count,
COUNT(*) AS col_count,
a.data_size
FROM #temp a
INNER JOIN information_schema.columns b
ON a.table_name collate database_default
= b.table_name collate database_default
GROUP BY a.table_name, a.row_count, a.data_size
ORDER BY CAST(REPLACE(a.data_size, ' KB', '') AS integer) DESC
DROP TABLE #temp

Tuesday, January 3, 2017

Split function in sql

Create  FUNCTION [dbo].[fnSplitPosToString] (
 @string VARCHAR(MAX)
 ,@delimiter CHAR(1)
 )

 RETURNS @output TABLE (Id int identity (1,1),data VARCHAR(256))
 
BEGIN
 DECLARE @start INT
     ,@end INT
 
 SELECT @start = 1
  ,@end = CHARINDEX(@delimiter, @string)
 
 WHILE @start < LEN(@string) + 1
 BEGIN
  IF @end = 0
   SET @end = LEN(@string) + 1
 
  INSERT INTO @output (data)
  VALUES (SUBSTRING(@string, @start, @end - @start))
 
  SET @start = @end + 1
  SET @end = CHARINDEX(@delimiter, @string, @start)
 END
 
 RETURN
END

AngularJS Scope Methods

$watch: This method is used to watch value changes in scope properties or variables.
$watchGroup: This method is used to watch value in scope array variable.
$watchCollection: This method is used to observe properties on a single object.
$on: This method is used to listens dispatched events of a given type
$emit: This method is used to dispatches an event name upwards and travel up to        $rootScope.scope listeners.
$broadcast: This method is used to dispatches an event name downward to all child scopes notify the registered $rootScope listeners.
$new: This scope object method creates a new child scope.
$digest: This scope method processes all of the watchers of the current scope and its children.
$destroy: This scope method is used to removes the current scope (and all of its children) from the parent scope.
$eval: This scope method is used to executes the expression on the current scope and returns the result.
$apply: This scope method is used to execute an expression in angular from outside of the angular framework.