My Sites


Tuesday, April 19, 2016

Set Java 8 Environment in Linux Ubuntu (Quick Essentials)

sudo gedit /etc/profile

JAVA_HOME=/usr/local/java/jdk1.8.0_77
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
JRE_HOME=/usr/local/java/jdk1.8.0_77/jre
PATH=$PATH:$HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

. /etc/profile


sudo nano .bashrc

export JAVA_HOME="/usr/local/java/jdk1.8.0_77/"
export PATH="$JAVA_HOME/bin:$PATH"

source ~/.bashrc

java --version

Wednesday, April 13, 2016

Technology Secrets behind Netflix


Simply for me, Netflix is awesome !! It's not all about the content that has on it, but the amazing technology that Netflix uses behind the curtain. It can be considered as the main leading global content streaming platform. So in North America, Netflix is the 3rd of the consumer internet traffic in peak times. And it has a huge library of content more than a petabyte. (1000 terabytes). Netflix expanded into 130 countries, now reaching just about every nation on Earth. So how are they handling such a huge traffic in a way that the consumers has no disappointment in loading content to their TVs, smartphones , gaming consoles and etc. Let's find out what is there behind the screen. :)

CDN - They have their own CDN which they call it Open Connect. Netflix has this partnership with local Internet Service Providers (ISPs) in order to deliver content efficiently  to their customers. Basically, it is localizing the internet traffic. So during quiet periods between midnight and lunchtime it prepopulates the servers with the content it thinks people will want to watch, reducing bandwidth use in peak hours.
They use FreeBSD as the open source OS, Nginx as the web server which will deliver the content via HTTP to the client application, and also Bird internet routing daemon to enable the transfer of network topology from ISP networks to the Netflix control system that directs clients to sources of content.
Talking about the main technologies,
Node.js is the heart of Netflix which many dependent technologies rely on top of node.js. Let's find out what the dependent technologies they are using.
Restify - Restify is a node.js module built specifically to enable you to build correct REST web services
Falcor - A JavaScript library for efficient data fetching
React.js - A JavaScript library for building user interfaces
NoSQL Databases/Tools used in Netflix - Amazon SimpleDB, Hadoop/Apache HBase and Cassandra.
Memcached- Free & open source, high-performance, distributed memory object caching system
Many microservice REST APIs are written in java and python.
AWS- (EC2 /S3 / Dynamodb/ EMR)
RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
Docker
Titus
Prana
Reactive Socket
Qiro

Reference : http://techblog.netflix.com/
For more info : http://stackshare.io/netflix/netflix

Sunday, April 10, 2016

A Developer guide to design principles and patterns

A design pattern represents a set of guidelines which will help to avoid having a bad software design. The SOLID principle is the best examples for commonly used design principles. 

S - Single Responsibility Principle
O - Open/Closed Principle
L - Liskov Substitution Principle 
I - Interface Segregation Principle
D - Dependency Inversion Principle

Single Responsibility Principle - Classes/ Modules must have only one reason to change. High cohesion should be there, means class should has a single focus and single thing well done. And also a class should be loosely coupled.The single responsibility should be encapsulated by the class.Therefore strive for high cohesion and loosely coupled systems.

Open/Closed Principle - Classes/Modules should be open for extension and closed for modification. That means new behaviour can be added in future but it should not modify the existing source code and make it complex. This embrace to use or reply on abstractions/Interfaces.

Liskov Substitution Principle - Subtypes can be substitutable for their base types. It's about programming to super type. This allows us to use polymorphism in our application.

Interface Segregation Principle - Clients should not be depend on methods that they do not use. Use multiple small cohesive interfaces instead of one big fat interface. Again loosely coupled and high cohesion is embraced.

Dependency Inversion Principle - High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstraction should not depend on details/concrete. And details/concretes must depend on abstractions. Dependency Injection is based on Inversion of control. It is a design pattern which tells how one object knows about its other dependent object. Basically, it is about how components get hold in their dependencies.
Programming to interface not to the implementation.

A design pattern is a general reusable solution , which can be used to solve a problem in our application. It is kind of like a proven template.
Design patterns can be categorized to Creational, Structural, Behavioural, Concurrency and Architectural and etc.

Design pattern common usage
Designing Service Layers - Module Pattern
Overly Complicated Object Interfaces - Façade Pattern

Visibility Into State Changes / Messaging Middlewares - Observer Pattern

What is CommonJS pattern ?

CommonJS pattern in commonly used in many javascript frameworks, libraries and environments. The best example is Node.js. The objective of this pattern is to encapsulate your javascript files into reusable modules so that it can be referenced by other modules.
  • Get reference to dependency
var dependency = require('/path/to/file');
  • Declare Module
var MyModule ={}
  • Expose to others
module.exports = MyModule;

Saturday, April 9, 2016

What is Machine Learning ?

What is actually ML ?

  • We can call it as a sub-filed of Artificial Intelligence.
  • It is basically about predict future. Think like you have a bunch of raw data. Through ML we can create a model which will identify patterns that exist on those data. So when a new data set is entered, the created model will be able to recognize those patterns and predict the future.
  • There are multiple applications of ML, such as detecting credit card fraud, Determining whether a customer likely switches to a competitor. (Customer churn / loss of clients or customers), NLP (Natural language processing) , Computer vision, including object recognition, Robot locomotion , Sentiment analysis, Speech & handwriting recognition, Stock market analysis, Deciding when to do a maintenance on a factory robot.
  • Simply we can describe the process as                                                     A bunch of data --> Identify Patterns --> Create a model (Ability to recognize patterns) --> Predict Future
  • This process is iterative and should be periodically repeated if you want to get a good model.
  • Deep Blue is the first ever chess-playing computer developed by IBM, which I found interesting when it's come to real-world AI . AlphaGo is another fascinating example , which is able to play the board game Go. Nowadays the big topic is Tesla,(electric vehicles manufacturers). They use ML for the auto pilot mode in Tesla model 2/3.
  • There are plenty of open source libraries we can use to implement machine learning, such as scikit learning and Tenserflow.
  • Machine learning is the study of algorithms that learn from examples and experience.
What is a Classifier ?
  • We can call it as a function , it takes some data as input and assigns a label to it as output. Create a classifier by finding patterns in example is called Supervised Learning.Simply supervised learning is the technique to write classifier automatically.

Thursday, April 7, 2016

JavaScript Best Practices

The latest ECMAScript standard defines 7 data types:
  • Six data types that are primitives:
    • Boolean
    • Null
    • Undefined
    • Number
    • String
    • Symbol (new in ECMAScript 6)
  • and Object
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures

best way to check something is available
if(typeof x !== 'undefined'){
    console.log('Exists');
}else{
    console.log('Not Exists');
}

Equality
==   If variables are 2 diffrent types , it will convet them to the same type and check
=== There will be no type conversion

Use === as default.

Node.js ENV variable
Use  node-foremon or nodemon