Sunday, August 09, 2015

Useful resources to write better Angular Code and get ready for Angular 2.0

 

ECMAScript 6 is bringing lot of goodnes and the JavaScript in future might look a lot different than what we see today.

Frameworks like Angular, Backbone, Ember provide a nice wrappers to fill the gaps but ultimately we should keep our eye on ES6.

Here is how you can try ES6 today using compilers like babel and tracer today: http://jomit.blogspot.com/2015/02/trying-ecmascript-6-javascript-6.html 

 

Enjoying Javascripting….

Wednesday, April 29, 2015

Build 2015–Day 1 Keynote (takeaways)

 

Azure

  • Docker for Windows (docker client for windows)
    • Mix and Match linux and windows containers and run it on any server.
    • Debugging apps within containers in linux on windows server using Visual Studio.
    • .Net Core RC (for linux, windows and mac)
  • App Service
  • Visual Studio (download)
    • A free code editor for MAC, Linux and Windows
  • SQL DB Elastic Pool
    • For managing lots of databases in SaaS type scenarios
  • SQL Data Warehouse
    • Directly competes with AWS Redshift and its better.
  • Data Lake
    • Store and process infinite data.

Office

  • Office Apps
  • New Unified Graph API to access all the data from 1 place
  • ‘Delve’ App
  • ‘Sway’ App

Windows

  • Windows 10 Universal apps
  • Windows Store Apps now support  (this is freaking awesome !!!!!)
    • Web Sites/Web Apps
    • .Net and Win32 Apps (using app virtualization)
    • Android Java/ C++ Apps
    • Object C Apps
  • Compile Object C code using Visual Studio on Windows
  • Hololens
  • Microsoft Edge  (final name for ‘'Project Spartan’ the new Browser on Windows 10)

Saturday, April 11, 2015

New App type, CORS support and Office 365 API's with vanilla-js


Few months back Microsoft introduced several new API’s for Office 365 for which spun across SharePoint, Exchange, Lync, and rather than having the developers learn each of the platform they simplified the general concepts and also introduced a new type of app - “Office 365 external Apps

These apps look similar to “Provider Hosted Apps” but the have some key difference in the way you register them and launch them. For more details visit: http://www.sharepointnutsandbolts.com/2014/12/office-365-apps-and-sharepoint-apps-comparison.html

Along with this new type of Apps, Microsoft has also enabled cross-origin resource sharing (CORS) support for Office 365 API’s.
Which means we do not need any special client libraries to authenticate or access these API’s.

Let’s see how we can register this new type of app and then integrate it using vanilla-js.

Step 1 – Register your App

  • Sign in to Azure Management Portal
  • From Active Directory node select the Active Directory linked to your Office 365 subscription

    image
  • Click “Applications” tab from the top navigation

    image
  • Click “Add” from the bottom of the screen and select “Add an application my organization is developing”

    image
  • Provide the app name and select Web application and/or web API as Type

    image
  • Provide the Sign On URL of your web app in which you are integrating the API’s
  • Provide any unique ID of your App in App ID URI

    image

Step 2 – Configure permissions for App

  • Open the application and click “Configure” tab from the navigation

    image
  • Scroll down and click “Add Application” under “permissions to other applications

    image
  • Click “+” next to Office 365 SharePoint Online and save.

    image
  • For Office 365 SharePoint Online, open delegated permissions dropdown, select appropriate permissions
    and save the application

    image

Step 3 – Configure the App to allow OAuth implicit grant flow

  • On the configure tab, click on “Manage Manifest” button from the bottom and download the manifest

    image

    image
  • Set the value of "oauth2AllowImplicitFlow" to true and upload the manifest file.

    image

    image
  • The application registration is complete now…

Step 4 – Integrate it with a Web Page

  • Authenticate

    image

    image
  • Call the REST API with Authorization Token

    image

    image
  • Fetch document list from SharePoint

    image

    image

See complete code on github..

Other Resources:

.

.

.

Tuesday, February 24, 2015

Trying ECMAScript 6 (JavaScript 6) Features

 

I have been working with JavaScript for over 5 years now. In the last 3 years, I have written more JavaScript code than C# code. And still there are parts of the language that amaze me. Who would have thought that 10 days of work could give rise to the assembly language of the web.

What is ECMAScript 6 ?

ECMAScript 6 is the upcoming version of the ECMAScript standard. This standard is targeting ratification in June 2015. ES6 is a significant update to the language, and the first update to the language since ES5 was standardized in 2009. See the draft ES6 standard for full specification of the ECMAScript 6 language.

See detailed list of all the features (along with examples) here : https://github.com/lukehoban/es6features 

Which JavaScript Engines are implementing these features ?

Pretty much every browser vendor have started implementing some features, if not all.
Here is a live compatibility dashboard : http://kangax.github.io/compat-table/es6/

And as of today, IE is ahead of everyone in the ‘Desktop Browsers’ category.

image

How can I try some of these ES6 feature today ?

Here are your options:



Whether you like it or not, JavaScript is here to stay and will play a key role in pushing the web forward..

Thursday, February 19, 2015

Saturday, January 24, 2015

Machine Learning Course Summary (Part 6)

Summary from the Stanford's Machine learning class by Andrew Ng


  • Part 1
    • Supervised vs. Unsupervised learning, Linear Regression, Logistic Regression, Gradient Descent
  • Part 2
    • Regularization, Neural Networks
  • Part 3
    • Debugging and Diagnostic, Machine Learning System Design
  • Part 4
    • Support Vector Machine, Kernels
  • Part 5
    • K-means algorithm, Principal Component Analysis (PCA) algorithm
  • Part 6
    • Anomaly detection, Multivariate Gaussian distribution
  • Part 7
    • Recommender Systems, Collaborative filtering algorithm, Mean normalization
  • Part 8
    • Stochastic gradient descent, Mini batch gradient descent, Map-reduce and data parallelism

Anomaly detection

  • Examples
    • Fraud Detection
      • x(i) = features of users i activities.
      • Model p(x) from data
      • Identify unusual  users by checking  which have p(x) < epsilon
    • Manufacturing
    • Monitoring computers in a data center
  • Algorithm
    • Choose features x(i) that you think might be indicative of anomalous examples.
    • Fit parameters u1,…un, sigma square 1,… sigma square n
    • Given new example x, compute p(x):
    • Anomaly if p(x) < epsilon

image

  • Aircraft engines example
    • 10000     good (normal) engines
    • 20     flawed engines (anomalous)
    • Alternative 1
      • Training set: 6000 good engines
      • CV: 2000 good engines (y=0), 10 anomalous (y=1)
      • Test: 2000 good engines (y=0), 10 anomalous (y=1)
    • Alternative 2:
      • Training set: 6000 good engines
      • CV: 4000 good engines (y=0), 10 anomalous (y=1)
      • Test: 4000 good engines (y=0), 10 anomalous (y=1)
    • Algorithm Evaluation

image

  • Anomaly detection vs. Supervised learning

      Anomaly detection

      Supervised learning

      • Very small number of positive examples
      • Large number of positive and negative examples.
      • Large number of negative examples
      • Enough positive examples for algorithm to get a sense of what positive examples are like, future positive examples likely to be similar to ones in training set.
      • Many different “types” of anomalies. Hard for any algorithm to learn from positive examples what the anomalies look like; future anomalies may look nothing like any of the anomalous examples we’ve seen so far.
      • Fraud detection
      • Email spam classification
      • Manufacturing (e.g. aircraft engines)
      • Weather prediction (sunny/rainy/etc).
      • Monitoring machines in a data center
      • Cancer classification
    • Choose what features to use
      • Plot a histogram and see the data

    image

      • Original vs. Multivariate Gaussian model

    image

    Tuesday, January 13, 2015

    Installing node-canvas on Win64 and Visual Studio 2013 Update 4

     

    While exploring machine learning using JavaScript I came across this nice video and github project by Heather Arthur.

    I decided to try it out, but I had to resolve quite a few issues. Here is the takeaway from the solution:

    • Install 32bit version of python instead of 64bit.

      • This is help overcome a lot of issues later when installing python libraries as the library installer look for details in registry to check if specific version of Python is installed or not. And with 64bit installation it wasn’t able to detect it.

    • node-canvas requires cairo which can be installed on Windows via the GTK+ package.

      • Download the 64 bit 2.22 all-in-one bundle for 64bit machines or else the C++ compiler will throw LINKER errors while building the package.
      • Make sure to follow the instructions in the gtk+-bundle_2.22.1-20101229_win64.README.txt file at the root of the bundle
      • Copy all the contents of the bundle to “C:\GTK” folder as the node-gyp needs that

    • Use the –-msvs_version=2013 switch to install the ‘canvas’ package

      • I got this error while installing the ‘canvas’ npm package from Visual Studio
    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".
      • I had to do 2 things to resolve it:
        • Update node-gyp to the latest version, including the one that is internally used by node
        • Use ‘npm install –-msvs_version=2013 canvas’ from command line to install the package.

    Finally add the canvas package with version number in dependencies in package.json to make Visual studio happy…

    Sunday, January 11, 2015

    Machine Learning Course Summary (Part 5)

    Summary from the Stanford's Machine learning class by Andrew Ng


    • Part 1
      • Supervised vs. Unsupervised learning, Linear Regression, Logistic Regression, Gradient Descent
    • Part 2
      • Regularization, Neural Networks
    • Part 3
      • Debugging and Diagnostic, Machine Learning System Design
    • Part 4
      • Support Vector Machine, Kernels
    • Part 5
      • K-means algorithm, Principal Component Analysis (PCA) algorithm
    • Part 6
      • Anomaly detection, Multivariate Gaussian distribution
    • Part 7
      • Recommender Systems, Collaborative filtering algorithm, Mean normalization
    • Part 8
      • Stochastic gradient descent, Mini batch gradient descent, Map-reduce and data parallelism

    K-means Algorithm

    • Clustering

    image

    • K-means algorithm
      • Put random cluster centroids
      • Find mean and replot cluster centroids
      • repeat…

    image

    image

    image

      • *Note – If a centroid has NO POINTS assigned to it, than eliminate that cluster centroid

    image

      • If we randomly choose WRONG X values than it might get stuck in “local optima”

    image

      • To solve the above random initialization problem, we run it 100 times and pick the clustering that gave lowest cost.
        • Note:
          • if K is small (between 2 to 10) than multiple random initialization will find better local optima
          • if K is large than multiple random initialization may not help or make a huge difference.

    image

    • How to choose the Number of Clusters ??
      • Elbow method

    image

    image

    Dimensionality Reduction

    • Reduce data from 2D to 1D and 3D to 2D

    image

    image

    image

    image

    image

    Principal Component Analysis (PCA) Algorithm

    • Data Preprocessing

    image

    image

    • Algorithm
      • Reduce data from n dimensions to k dimensions
      • Compute “covariance matrix”
      • Compute “eigenvectors” of matrix sigma

    image

    image

      • Summary

    image

    • Choosing K (number of principal components)
      • Typically choose k to be smallest value:
      • 95% to 99% is a common variance value

    image

      • Keep changing K and see what gives us the smallest value which gives us 99% variance.

    image

    Applying Principal Component Analysis (PCA)

    • Supervised Learning Speedup
      • Extract inputs
      • Apply PCA
      • Get New Training Set
      • Use logistic regression or other algorithms

    image

    • Application of PCA
      • Compressions
        • Reduce memory/disk needed to store data
        • Speed up learning algorithm
      • Visualization
      • DO NOT USE PCA to prevent overfitting (to reduce the number of features), use regularization instead.
      • Before implementing PCA, first try running whatever you want to do with the original/raw data. Only if that doesn’t do what you want, then implement PCA

    AddIn