Get Your any Mobile(android, windows), Web Application, Desktop Code/Project Done... HERE

Expert in .net project with over 300+ projects done till now.

Tuesday, 30 May 2017

Enable Audit Record in Sql server

Command in Sql Server Master database

USE MASTER
GO

CREATE SERVER AUDIT audit_test                                          
TO FILE (FILEPATH = 'G:\')
GO


CREATE SERVER AUDIT SPECIFICATION audit_test_spec      
FOR SERVER AUDIT [audit_test]
ADD (FAILED_LOGIN_GROUP),
ADD (SUCCESSFUL_LOGIN_GROUP)
WITH (STATE=ON)
GO


Now check in Security-> Audit -> Audit log

How to find the active SQL connections and kill them

Find Active connections in sql server

select
    db_name(dbid) as [Database Name],
    count(dbid) as [No Of Connections],
    loginame as [Login Name]
from
    sys.sysprocesses
where
    dbid > 0
group by
    dbid, loginame


How to kill a SQL connection

set nocount on
declare @databasename varchar(100)
declare @query varchar(max)
set @query = ''

set @databasename = 'xxx'
if db_id(@databasename) < 4
begin
print 'system database connection cannot be killeed'
return
end

select @query=coalesce(@query,',' )+'kill '+convert(varchar, spid)+ '; '
from master..sysprocesses where dbid=db_id(@databasename)

if len(@query) > 0
begin
print @query
exec(@query)
end

Thanks


Tuesday, 20 September 2016

New Smartphone with 12GB RAM, 1TB storage unveiled

Here is the News --

Turing Robotics Industries (TRI) has unveiled its latest smartphone - the Turing Phone Cadenza. It comes with 'Voice On' technology which enables the smartphone to be switched On/Off using voice commands. Users can also use these voice commands for biometric authentication.

The Turing Phone Cadenza features a 5.8-inch Quad HD display of 1440x2560 pixel resolution. It is powered by not one, but two Qualcomm Snapdragon 830 (even though the same hasn't been officially announced) CPUs paired with a an astonishing 12GB of RAM and 1TB of internal storage. The storage can be further expanded up to 500GB by installing a microSD card.
The Cadenza runs Turing's own Swordfish OS with deep learning Artificial Intelligence (AI) features a 60MP rear camera with IMAX 6K recording facility and a 20MP dual-front camera. Users can install up to 4 sim cards in the smartphone and it houses a huge 100Wh battery with graphene and hydrogen fuel cells. 
In related news, BlackBerry recently launched its secure Android smartphone DTEK50 in July. BlackBerry claims that the DTEK50 is its slimmest smartphone yet, at just 7.4mm thick.
Running Android 6.0 Marshmallow, BlackBerry DTEK50 features a 5.2-inch full-HD scratch-resistant display and is powered by an octa-core Qualcomm Snapdragon 617 processor clubbed with 3GB RAM. Housing 16GB of in-built storage, which can be further expanded up to 2TB via microSD cards.
BlackBerry DTEK50 has a 13MP autofocus rear camera along with an 8MP front-facing shooter. Both cameras can record Full HD videos at 30 frames per second. On the connectivity front, the handset supports Bluetooth, Wi-Fi, NFC, GPS, 3G, and 4G.

SPECIFICATIONS


Source - gadgetsnow

Saturday, 18 June 2016

How to put delay before doing an operation in WPF

Here is the code :
The call to Thread.Sleep is blocking the UI thread. You need to wait asynchronously.
Method 1: use a DispatcherTimer
tbkLabel.Text = "two seconds delay";

var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
timer.Start();
timer.Tick += (sender, args) =>
    {
        timer.Stop();
        var page = new Page2();
        page.Show();
    };
Method 2: use Task.Delay
tbkLabel.Text = "two seconds delay";

Task.Delay(2000).ContinueWith(_ => 
   { 
     var page = new Page2();
     page.Show();
   }
);
Method 3: The .NET 4.5 way, use async/await
// we need to add the async keyword to the method signature
public async void TheEnclosingMethod()
{
    tbkLabel.Text = "two seconds delay";

    await Task.Delay(2000);
    var page = new Page2();
    page.Show();
}

Friday, 3 June 2016

im2col function in MATLAB explanation

Let us suppose we have


A=[1 1;2 2]

1 1

2 2 ... ok


Now img2col syntax  == im2col(A,[m n],block_type)


Where block type = ('distinct','sliding')

distinct places 0's in the final output,,,for padding,

sliding,,repeats from the very first matrix element. after all elements read out.


Now..


Now [m n] -- very important ....


Number of Rows to show = M*N (if m=2 ,, n=2 then each column has 4 elements..)

and Number of element fetch to repeat is M in row...

That means,,


OUTPUT OF THIS - im2col(A,[2 2], 'sliding')

ans =

     1
     2
     1
     2


-- if  A=[1 1 1;2 2 2]

A =

     1     1     1
     2     2     2


then


im2col(A,[2 2], 'sliding')

ans = contains 4 rows....as 2*2 ...   and fetch 2 elements as M=2 here...

and sliding ,,so repeats after 6th element..

     1     1
     2     2
     1     1
     2     2


Now... next


 im2col(A,[3 2], 'distinct')


Here 3*2=6 elements in each row....and fetch 3 elements,,as it contains,,2 elements ,,add 0

and here is the output..

ans =

     1     1
     2     2
     0     0
     1     0
     2     0
     0     0


 Next


im2col(A,[2 3], 'distinct')

-- 6 elements,,,,,and fetch 2 from each column,,,

ans =

     1
     2
     1
     2
     1
     2


NEXT


 im2col(A,[2 4], 'distinct')

-- 8 rows...and fetch 2,,,from each column...

ans =

     1
     2
     1
     2
     1
     2
     0
     0


NEXT


 im2col(A,[4 2], 'distinct')
here 8 rows....and fetch 4 elements from each column,,,as we have 2 then add 2 zeros...to make 4 as needed.


ans =

     1     1
     2     2
     0     0
     0     0
     1     0
     2     0
     0     0
     0     0



Simple...Enjoy,, :)

Wednesday, 30 March 2016

Check Image extension using input type file in html using Jquery


Here is the code :

$fileinput1.on("change", function () {
                var input = this;
                var url = $(input).val();
                var ext = url.substring(url.lastIndexOf('.') + 1).toLowerCase();

                if (input.files && input.files[0] && (ext == "png" || ext == "jpeg" || ext == "jpg")) {

                    var FR = new FileReader();
                    FR.onload = function (e) {
                        var imagetocheck = new Image();
                        imagetocheck.src = e.target.result;
                        imagetocheck.onload = function () {
                            var width = this.width;
                            var height = this.height;

                            if (width == 50 && height == 50) {
                              
                            }
                            else {
                               
                                alert('Invalid Dimensions - Only image with Height-50px and Width 50px is accepted !!');
                            }
                        };
                    };
                    FR.readAsDataURL(this.files[0]);
                }
                else {                  
                    alert('Invalid extension');
                }
            });

Tuesday, 22 March 2016

Divide any number into Equal parts in SQL SERVER


First Create One function that will generate very first part

 CREATE FUNCTION pGetCallsCount
(
 @totalcall INT = 51,
 @Count INT  = 4
)
RETURNS INT
AS
BEGIN
DECLARE @result1 INT
 DECLARE @r INT  = @totalcall % @Count
 IF(@r=0)
 BEGIN
 IF(@count=1)
 SET @result1=@totalcall
 ELSE
  SET @result1=@totalcall/@count 
 END
 ELSE
  BEGIN 
  SET @result1=(@Count-@r)+@totalcall -- surely divided
  SET @result1=@result1/@Count
  END
  RETURN @result1
END
GO


Then Call that function to create next parts like mentioned below :-

DECLARE @totalcall INT = 43
DECLARE @Count INT  = 4
DECLARE @r INT  = @totalcall % @Count

DECLARE @totalsum INT=0
DECLARE @result INT
DECLARE @totalcalldemo INT
SELECT @totalcalldemo=@totalcall
WHILE(@totalsum<>@totalcalldemo)
BEGIN
SELECT @result=dbo.pGetCallsCount(@totalcall,@Count) -- (51,4),
SET @totalcall=@totalcall-@result
SET @Count=@Count-1
SET @totalsum=@totalsum+@result
PRINT @result
END 


OUTPUT
11
11
11
10