Tuesday, December 8, 2015

FireFox - Disable XSS filter

1. Go to about:config
2. search for browser.urlbar.filter.javascript
3. Set this to false

Sunday, October 25, 2015

Install JShint Sublime Text 2

Here are the steps to install JSHint in Sublime Text 2.

1. Install Sublime Package Manager. In Sublime go to View > Show Console menu and copy the following:

import urllib2,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

2. Via Sublime Package Manager do the following:

  • Ctrl+Shift+P or Cmd+Shift+P in Linux/Windows/OS X
  • type install, select Package Control: Install Package
  • type js gutter, select JSHint Gutter

Sunday, October 18, 2015

Angular List of items with Select all, checkboxes

An example of how to create a list of items with:

- Checkbox for each item
- Select all checkbox in table header
- When you uncheck all items the select all will uncheck
- When you check all items individually the select all will check

http://plnkr.co/edit/OaEXkql3Ds9xsozzTDBp

Sunday, June 21, 2015

Frozen column implementions

Over the years I have created and seen some interesting ways to create frozen columns. Some involved using javascript and some with just css.

To make a fixed or frozen column you typically create a table with a cell that has a cell with position absolute and provide a width.

Example: http://jsfiddle.net/72077p7g/

Another example: http://jsfiddle.net/m5rn687d/

Javascript example:

http://www.fixedheadertable.com/




Thursday, June 18, 2015

Azure Cloud Service - Change Default Guest OS Windows Version via Service Configuration file

Azure Cloud Services use Windows 2008 Server R2 operating system by default.
 
How do you override your Azure Cloud Service to use Windows 2012 Server R2 or other operating system? You could manually change it via the Azure web interface but then each time you deploy your cloud service it will be overwritten.
 
To automate this you can update osFamily value in the Service Configuration file for your web role.
 
- Windows 2008 Server R2 = 2
- Windows 2012 Server = 3
- Windows 2012 Server R2 = 4
<ServiceConfiguration serviceName="TestCloudService"xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"osFamily="4" osVersion="*" schemaVersion="2014-01.2.3">

Reactive Programming in JavaScript - Reactive Manifesto

Reactive Programming in JavaScript could be considered the next evolution of asynchronous programming; the next pattern for asynchronous development after JavaScript promised based patterns.
 
Reactive Manifesto - http://www.reactivemanifesto.org/
 
RxJS
 
MS Open Technologies has developed RxJS - RxJS or Reactive Extensions for JavaScript is a library for transforming, composing, and querying streams of data.
 
 
The Reactive Extensions for JavaScript (RxJS) is a set of libraries for composing asynchronous and event-based programs using observable sequences and fluent query operators that many of you already know by Array#extras in JavaScript. Using RxJS, developers represent asynchronous data streams with Observables, query asynchronous data streams using our many operators, and parameterize the concurrency in the asynchronous data streams using Schedulers. Simply put, RxJS = Observables + Operators + Schedulers.
 
RxJS Overview
 

Wednesday, June 17, 2015

Angular directive that will only allow numeric input


Create an input that is of type text. The directive will take the value and parse int therefore turning it into a number.

<input type="text" numeric-input-only ng-model="test.Units" required />

Directive:

angular.module('directives').directive('numericInputOnly', [function () {
    return {
        require: 'ngModel',
        link: function (scope, element, attrs, modelCtrl) {
            modelCtrl.$parsers.push(function (inputValue) {
             
                // When ng required is used
                // In such cases, when a letter is typed first, this parser will be called
                // again, and the 2nd time, the value will be undefined
                if (inputValue == undefined)
                {
                    return '';
                }
                 
                var transformedInput = inputValue.toString().replace(/[^0-9]/g, '');
                if (transformedInput != inputValue) {

                    modelCtrl.$setViewValue(parseInt(transformedInput));
                    modelCtrl.$render();
                }

                return parseInt(transformedInput);
            });
        }
    };
}]);


Another example that I haven't tried yet is to prevent the user from being able to enter certain keys by binding to keydown.

.directive('onlyNum', function() {
        return function(scope, element, attrs) {

            var keyCode = [8,9,37,39,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,110];
            element.bind("keydown", function(event) {
                console.log($.inArray(event.which,keyCode));
                if($.inArray(event.which,keyCode) == -1) {
                    scope.$apply(function(){
                        scope.$eval(attrs.onlyNum);
                        event.preventDefault();
                    });
                    event.preventDefault();
                }

            });
        };
    })

Wednesday, March 25, 2015

Easily locate iOS Simulator files for Mobile Development

During mobile development when using the iOS Simulator you need to review local files that you may be saving to the file system or sqlite db files.

Apple previously located the iOS Simulator files at /Library/Application Support/iPhone Simulator/[OS version]/Applications

In the new version of xcode 6 the above location is no longer present. A bunch of googling turned up nothing until I found a program called SimPholders that provides a program that locates your simulator files for you along with providing a menu that lists the different simulator versions.
Amaze balls!

http://simpholders.com/

Friday, March 13, 2015

iOS - Xamarin - Prevent entry of characters / Allow only numeric input in UITextField

textField.ShouldChangeCharacters = (UITextField textField, NSRange range, string replacementString) => { int test; return replacementString.Length == 0 || int.TryParse(replacementString, out test); };