Tuesday 20 December 2016

Tuesday 11 October 2016

Angular 2

Proxy: https://jjasonclark.com/how-to-setup-node-behind-web-proxy

Disable SSL:
npm config set strict-ssl false

Set Registry
npm config set registry "http://registry.npmjs.org/"

Proxy
npm config set proxy http://localhost:53128
npm config set https-proxy http://localhost:53128
npm config set registry http://registry.npmjs.org
Angular with TypeScript
https://angular.io/docs/ts/latest/quickstart.html

WebPack:

  • https://github.com/AngularClass/angular2-webpack-starter
  • https://github.com/preboot/angular2-webpack



Angular 2

Proxy: https://jjasonclark.com/how-to-setup-node-behind-web-proxy

Disable SSL:
npm config set strict-ssl false

Set Registry
npm config set registry "http://registry.npmjs.org/"

Proxy
npm config set proxy http://localhost:53128
npm config set https-proxy http://localhost:53128
npm config set registry http://registry.npmjs.org

Angular 2

Proxy: https://jjasonclark.com/how-to-setup-node-behind-web-proxy

Disable SSL:
npm config set strict-ssl false

Proxy
npm config set proxy http://localhost:53128
npm config set https-proxy http://localhost:53128
npm config set registry http://registry.npmjs.org

Sunday 21 August 2016

Custom Shadowbox Modal

The below code shows the Processing Image as a Modal.

You can close it by setting the processing property on the angular $scope.

 .customModal {

            position: fixed; /* Stay in place */

            z-index: 1; /* Sit on top */

            padding-top: 100px; /* Location of the box */

            left: 0;

            top: 0;

            width: 100%; /* Full width */

            height: 100%; /* Full height */

            text-align: center;

            background-color: rgb(0, 0, 0); /* Fallback color */

            background-color: rgba(0, 0, 0, 0.4); /* Black w/ opacity */

        }



        /* Modal Content */

        .customModal-content {

            margin: auto;

            width: 220px;

            height: 183px;

        }
    
   

Tuesday 9 August 2016

SMS Gateway Providers


·         TextLocal
o   They provide an API to use http://www.textlocal.com/sms-api-integrations
o   Commercial – PAYG (2.4p per text) or Monthly payments
·         ClickATell
o   Commercial (2.9p per message)
·         Twilio:
o   Commercial
·         Email to SMS Gateway (doesn’t seem to be reliable):

Dynmark:


·         There seems to be a way also with pure .NET but need to look into it if it has any drawbacks: http://www.codeproject.com/Articles/19023/Sending-SMS-using-NET

Sinch
Nexmo
Plivo



Thursday 7 July 2016

DateTime Extensions

public static class DateTimeExtensions
    {
        /// 
        /// Includes the from and to dates so from Monday to Tuesday it returns 2
        /// 
        public static int FindBusinessDaysUntil(this DateTime from, DateTime to)
        {
            double calcBusinessDays =
                1 + ((to - from).TotalDays * 5 -
                (from.DayOfWeek - to.DayOfWeek) * 2) / 7;

            if ((int)to.DayOfWeek == 6) calcBusinessDays--;
            if ((int)from.DayOfWeek == 0) calcBusinessDays--;

            return Convert.ToInt16(calcBusinessDays);
        }

        public static DateTime NextBusinessDay(this DateTime from)
        {
            var nextDay = from.AddDays(1);

            while (true)
            {
                var numberOfBusinessDays = FindBusinessDaysUntil(from, nextDay);

                if (numberOfBusinessDays == 2)
                {
                    return nextDay;
                }

                nextDay = nextDay.AddDays(1);
            }
        }

        public static DateTime NextBusinessDay(this DateTime from, int days)
        {
            var result = from;

            for (int i = 0; i < days; i++)
            {
                result = result.NextBusinessDay();
            }

            return result;
        }        
    }
}

Tuesday 28 June 2016

.NET Memory Leak Checklist


CheckList:

  • Check application logs
  • Check IIS logs
  • Check event viewer
  • Check Windows Error Logs
  • Check Windows Resource Monitoring window
  • Check Crash Dumps; if not configured set it up.

How to Create a Memory Dump:
https://support.symantec.com/en_US/article.howto31321.html

https://blogs.msdn.microsoft.com/chaun/2013/11/12/steps-to-catch-a-simple-crash-dump-of-a-crashing-process/

You can then use it for further analysis via DebugDiag or Visual Studio.

Tools

ProcDump Tool

DebugDiag Tool

ANTS Memory Profiler
Add LocalDumps

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps


Will be captured to:

%LOCALAPPDATA%\CrashDumps

Wednesday 22 June 2016

Google Maps Geolocation

    
    

Tuesday 31 May 2016

Post FormData with Multiple Params

 
 public class FormDataBuilder
    {
        private readonly List _params = new List();

        private readonly string _boundary;

        private const string BoundaryDashes = "--";

        public FormDataBuilder(string boundary)
        {
            _boundary = boundary;
        }

        public string Build()
        {
            StringBuilder sb = new StringBuilder();
            
            foreach (FormDataParam param in _params)
            {
                sb.AppendLine(BoundaryDashes + _boundary);

                sb.AppendLine(param.ParamType == FormDataParamType.File
                    ? string.Format("Content-Disposition: file; name=\"{0}\"; filename=\"{1}\"", param.Name, param.FileName)
                    : string.Format("Content-Disposition: form-data; name=\"{0}\"", param.Name));

                sb.AppendLine("Content-Type: {0}".FormatWith(param.ContentType.Description()));
                sb.AppendLine();
                sb.AppendLine(param.Value);
            }

            sb.AppendLine(BoundaryDashes + _boundary + BoundaryDashes);

            return sb.ToString(); 
        }

        public FormDataBuilder AddImage(string name, string value, string fileName)
        {
            return Add(FormDataParam.CreateImage(name, value, fileName));
        }

        public FormDataBuilder AddAudio(string name, string value, string fileName)
        {
            return Add(FormDataParam.CreateAudio(name, value, fileName));
        }

        public FormDataBuilder AddText(string name, string value)
        {
            return Add(FormDataParam.CreateField(name, value, ContentType.Text));
        }

        public FormDataBuilder AddJson(string name, string value)
        {
            return Add(FormDataParam.CreateField(name, value, ContentType.Json));
        }

        public FormDataBuilder Add(FormDataParam formDataParam)
        {
            _params.Add(formDataParam);

            return this;
        }
    }

 public enum FormDataParamType
    {
        Field,
        File
    }

    public enum ContentType
    {
        [Description("text/plain")]
        Text,
        [Description("application/json")]
        Json,
        [Description("image/jpg")]
        Image,
        [Description("audio/wav")]
        Audio
    }

    public class FormDataParam
    {
        public string Name;
        public string FileName;
        public string Value;
        public FormDataParamType ParamType;
        public ContentType ContentType;

        public static FormDataParam CreateField(string name, string value, ContentType contentType)
        {
            return new FormDataParam()
            {
                Name = name,
                Value = value,
                ParamType = FormDataParamType.Field,
                ContentType = contentType
            };
        }

        public static FormDataParam CreateImage(string name, string value, string fileName)
        {
            return new FormDataParam()
            {
                Name = name,
                Value = value,
                ParamType = FormDataParamType.File,
                FileName = fileName,
                ContentType = ContentType.Image
            };
        }

        public static FormDataParam CreateAudio(string name, string value, string fileName)
        {
            return new FormDataParam()
            {
                Name = name,
                Value = value,
                ParamType = FormDataParamType.File,
                FileName = fileName,
                ContentType = ContentType.Audio
            };
        }
    }

Monday 23 May 2016

Most Useful JavaScript Libraries

MediaStreamRecorder on GitHub

Cross browser audio/video/screen recording

WebCamJS on GitHub
HTML5 Webcam Image Capture Library

jQuery UI
A set of controls, effects, widgets, and themes built on top of the jQuery JavaScript Library.


Thursday 5 May 2016

Smart Authentication

Jumio:
ID Scanning and Verification

Mitek:
ID Scanning and Verification
http://finovate.com/videos/finovatespring-2016-mitek/

ImageWare:
Identity management and biometric enrollment over the web and via mobile.

InAuth:
Find geolocation details based on your device details





Monday 14 March 2016

Add or Update Query String

        location.href = addOrUpdateQueryString(location.href, 'maxPageSize', '50');

        var addOrUpdateQueryString = function(url, name, value) {

        var splitted = url.split('?');
        var base = splitted[0];
        var pairsArray = [];
        var isNew = true;
        if (splitted.length > 1) {
            // it has query string
            var qPairsArray = splitted[1].split('&');
            for (var i = 0; i < qPairsArray.length; i++) {
                var pair = qPairsArray[i].split('=');
                var pairName = pair[0];
                var pairValue = pair[1];
                if (pairName == name) {
                    pairValue = value;
                    isNew = false;
                }
                pairsArray.push({ name: pairName, value: pairValue });
            }
        }

        if (isNew) {
            pairsArray.push({ name: name, value: value });
        }

        return buildUrl(base, pairsArray);
    }

 function buildUrl(base, pairsArray) {
        var newQ = '';
        pairsArray.forEach(function (obj) {
            var thisPair = obj.name + '=' + obj.value;
            newQ = newQ + (newQ == '' ? '' : '&') + thisPair;
        });

        return base + "?" + newQ;
    }