Skip to main content

Posts

Showing posts from 2016

small code snippet to get Youtube video views from URL using Javascript

<div>     <input type="url" placeholder="Enter Youtube video URL">     <a href="#" onClick="videoViews()">GO</a>  </div> <div class="videoembed"></div> <div class="views"></div> -------------------------------------------------- function videoViews() {     var rex = /[a-zA-Z0-9\-\_]{11}/,         videoUrl = $('input').val() === '' ? alert('Enter a valid Url'):$('input').val(),         videoId = videoUrl.match(rex),         jsonUrl = 'http://gdata.youtube.com/feeds/api/videos/' + videoId + '?v=2&alt=json',        embedUrl = '//www.youtube.com/embed/' + videoId,        embedCode = '<iframe width="350" height="197" src="' + embedUrl + '" frameborder="0" allowfullscreen></iframe>'      ...

How to find the browser details using JavaScript

 Getting about OS, Browser, Mobile, Flash, Cookies, Screen Size and Full User Agent. /**  * JavaScript Client Detection  * (C) viazenetti GmbH (Christian Ludwig)  */ (function (window) {     {         var unknown = '-';         // screen         var screenSize = '';         if (screen.width) {             width = (screen.width) ? screen.width : '';             height = (screen.height) ? screen.height : '';             screenSize += '' + width + " x " + height;         }         // browser         var nVer = navigator.appVersion;    ...

Enable or disable client side validations in mvc4

We can enable or disable the client side validations in MVC4 by doing simple configuration / code changes. For enable / disable validations application level: We can use any one of the below two methods (web.config change or Global.asax.cs change) Configuration change in web.config < appSettings >     < add   key = " ClientValidationEnabled "   value = " true "   />     < add   key = " UnobtrusiveJavaScriptEnabled "   value = " true "   /> </ appSettings > Code change in Global.asax.cs file protected   void   Application_Start() {       HtmlHelper .ClientValidationEnabled =   true ;       HtmlHelper .UnobtrusiveJavaScriptEnabled =   true ; } For enable/disable validation in a particular view   set the below two properties in the View Razor code. @{       ViewBag.Title =   "Index" ;...

3 easy steps to create WebAPI documentations

By default, the API Help page created by   Microsoft . AspNet . WebApi . HelpPage   contains no documentation. We will see all   ApiController   actions are listed with   No   documentation available . To enable the documentation, we just need to follow three easy steps. Step 1 - on the controller level For the testing purpose, a new   ApiController   is created, named   DocumentationsController . public class DocumentationsController : ApiController { // GET api/documentation public IEnumerable <string> Get () { return new string [] { "value1" , "value2" }; } .... Hit   ///   ahead of the controller action to get the documentation. // GET api/documentation /// <summary> /// This is how we create a documentation /// </summary> /// <returns></returns> public IEnumerable <string> Get () .... For more information on what can be docume...

Gmail Error :The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required

https://www.google.com/settings/u/1/security/lesssecureapps Its a security issue, Gmail by default prevents access for your e-mail account from custom applications. You can set it up to accept the login from your application. After Logging in to your mail,  CLICK HERE This will take you to the following page Don't forget to click the back arrow near the title  Less Secure Apps  after  Turning ON .

SQL Server Isolation Levels with examples

Following are the different types of isolations available in SQL Server. READ COMMITTED READ UNCOMMITTED REPEATABLE READ SERIALIZABLE SNAPSHOT Let us discuss about each isolation level in details.Before this, execute following script to create table and insert some data that we are going to use in examples for each isolation IF OBJECT_ID('Emp') is not null begin DROP TABLE Emp end create table Emp(ID int,Name Varchar(50),Salary Int) insert into Emp(ID,Name,Salary) values( 1,'David',1000) insert into Emp(ID,Name,Salary) values( 2,'Steve',2000) insert into Emp(ID,Name,Salary) values( 3,'Chris',3000) Note:   Before executing each example in this article, reset the Emp table values by executing the above script. Read Committed In select query it will take only commited values of table. If any transaction is opened and incompleted on table in others sessions then select query...