Monday, February 16, 2015

Case-insensitive and Accent-insensitive String Comparison in Linq to SQL

ALTER TABLE Stories ALTER COLUMN Name [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AI

Friday, January 30, 2015

Wednesday, January 28, 2015

AngularJS Directives

ng-app
ng-controller
ng-model
ng-click
ng-submit
ng-repeat
ng-view
ng-show
ng-hide

Tuesday, January 27, 2015

Watching: AngularJS: Get Started























Link: http://www.pluralsight.com/courses/angularjs-get-started

Watching: Building Mobile Apps With the Ionic Framework and AngularJS























Link: http://www.pluralsight.com/courses/building-mobile-apps-ionic-framework-angularjs

Wednesday, January 21, 2015

First Ionic App




Sublime Text Emmet (ex-Zen Coding)

table snippet:
table>tr*2>td*3+tab

generated text:
<table>
      <tr>
        <td></td>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
        <td></td>
      </tr>
    </table>

Node.js Setup


Tuesday, January 6, 2015

New Read: jQuery UI In Action


New Read: Microsoft.NET: Architecting Applications for the Enterprise - Second Edition


Elmah Security Settings

<elmah>
    <security allowRemoteAccess="1"/>
</elmah>

<add key="elmah.mvc.requiresAuthentication" value="true" />
<add key="elmah.mvc.allowedRoles" value="Admin" />

Saturday, December 20, 2014

jQuery UI Autocomplete Changes in 1.10

Legacy 1.9 Code:
$("#searchBox").data("uiAutocomplete")._renderItem = function (ul, item) {
 return renderAutoCompleteItems(ul, item);
};

renderAutoCompleteItems = function(ul, item) {
 return $("<li />")
   .data("item.autocomplete", item)
   .append("<a><img style='width:50px; height:50px;' src='" + item.icon + "' /> " + item.label + "</a>")
   .appendTo(ul);
};

Updated 1.10 Code:
$("#searchBox").data("ui-autocomplete")._renderItem = function (ul, item) {
 return renderAutoCompleteItems(ul, item);
};

renderAutoCompleteItems = function(ul, item) {
 return $("<li />")
   .data("ui-autocomplete-item", item)
   .append("<a><img style='width:50px; height:50px;' src='" + item.icon + "' /> " + item.label + "</a>")
   .appendTo(ul);
};

Friday, December 12, 2014

Upgrade from ASP.NET Identity 1.0 to 2.0

View -> Package Manager Console
PM > Enable-Migrations
PM > Add-Migration UpdateIdentifyName
PM > Update-Database -verbose

using System.Data.Entity.Migrations;
    
    public partial class UpdateIdentifyName : DbMigration
    {
        public override void Up()
        {
            RenameColumn(table: "dbo.AspNetUserClaims", name: "User_Id", newName: "UserId");
            RenameIndex(table: "dbo.AspNetUserClaims", name: "IX_User_Id", newName: "IX_UserId");
            DropPrimaryKey("dbo.AspNetUserLogins");
            AddColumn("dbo.AspNetUsers", "FirstName", c => c.String(nullable: false, maxLength: 256));
            AddColumn("dbo.AspNetUsers", "LastName", c => c.String(nullable: false, maxLength: 256));
            AddColumn("dbo.AspNetUsers", "Email", c => c.String(maxLength: 256));
            AddColumn("dbo.AspNetUsers", "EmailConfirmed", c => c.Boolean(nullable: false));
            AddColumn("dbo.AspNetUsers", "PhoneNumber", c => c.String());
            AddColumn("dbo.AspNetUsers", "PhoneNumberConfirmed", c => c.Boolean(nullable: false));
            AddColumn("dbo.AspNetUsers", "TwoFactorEnabled", c => c.Boolean(nullable: false));
            AddColumn("dbo.AspNetUsers", "LockoutEndDateUtc", c => c.DateTime());
            AddColumn("dbo.AspNetUsers", "LockoutEnabled", c => c.Boolean(nullable: false));
            AddColumn("dbo.AspNetUsers", "AccessFailedCount", c => c.Int(nullable: false));
            AlterColumn("dbo.AspNetUsers", "UserName", c => c.String(nullable: false, maxLength: 256));
            AddColumn("dbo.AspNetUsers", "CreatedDateTime", c => c.DateTime(nullable: false));
            AlterColumn("dbo.AspNetRoles", "Name", c => c.String(nullable: false, maxLength: 256));
            AddPrimaryKey("dbo.AspNetUserLogins", new[] { "LoginProvider", "ProviderKey", "UserId" });
            CreateIndex("dbo.AspNetUsers", "UserName", unique: true, name: "UserNameIndex");
            CreateIndex("dbo.AspNetRoles", "Name", unique: true, name: "RoleNameIndex");
            DropColumn("dbo.AspNetUsers", "Discriminator");
        } 
    }

Tuesday, December 9, 2014

ASP.NET MVC File Upload through jQuery AJAX

HTML:
<input type="file" name="file" id="file" />

Javascript Submit:
var formData = new FormData();
var file = $("#file")[0].files[0];
formData.append("file", file);
formData.append("SourceId", 1234);
ajaxRequestFormData(window.urls.uploadAttachment, formData)

jQuery AJAX:
ajaxRequestFormData = function (url, model) {
$.ajax({
url: url,
type: "POST",
cache: false,
data: model,
dataType: "json",
contentType: false,
processData: false,
beforeSend: showProgress()
}).done(function (data) {
...
hideProgress();
}).fail(function () {
...
});
};

Controller Action:
public virtual ActionResult UploadAttachment(AttachmentDto attachment)
{
var file = Request.Files[0];
attachment.File = file;

var sourceId = attachment.SourceId;

...
}

Domain Class:
public class AttachmentDto
{
public HttpPostedFileBase File { get; set; }
public decimal SourceId { get; set; }
...
}

Wednesday, November 26, 2014

PowerShell Rename-Item

PS D:\source> dir | Rename-Item -NewName {$_.Name.ToLowerInvaria
nt()}

T-SQL Replace Method

update shows
set ProfileImagePath = replace(ProfileImagePath, '/Content/images/Shows/S', 's')
where Id = 1019

Wednesday, November 19, 2014

Tuesday, November 11, 2014

Monday, October 27, 2014