LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt

  • Either disable incremental linking, by going to

    Project Properties 
       -> Configuration Properties 
           -> Linker (General) 
              -> Enable Incremental Linking -> "No (/INCREMENTAL:NO)"
  • or install VS2010 SP1.

Note that installing VS 2010 SP1 will remove the 64-bit compilers. You need to install the VS 2010 SP1 compiler pack to get them back.

This affects Microsoft Windows SDK 7.1 for Windows 7 and .NET 4.0 as well as Visual Studio 2010.

Formats date to a string based on the requested format

format string can be composed of the following elements:

  • 'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)
  • 'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
  • 'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)
  • 'MMMM': Month in year (January-December)
  • 'MMM': Month in year (Jan-Dec)
  • 'MM': Month in year, padded (01-12)
  • 'M': Month in year (1-12)
  • 'dd': Day in month, padded (01-31)
  • 'd': Day in month (1-31)
  • 'EEEE': Day in Week,(Sunday-Saturday)
  • 'EEE': Day in Week, (Sun-Sat)
  • 'HH': Hour in day, padded (00-23)
  • 'H': Hour in day (0-23)
  • 'hh': Hour in am/pm, padded (01-12)
  • 'h': Hour in am/pm, (1-12)
  • 'mm': Minute in hour, padded (00-59)
  • 'm': Minute in hour (0-59)
  • 'ss': Second in minute, padded (00-59)
  • 's': Second in minute (0-59)
  • '.sss' or ',sss': Millisecond in second, padded (000-999)
  • 'a': am/pm marker
  • 'Z': 4 digit (+sign) representation of the timezone offset (-1200-+1200)
  • 'ww': ISO-8601 week of year (00-53)
  • 'w': ISO-8601 week of year (0-53)

    format string can also be one of the following predefined localizable formats:

  • 'medium': equivalent to 'MMM d, y h:mm:ss a' for en_US locale (e.g. Sep 3, 2010 12:05:08 pm)
  • 'short': equivalent to 'M/d/yy h:mm a' for en_US locale (e.g. 9/3/10 12:05 pm)
  • 'fullDate': equivalent to 'EEEE, MMMM d,y' for en_US locale (e.g. Friday, September 3, 2010)
  • 'longDate': equivalent to 'MMMM d, y' for en_US locale (e.g. September 3, 2010)
  • 'mediumDate': equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010)
  • 'shortDate': equivalent to 'M/d/yy' for en_US locale (e.g. 9/3/10)
  • 'mediumTime': equivalent to 'h:mm:ss a' for en_US locale (e.g. 12:05:08 pm)
  • 'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 pm)

    format string can contain literal values. These need to be quoted with single quotes (e.g. "h 'in the morning'"). In order to output single quote, use two single quotes in a sequence (e.g. "h 'o''clock'").


In HTML Template Binding

  1. {{ date_expression | date : date : format}}

In JavaScript

  1. $filter(‘date’)(date, format)

Writing directives in AngularJS

There are different ways to declare a directive. The difference resides in the return value of the factory function. You can either return a Directive Definition Object (see below) that defines the directive properties, or just the postLink function of such an object (all other properties will have the default values).

Here’s an example directive declared with a Directive Definition Object:


var myModule = angular.module(...);
myModule.directive('directiveName', function factory(injectables) {
  var directiveDefinitionObject = {
    priority: 0,
    template: '<div></div>',
    templateUrl: 'directive.html',
    replace: false,
    transclude: false,
    restrict: 'A',
    scope: false,
    controller: function($scope, $element, $attrs, $transclude, otherInjectables) { ... },
    compile: function compile(tElement, tAttrs, transclude) {
      return {
        pre: function preLink(scope, iElement, iAttrs, controller) { ... },
        post: function postLink(scope, iElement, iAttrs, controller) { ... }
    link: function postLink(scope, iElement, iAttrs) { ... }
  return directiveDefinitionObject;

In most cases you will not need such fine control and so the above can be simplified. You can still return a Directive Definition Object, but only setting the ‘compile’ function property of the Object, and rely on the default values for other properties.

Therefore the above can be simplified as:

var myModule = angular.module(...);
myModule.directive('directiveName', function factory(injectables) {
  var directiveDefinitionObject = {
    compile: function compile(tElement, tAttrs) {
      return function postLink(scope, iElement, iAttrs) { ... }
  return directiveDefinitionObject;

Finally, most directives concern themselves only with instances, not with template transformations, allowing further simplification.

Here we only define the postLink function:

var myModule = angular.module(...);
myModule.directive('directiveName', function factory(injectables) {
  return function postLink(scope, iElement, iAttrs) { ... }

Get or display file image of base64 string in HTML/Javascript

There are 2 common scenarios of display file image in base64 string, one is use the HTML file upload, the other is that some API will return image in base64 string. You know, that a binary file is easy to translate into base64 string.

Here is an AngularJS code snippet, a directive to show the uploaded image

.directive('myUpload', [function () {
return {
 restrict: 'A',
 link: function (scope, elem, attrs) {
  var reader = new FileReader();
  reader.onload = function (e) {
            scope.image =;

        elem.on('change', function() {

And you can use it in your HTML file like this

<img ng-if="image" src="{{image}}" alt="">
<input my-upload type="file" name="upload">


A file image in base64 string is something like /9j/4AAQSkZJRg…, and you can show it in your browser by type this string in your address bar like this  data:image/png;base64,/9j/4AAQSkZJRg..

Just add a prefix: data:image/png;base64,

And also, you can show image in html like

<img src=data:image/png;base64,/9j/4AAQSkZJRg” >

Web development via angularjs, javascript,, c#, html5, SEO, etc