Tuesday, May 31, 2016

AUTH0 ANGULAR 2 - github links

Steps in creating and running demo Angualr2 + Auth0:
1. Create account on Auth0
2. Create Application (download Angular2 + Auth0 sample code)
3. Add Allowed Callback URLs separated by comma for Prod and Dev e.g http://localhost:3000/, http://localhost:8080/, http://localhost:8081/ (if it is not set you will got an error on login: error invalid origin)
4. Create User with login password



4. Build for prod: npm run watch:prod
5. Build for prod: npm run server:prod
C:\Users\Andre\Downloads\AUTH0\auth0-angular2-sample\webpack>npm run server:prod

> auth0-angular2-webpack@0.0.0 server:prod C:\Users\Andre\Downloads\AUTH0\auth0-angular2-sample\webpack
> http-server dist --cors

Starting up http-server, serving dist
Available on:
  http://93.126.95.40:8081
  http://127.0.0.1:8081

5. Build for prod: npm run server:prod
5. Build for prod: npm run server:prod
5. Build for prod: npm run server:prod
5. Build for prod: npm run server:prod
5. Build for prod: npm run server:prod
5. Build for prod: npm run server:prod


auth0 pricing
https://auth0.com/pricing

auth0-angular2
https://github.com/auth0/auth0-angular2/blob/master/webpack/package.json

angular2-jwt
https://github.com/auth0/angular2-jwt

Real world Angular 2 app authentication
https://auth0.com/blog/2015/05/14/creating-your-first-real-world-angular-2-app-from-authentication-to-calling-an-api-and-everything-in-between/

JWT - JSON Web Token for auth0 authorization
https://jwt.io/introduction/

Friday, May 20, 2016

TYPESCRIPT - TypeScript compiler explained: Anders Hejlsberg on Modern Compiler Construction

TYPESCRIPT - Anders Hejlsberg on TypeScript 2

TYPESCRIPT - my notes on Pluralsight TypeScript Fundamentals by Dan Wahlin and John Papa

Pluralsight TypeScript Fundamentals by Dan Wahlin and John Papa

TypeScript is a superset of JavaScript

Arrow Functions => (actually it is a "fat" arrow :)
It is a Lambdas.

TypeScript Key Features
Dynamic vs Static

Optional parameter
x? : number

Type and Ambient Declaration
Type declarations: http://definitelytyped.org/
Look for different *.d.ts types files: typescript.codeplex.com
Other 3rd party types files: https://github.com/DefinitelyTyped/DefinitelyTyped


Object Types


Function
Function can take in its parameter object type like this:

var someField = function (rect: {h: number, w?: number}) {
    if (rect.w === undifined) {
          rect.h * rect.h;
    } else {
        rect.h * rect.w;
    }
}

Class
Every class in TypeScript can have:
Constructor, Fields, Properties, Functions

Make variable of whole class and call from that variable static methods:
let greeterMaker: typeof Greeter = Greeter; 
greeterMaker.standardGreeting = "Hey there!";

Properties
Properties are the private members of the class exposed to the exterior by get and set key words.
Check this post: http://blogs.microsoft.co.il/gilf/2013/01/22/creating-properties-in-typescript/

Using a class as an interface (!!!)
As we said in the previous section, a class declaration creates two things: a type representing instances of the class and a constructor function. Because classes create types, you can use them in the same places you would be able to use interfaces.

class Point {
    x: number;
    y: number;
}

interface Point3d extends Point {
    z: number;
}

let point3d: Point3d = {x: 1, y: 2, z: 3};

Rest parameter in TypeScript is what we know like Varargs in Java
someMethod(...someArgs: string)









Wednesday, May 18, 2016

SPARK - pluralsight course Apache Spark Fundamentals, my notes


Resources about the use of Spark:
https://amplab.cs.berkeley.edu/for-big-data-moores-law-means-better-decisions/
https://www.chrisstucchio.com/blog/2013/hadoop_hatred.html
http://aadrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html
https://github.com/rozim/ChessData (PGN source) https://en.wikipedia.org/wiki/Portable_Game_Notation (PGN wiki)
https://spark.apache.org/examples.html

Spark installation's issues on Window 10:
The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rw-rw-rw- (on Windows)
How to fix it:
Be sure you have the right version of winutil.exe (its size should be > 100kb). The download link of it is here: http://letstalkspark.blogspot.com/2016/02/getting-started-with-spark-on-window-64.html
find out this line: e.g. -  Download winutils.exe  ( Put in C:\BigData\Hadoop\bin )  -- This is for 64-bit

Then execute this command:
C:\pathToWinutils\winutils.exe chmod -R 777 \tmp\hive

First task in Spark
(count word and sort them from default file e.g. README.md of spark package):

val textFile = sc.textFile("file:///spark/README.md")
val tokenizedFileData = textFile.flatMap(line => line.split(" "))
val countPrep = tokenizedFileData.map(word => (word, 1))
val counts = countPrep.reduceByKey((accumValue, newValue) => accumValue + newValue)
val sortedCounts = counts.sortBy(kvPair=>kvPair._2, false)
sortedCounts.saveAsTextFile("file:///PluralsightData/ReadMeWordCount")

Then checkout the files part-00000.txt and part-00001.txt stored in ReadMeWordCount folder in your FS.

Try other function on data set
tokenizedFileData.countByValue

Monday, May 16, 2016

Angular 2 - ngConf notes

Codelyzer
Checks your code against A2 Styleguid

Angular.io/resources

Angular Augury