Its YOU who allows hacker to hack.


It's never the hacker who hacks. It's YOU who allows hacker to hack.

We are emerging into a complete digital world. Just like our House makes us secure, similarly there are some measures to get ourselves secure in this Digital world. So why not to build your digital house with some free tips.

Here are some very simple tips you should follow to avoid any kind of hacking to your account.

1. Always use well known browsers.



Chrome, Firefox, IE, Opera etc. Anyone might download a internet browser may be from some fancy ads, or fun or for experimenting. Never use or browse internet from any other browser. I mean never ever.
* Even Facebook or gmail can be hacked if not adhere to this first tip, not a big deal.

2.Always use latest browser.



How much latest? Most of the  modern browsers auto updates themselves. But check just your browser version once if it is latest or near to latest. If yes, this means your browser is getting auto updated. If no, you need to manually update it daily or figure out why it is not getting updated.



3. Make sure you trust the website you are providing personal information to.



If you think you need to access a website but it is not that famous or trustworthy, you can make a login but never provide any personal information like your phone number or your debit/credit information. You can provide your email but keep one more useless gmail id for such cases.

4. Review your Facebook and Google security settings.


Have a look at these pages:
https://www.facebook.com/help/325807937506242/
and
https://myaccount.google.com/security



5. Never provide information on HTTP



Never ever login or post any information in a website which in unsecured. Secured website starts with https:// and unsecured with http://

6. Always use an anti-virus in your system.



It's good if you have a paid version of any Antivirus, however there are other several antivirus like Panda antivirus which is free.

7. Do not login Facebook, google or wherever you have your accounts through any link.

Facebook - Faecbook 
Orkut - Okrut 
Google - Goolge 

Seems Similar names Eh! 

 If you are not sure about the spelling of the website, use google to search and open that website. For. eg. orkut.com accounts were hacked by okrut.com, the name seems similar but if you look closely r and k are exchanged.



8. Please share this article with your family and friends to contribute for making this world digitally secured.



Virtual Reality - The Future is Now!




In this era of lightening fast technologies, Virtual Reality is a very new and trendy concept. In general, “Virtual” means non-existing and “Reality” means what we experience as human beings. But in technical terms, Virtual Reality is an artificial environment that is created with the software and presented in the way that the user accepts it as a real environment. In other words, Virtual Reality is the use of computer technology which creates the effect of an interactive 3D world in which the objects have a sense of spatial presence.

Even a decade back, you might have seen many movies like "Star Wars" and I remember one of the Backstreet Boys Song - "Larger than Life..". The concept has been there for a very long time. However, the with recent technological advancements, it seems the future is really now!



Education


Virtual Reality is used for teaching and learning concepts. Through this, students can interact with large groups of students within a three-dimensional environment. It represents the complex data in an accessible way so that students can learn things with fun and also interact with objects in this virtual environment in order to discover more about them. For Example, students can learn about a solar system where they can move planets, see around stars and track the progress of a comet.

Business



Virtual Reality is very helpful in the field of Business. It includes many things such as Virtual trips of a business environment; provide complex training sessions to new employees in a virtual environment, 2D/3D view of a product, detecting design problems at an early stage etc. They can test their products in a virtual environment without any risk.


Virtual Museums

Use of virtual reality in the museum and historical settings e.g. visitor centers, interactive exhibitions. Through interactive technologies, children get an amazing experience and encourage them to visit and take part in these activities.

Video Games


Virtual Reality gaming is an entertainment environment where a person can interact with a game. They can detect person’s presence in a game through bio-sensing. These are small sensors which are attached to a data glove; suit so that they can transform your actions into appropriate responses on the screen.

Theme Parks

It makes head-mounted displays. They use high-definition movie screens, booming sounds and motorized seats to simulate adventures into space and beyond. This technology creates virtual reality roll coasters so it provides real-world coaster with a head-mounted display. Riders might be transported to the back of a dragon or other fantastical environments.

Healthcare & Clinical Therapies


Virtual Reality is being used in various medical fields like clinical therapy, anxiety disorder treatment, pain management, phobia treatment, robotic surgery, surgery simulation etc. With the help of HumanSim System, doctors, nurses, and others can learn new skills in a virtual environment and also interact with a patient to detect its problems without harming them. So they get experience with a series of sensors.

Military


Virtual Reality is used in the every field of the Military i.e. Army, Navy and Air Force. This is particularly used for training soldiers for combat and dangerous situations and they have to learn how to react in these situations. Through virtual reality simulation, Soldiers learn many things without the risk of a death or a serious injury. For Example, flight simulators are used to teach flying skills and they learn how to deal with emergency situations. So there are many Military uses of Virtual Reality such as Battlefield Simulation, Virtual boot camp, Vehicle Simulation etc.

Construction


There is an extremely scope of Virtual Reality in the construction field. In the virtual environment, an organization makes a structure in 3D and views a number of factors without the time and cost of the building structure. It is also used to train construction workers and employees so that they can fit in the working environment.


Fashion


Virtual Reality can be used in a variety of ways in Fashion field. It designs VR software for building virtual fashion stores where people can do shopping in a real 3D virtual mall which is designed to resemble a modern shopping mall. Virtual Reality creates 3D avatars to help with clothes design and 3D fashion portfolio. It also helps to arrange fashion show in a virtual environment.

Sports


Virtual Reality is used to give training in many sports such as golf, cycling, skiing, athletics etc. Through this, we can measure the performance of the sportsmen. They can learn various strategies of sports in a virtual 3D environment. It can be used to design sporting clothes and equipment, e.g. running shoe design.


Virtual Reality devices/gadgets

Google Cardboard | Price - Range $14.99 to $29.99


It is a good, justifiable provide virtual reality experience at the best cheapest price. Just pop your Smartphone into a cardboard cutout. It well-equipped with gyroscopes and the displays required for a virtual reality headset.

Oculus Rift VR | Price - Approx $599


Oculus Rift is primarily responsible for bringing on the wave of virtual reality and it comes with a hefty price tag. A resolution of 1080x1200 per eye, a 90Hz refresh rate, a wide field of view, and integrated headphones for a 3D audio effect. It has also rotational and positional tracking system. The approximate price is $599.

Samsung Gear VR | Price - Approx $99.99


Samsung has launched own virtual reality headsets, named Gear VR. It is basically a way to pop in your Samsung Smartphone into it, strap on the headset and experience Virtual Reality. It has various features like 96-degrees of Field of view, support for proximity sensors and an ever-expanding behemoth of content.

HTC Vive | Price - Approx $799


This headset is designed to utilize room-scale technology to turn the room into 3D space via sensors. It allows the users to navigate naturally with the ability of motion tracked handheld controllers to graphically manipulate objects, interact with precision, communicate and getting experience environments. It has various features such as 32-sensors-powered 360-degree motion tracking, 110-degrees field of view, 2160 x 1200 combined resolution and 90Hz refresh rate

Microsoft HoloLens | Price Approx $3000


The Microsoft Hololens is an untethered holographic projection device. It doesn’t require any other third-party software, hardware or platform to operate it. It is a standalone device that could project holographic projections into thin air. It has a 120-degree field of vision and high-definition visuals which provide best holographic computing experience. it is used in various industries like Media & Animation, Mechanical, Healthcare, Architecture, Research, and Automation.

Razer OSVR | Price - Range $199.99 to $299.99


It is an open source platform. It is an ecosystem of hardware and software that aims to create standards for hardware and gaming. This company provides its own SDK for development. It has various features such as 5.5 inches Full HD OLED display, display resolution 1920 x 1080, a gyroscope, a compass and an integrated accelerometer.

Gaming Consoles with Virtual Reality

Sony Playstation VR


It is developed by Sony Interactive Entertainment. It is a home video game console. In this, the player wearing the headset acts separately from other players without the headset. Playstation VR works with either the standard DualShock 4 controller or the PlayStation Move motion controllers. It has 5.7-inch OLED panel, 360-degree vision, display resolution 1080p, 3.5mm headphone jack, 120 frames per second, PlayStation camera, and processor box which is used to enable the Social Screen video output to the television as well as process the 3D audio effect.

3D Virtual Reality VR Box with Bluetooth Joystick Gamepad


This product includes 3D VR GLASSES which is specially designed for Smartphone. It adds great effect so that you feel like your private 3D Cinema and bring great game experience. It is very easy to use by the children, students, travelers and the old age people etc. You just need to put your Smartphone into the relative slot of the 3D VR glasses and you can enjoy 3D movies or 3D games.

Ultragear IPEGA PG-9037 Bluetooth Gamepad with VR


This game controller compatible with Android Smartphone’s, iPhone, iPod and most Android games. It has a telescopic stand where you can be placed your Smartphone in the bracket up to the 6inch screen. With new mouse function, you can watch your smart TV or play the game on the large screen. Bluetooth Ver3.0 wireless transmission covers 6-8 meters wide range of control. It is compact, flexible, easy to control, and portable. It supports various games such as Wild Blood, Dungeon Hunter, Zombie, Shadowgun, Sonic CD etc.

Virtual Reality Table Tennis Video Game


This Virtual Reality Table Tennis Video Game can play on your TV just like you are playing on a table. Two players can play together. There are two Table Tennis bats and a game console with inbuilt games to play. It can be played by kids, youngsters etc. It is motion game and its capacity up to 4GB. It has 1USB port and it supports online connectivity.

Zebronics Gaming Virtual Reality Headset


  1. It supports all Android and iOS Smartphones with screen size up to 14cm (5.5inch). Feature includes:
  2. Ultra-immersive motion sensing game experience
  3. Focal length adjustable
  4. Powerful magnet trigger
  5. Compatible with Google Cardboard
  6. Enough size for wearing glasses, More Comfortable and Durable
  7. 360-degree views, games, video etc.

Future of Virtual Reality

  1. The future of Virtual Reality could be our next computing platform.
  2. It will take a while for Virtual Reality to gain traction like hyped technologies.
  3. It offers a new way of seeing our world.
  4. Virtual Reality could eventually impact all of the senses.
  5. The market potential of Virtual Reality could be huge.

A Quick Guide To CSS3 - Cheat Sheet and Browser Support




CSS3 Cheat Sheet

With this sheet you can quickly refer the properties of different elements or components of a web page. Still it first requires the understanding of what each property do. You can click on the image and save it to your desktop for future references.

(Click to zoom)


CSS3 Browser Support

Almost all modern browsers support CSS3. Still it is important to consider older browsers as well in case we need to fallback to some other alternative to render the css properly. There are various css frameworks like bootstrap and foundation which takes care of this purpose of falling back to other alternative.



To test which all CSS3 properties your browser support, you can visit the below link:
http://css3test.com/

A Quick Guide To CSS3 - 2D and 3D Transformation




CSS3 2D and 3D Transformation

This is one of the most awaiting implementation in terms of creating interactive and real world web pages. CSS has introduced some properties through which we can changes the shape, size and position of the CSS3 elements.
Property Value options
perspective none | number
backface-visibility visible | hidden
transform none | matrix | matrix3d | translate3d | translateX | scale3d |
scaleY | rotate | rotateZ | skew | perspective and so on
perspective-origin x-axis y-axis|initial|inherit;
x-axis - % | left | center | right
y-axis - % | left | center | right
transform-style flat | preserve-3d
transform-origin x-axis y-axis z-axis|initial|inherit;
x-axis - left | center | right | length | %
y-axis - left | center | right | length | %
z-axis - left | center | right | length | %

Example : 2D Transformation
div {
 transform: translate(70px, 110px);
}



Example : 3D Transformation
div {
    transform: rotateX(150deg);
}





Browser Support for 2D Transformation



Browser Support for 3D Transformation




A Quick Guide To CSS3 - Box-model, Selector and Box Layout




CSS3 Box Model

It is one of the most important concept of CSS3. Every HTML element is surrounded by a box weather its a div, span, paragraph, anchor etc. CSS3 Box Model concept revolves around Margin, Border, Padding, and Content of the box. This makes browser takes complete control on how the box and its contents will be rendered on the webpage.


  • The margin is transparent. It clears the area of outside the border. If margin width is 0, then the edge of margin is same as border edge.
  • Border defines the border of the box. If the border width is 0, then the edge of the border is same as padding edge.
  • Padding edge surrounds the box padding. It can be controlled by padding-top, padding-bottom, padding-left and padding-right.
  • Content is the actual area which contains real content of an element. It has color, image or background. We can also set the width, the height of the content box.

Property Value options
height auto | % | length
width auto | % | length
margin margin-bottom | margin-top | margin-right | margin-left
float left | right | none
padding padding-bottom | padding -top | padding -right | padding -left
visibility visible | hidden | collapse
display inline | block | flex | inline-block | inline-table | list-item | table | none | initial | inherit



CSS Selectors

CSS3 Selectors used to select different elements on the webpage and manipulate their properties. There are different selectors with which we can select one or more elements in the webpage.

Selector Description
.<className> It is used to select all elements with .<className> class
#<identifierName> It is used to select all elements with id attribute set to <identifierName>
* It is used to select all elements.
div It is used to select div elements
[attribute] It is used to select all elements with the specified attribute
[attribute=value] It is used to select all elements where the specified attribute is equal to value
a: link It is used to select all unvisited links.
a: active It is used to select the active link and so on.

Box Layout


This property is used to set the layout of the box in the Webpage. It is very new in CSS3. The template is tested to check its compatibility with all requirements on multiple platforms.
Property Value options
box-direction normal | reserve
box-align start | end | center
box-lines single | multiple
box-orient vertical | horizontal | block-axis | inline-axis
box-sizing padding-box | content-box | margin-box | border-box
box-pack start | end | center | justify


A Quick Guide To CSS3 - Border, Font and Text



CSS3 Border

CSS3 borders are used to set the borders of a container which can be div, span, paragraph etc. It includes for different properties left, right, top, bottom in the webpage.

Property Value options
border-style none | hidden | dotted | dashed | double | inset | outset | solid
border-width thin | medium | thick | length
border-color Any color value RGB, Hash etc.
border-radius border-bottom-right-radius | border-top-right-radius |
border-bottom-left-radius | border-top-left-radius

Example
.one {
 border-width: 3px 8px 4px 20px;
 border-style: dashed;
 border-color: yellow green red blue;
}

CSS3 Font

CSS3 Font properties are used to set the font used in different textual components of a webpage.

Property Value options
font-size xx-small | x-small | small | medium | large | x-large | xx-large and so on
font-family family-name | generic family
font-style normal | italic | oblique | inherit
font-weight normal | bold | bolder | lighter | 100 | 200 | 300 and so on
font-variant normal | small-caps | inherit

Example
p {
 font-style: italic;
 font-family: 'Arial';
 font-size: xx-large;
 font-weight: bolder;
 font-variant: small-caps;
}



CSS3 Text

CSS Text properties are used to set the general text properties like we used to do in any text editor like Word. Same textual decorations can be achieved in the webpage with the help of these properties.

Property Value options
text-align start | end | left | right | center | justify
direction rtl | ltr | inherit
letter-spacing normal | length | %
text-decoration none | overline | underline | blink
text-justify auto | inter-cluster | distribute etc
text-outline none | color | length
text-indent length | %
text-shadow none | color | length
text-transform none | uppercase | lowercase | capitalize

Example
p.example {
 text-align: center; 
 text-decoration: blink;
 text-transform: lowercase;
 text-outline: none;
 text-shadow: 2px 3px blue;
}

A Quick Guide To CSS3 - Introduction, Wordwrap and Backgrounds



CSS is an acronym for Cascading Style Sheet.

Cascading  - Declare once use anywhere. Cascade the styling rules to any level, from parent to child level elements.
Style Sheet - Defines style rules.

CSS3 is the extended version of CSS2. CSS3 has arrived with so many new features and enhancements can make any webpage a gem with fewer efforts.

We will cover here CSS selector syntax, properties, browser support, and useful information about its all controls. Its a quick guide so we will cover a more crisp cheat sheet kind of guide rather than the detailed one. To know more about CSS from basic please follow the link -
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics

CSS3 Word Wrap 

Word Wrap is a property of CSS3 that is used to break the words and wrap into next line.

Syntax
Word-wrap : normal | break-word | initial | inherit

Normal - break the line at normal word break points.
Break-word - unbreakable word breaks into a new line.
Initial - used to set a default value.
Inherit - used to take computed value.

Example
p {
    width: 100px;
    background: #70ea70;
    word-wrap: break-word;
}



CSS3 Backgrounds 

These are used to set the various properties of the background of the webpage.

Property Value options
background-image URL | none
background-attachment scroll | fixed
background-image URL | none
background-color color | transparent
background-size length | % | auto | cover | contain
background-position top right | top left | top center | bottom left | center | center right and so on
background-repeat repeat | repeat-x | repeat-y | no-repeat

Example
#back {
 width: 300px; 
 height: 200px;
 background-position: center bottom, left top;
 background-repeat: no-repeat;
 background-color: #90ee90;
}

Next : CSS 3 Borders, Fonts and Text

One time password authentication using Nodejs, passwordless and Twilio



One time password is a high demand authentication functionality in today's time while login into the system, making some transaction or taking some high risk action in the system. It provides an additional security in our application. Passwords can be hacked or guessed that depends on the password security policy of your website. However, the one time password give you a password in your email or your mobile number which can be used one time only and is valid for few minutes. Messages sent to your mobile numbers are secured in a way that you can only see them in your mobile.

Implementing one time password is really simple in Nodejs by using Passwordless and Twilio node packages. Please follow the below steps which will setup your webpage where you can enter your mobile number and then you will receive a 6 digit OTP in your own mobile number. Then you can verify the same and if verified then redirected to the login page.

Create an account in Twilio

Goto twilio.com and create an account by signing up. After this you will be logged in to twilio.

How Twilio works

There is an official description of how Twilio works:


Visit the Twilio's getting started page

Once you login, go to this url
https://www.twilio.com/console/sms/getting-started/basics

In the above page there is a step-by-step demo to create a phone number and send a test sms.
- Note down this phone number.

Note the API credentials

On the same page, click on "Show API credentials" on the right side of the page and note down the these two parameters - Account SID and AUTH Token


Install mongodb in your system (if not already installed).

If you have setup the mongodb without authentication, then your connection string will simply be -
'mongodb://localhost:<port>/passwordless-sms'
Replace <port> with your mongodb port (typically 27017).

If you have setup mongodb with authentication, then your connection string will be -
'mongodb://<dbUserId>:<dbPassword>@localhost:<port>/passwordless-sms'

Replace <port> with mongodb port.
Replace <dbUserId> with mongodb database user id.
Replace <dbPassword> with mongodb database password.

Clone the passwordless example demo Github repo

Clone the following github repo into your system
https://github.com/rbudiharso/smsauth-example


Edit the source code

Open the app.js in your favourite editor and edit the below lines:

Find this lines
accountSid = 'TWILIO_SID' 
and replace the TWILIO_SID with your Account SID which you have noted down before.

Now, find this line
authToken = 'TWILIO_AUTH_TOKEN'
and replace the TWILIO_AUTH_TOKEN with the AUTH Token you noted down before.

Now, find this line 
from: "TWILIO_NUMBER"
and replace the TWILIO_NUMBER with the phone number you noted down before.

Now, find this line
db = 'mongodb://localhost/passwordless-sms';
and replace this mongodb connection string with the connection string you made earlier.

Generating 6 digit OTP

Open nodejs console and go the github repository directory in your system. Execute the below command in console

npm install random-js --save

Open the app.js again find the below function

tokenAlgorithm: function() {
 // custom token generator
 // short random token generator, enough to fit into single SMS
 return '12345'
}

and replace this function with below line of code:

tokenAlgorithm: function() {
 var random = new Random(Random.engines.mt19937().autoSeed());
 console.log(random);
 var value = random.integer(100000, 999999);
 console.log(value);
 return value.toString();
}

Running our app to test

In node console execute the command
node app.js

Open the browser and enter this URL
http://localhost:9000

Type your mobile number with country code. You will receive a 6 digit OTP in your mobile number. Then in next page enter that 6 digit OTP and you will be logged in.

Note : You should also code out the token timeout functionality. When passwordless saves a token in mongodb, its timestamp is also saved. So, while OTP verification, you should get that timestamp and check if it is within range of our timeout setting and throw exception otherwise.

Print reverse level order traversal of Binary Search Tree

struct node
{
 int data;
 struct node* left;
 struct node* right;
};

struct node* newNode(int data)
{
 struct node* temp = (struct node*)malloc(sizeof(struct node));
 temp->data = data;
 temp->left = temp->right = NULL;
 return temp;
}

struct node* insertNodeInBst(struct node* root, int key)
{
 if (root == NULL)
 {
  return newNode(key);
 }
 if (key < root->data)
 {
  root->left = insertNodeInBst(root->left, key);
 }
 else
 {
  root->right = insertNodeInBst(root->right, key);
 }
 return root;
}

int level(struct node* root)
{
 if (root == NULL)
 {
  return 0;
 }
 else
 {
  int lLevel = level(root->left);
  int rLevel = level(root->right);
  if (lLevel > rLevel)
   return (lLevel + 1);
  else
   return (rLevel + 1);
 }
}

void printGivenLevel(struct node* root, int level)
{
 if (root == NULL)
  return;
 if (level == 1)
  printf("%d ", root->data);
 else if (level > 1)
 {
  printGivenLevel(root->left, level - 1);
  printGivenLevel(root->right, level - 1);
 }
}

void reverseLevelOrderTraversal(struct node* root)
{
 int h = level(root);
 int i;
 for (i = h; i >= 1; i--)
 {
  printGivenLevel(root, i);
 }
}

int main()
{
 //Read space separated numbers
 string rawInput;
 vector<string> numbers;
 while (getline(cin, rawInput, ' '))
 {
  numbers.push_back(rawInput);
 }
 
 // Uncomment the below code to Add your inputs here to test without inputting from user
 /*numbers.push_back("5");
 numbers.push_back("4");
 numbers.push_back("3");
 numbers.push_back("9");
 numbers.push_back("1");*/
 
 int key = 0;
 struct node* root = NULL;
 while (!numbers.empty())
 {
  string number = numbers.front();
  key = atoi(number.c_str());
  root = insertNodeInBst(root, key);
  numbers.erase(numbers.begin());
 }

 reverseLevelOrderTraversal(root);
 return 0;
}

Finding largest element in array having first increasing then decreasing elements in O(LogN)

//Array which has n elements in it.
//1st element->a[k] ascending order.
//a[k]->last element descending order.
//Find largest element in this array.
//
//Example :
//1 2 3 4 3 2 1
//Output 4

char calculateOrder(int first, int second, int third)
{
 //desc
 if (second< first && second > third)
 {
  return 'd';
 }
 else if (second > first && second < third)
 {
  return 'a';
 }
 else
 {
  return '0';
 }
}

int CompareThree(int first, int second, int third)
{
 //max of three
 if (first>second && first > third)
  return first;
 else if (second> first && second > third)
  return second;
 else
  return third;
}

void kElement(int arrIntegers[], int left, int right)
{
 int mid = (left + right) / 2;

 //Calculate order of mid-1, mid, mid+1

 char order = calculateOrder(arrIntegers[mid - 1], arrIntegers[mid], arrIntegers[mid + 1]);
 if (order == 'd') //discard right
 {
  kElement(arrIntegers, left, mid);
 }
 else if (order == 'a')
 {
  kElement(arrIntegers, mid, right);
 }
 else
 {
  printf("%d", CompareThree(arrIntegers[left], arrIntegers[mid], arrIntegers[right]));
  return;
 }
}

int main()
{
 int intArray[6] = { 1,2,3,4,3,2 };
 kElement(intArray, 0, 5);
 return 1;
}

Top new features of Angular 4.0





Angular 4.0 is now officially released on 23rd March 2017.
You might probably be wondering it was Angular 2 that was running and now Angular 4. Where has Angular 3 gone?
The answer is much simpler than you might expect. The angular core team have certain components which have been targeted to 4.0 while the Angular core was still in 3.0. These components are necessary angular components and has to be shipped with Angular library. So to cope with this conflict, they have skipped version 3 and target all the components to version 4.0 only.

One of the great thing about Angular 4 is that it is backward compatible with Angular 2.

Angular releases over 2.0

Release Features
2.1 Route Preloading
2.2 Ahead of Time (AOT) + ngUpgrade
2.3 Language Service.
* The language service is useful for IDEs to integrate with Typescript. Its not just they are shipping the compiler. Its been better now to show errors and warnings on the fly.

Angular transition from 2.3 to 3.0

Release Features
Patch 2.3.1 No Features, No Breaking Changes
Minor 2.3.0 New Features, No Breaking changes
Major 3.0.0 New Features, Potential breaking changes

Angular team has clearly mentioned that every release will be - Predictable, Transparent and Incremental. It will not be like what happened when the transition took place from Angular 1 to Angular 2.

Angular 4 future evolution (Tentative schedule)

Angular 5 - September / October 2017
Angular 6 - March 2018
Angular 7 - September/October 2018

Upgrading to Angular 4

It's very easy to upgrade to Angular 4 from Angular 2 app. We just need to run the following commands.

For Mac:

npm install @angular/{common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router,animations}@latest typescript@latest --save 

For Windows:

npm install @angular/common@latest @angular/compiler@latest @angular/compiler-cli@latest @angular/core@latest @angular/forms@latest @angular/http@latest @angular/platform-browser@latest @angular/platform-browser-dynamic@latest @angular/platform-server@latest @angular/router@latest @angular/animations@latest typescript@latest --save

Angular Universal

Now Angular app can be rendered on the server using Angular Universal. For more info check out https://universal.angular.io/

Semver (Semantic Versioning) now

Angular Team will now be using Semver to version their releases. For more details to Semver you can visit http://semver.org/

Angular 4 new features

Animations

Animations now have their own package @angular/platform-browser/animations

Templates

The template tag has been changed to ng-template. The template tag being more generic to other frameworks, Angular has made it to ng-template.

Else is now supported with ngIf 

<div*ngIf="stack.length > 0; else handleBlank"><p>The stack has some elements.</p>
 <ng-template#handleBlank>Stack is empty. Please add some numbers.
the handleBlank is a local reference to the ng-template. We use this reference name in the else clause of the ngIf. The old way will still work.

Typescript 2.2 is supported now.

Since Angular 2 release, the team has made the Angular framework easy to code with Typescript (it can still be used with javascript and dart). Typescript is a syntactical sugar. Typescript 2.2 is supported now in Angular 4. For more info visit https://www.typescriptlang.org/

The 'as' keyword

The 'as' keyword is used to store the output of a result in a temporary variable. For. e.g.
<div ngif="let price of book | currency as LocalPrice; index as = i">
{{i}} ) {{book.Name}} - LocalPrice
</div>

It can effectively be used as an output of async result.
observable_or_promise_expression | async as result
{{result.prop}}

Http

Search parameters have been simplified in http request.
http.get('${apiUrl}/api/getBookInfo', {params : {id : 1} });

In previous version:
const params = new URLSearchParams();
params.append('id', 1);
http.get('${apiUrl}/api/getBookInfo', {search : params });

Pipes

A new pipe has been introduced with the Angular pipes collection that is - titlecase. It changes the first letter of each word to the uppercase. For e.g. the below code will display "Hello World".

<p>{{ 'hello world' | titlecase }}</p>

Test

To override a template in a test has been simplified.

TestBed.overrideTemplate(DialerComponent, '<div>{{dialer.name}}</div>'

In previous version:
TestBed.overrideComponent(SomeComponent, {
 set: {
    template: '<div>Overridden template here</div>'
    // ...
 }
});

Email Validator 

An email validator is introduced along with other validators in Angular. The email validation can be done with Regex, however since email is very frequently used field, so it does make sense to introduce a inbuilt validator for this.

Showing current location in browser using HTML5 Geolocation and Google Maps


HTML5 and Geolocation API

HTML5 comes with Geolocation API which allows user to provide their location to the web application. This is totally secure and user will always be asked for permission whether or not to provide information about their location.

The Geolocation API is provided with navigator.geolocation object of the BOM (Browser Object Model)

Current Position

To obtain the user's current location, you can call the getCurrentPosition() method of the geolocation object. It takes the success function as first parameter which setups position object in the function argument. The second parameter is an error function which setups error object in the function argument.

navigator.geolocation.getCurrentPosition(function(position) {
  
}, function(error) {
  
});

We can get the longitude and latitude from this position object as:
position.coords.latitude 
position.coords.longitude

Watch Position

If the position data changes (either by device movement or if more accurate geo information arrives), you can set up a callback function that is called with that updated position information. This is done using the watchPosition() function, which has the same input parameters as getCurrentPosition().

var watchID = navigator.geolocation.watchPosition(function(position) {
  
});

We can use the watchid value in tandem with the clearWatch() method to stop watching the user's location.

navigator.geolocation.clearWatch(watchID);

Demo Source Code

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

</head>
<body>

<div id="geo-wrapper" width="600" height="400"></div>
<span id="geo-error"></span>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script>
$(function(){
    if(navigator.geolocation)
    {
        navigator.geolocation.getCurrentPosition(show_map,show_map_error);
    }
    else
    {
        $("#geo-error").html('Your browser does not support geolocation.');
    }
});

function show_map(loc){

var lat = loc.coords.latitude;
var lon = loc.coords.longitude;

var lat_lon = new google.maps.LatLng(lat,lon);

mapholder = document.getElementById('geo-wrapper')
    mapholder.style.height = '250px';
    mapholder.style.width = '500px';

var mapOptions = {
    center:lat_lon,
    zoom:14,
    mapTypeId:google.maps.MapTypeId.ROADMAP,
    mapTypeControl:false,
    navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}
}

var map = new google.maps.Map(document.getElementById("geo-wrapper"), mapOptions);
var marker = new google.maps.Marker({position:lat_lon, map:map, title:"You are here.!"});

}

function show_map_error(error){
    var x = document.getElementById("geo-error");
    switch(error.code) {
        case error.PERMISSION_DENIED:
            x.innerHTML = "User denied the request for Geolocation."
            break;
        case error.POSITION_UNAVAILABLE:
            x.innerHTML = "Location information is unavailable."
            break;
        case error.TIMEOUT:
            x.innerHTML = "The request to get user location timed out."
            break;
        case error.UNKNOWN_ERROR:
            x.innerHTML = "An unknown error occurred."
            break;
        }
}

</script>
</body>
</html>

You can get the below code in Github Gist also -
https://gist.github.com/satya-jugran/af36aec8672ce155ee03476bab87da6b

Top features of Visual Studio 2017 you should know


Visual Studio 2017 has arrived with brand new features and enhancements which will make the software development more easier and quicker. With some of its new features, it is going the give a better development experience from it's predecessor's versions. Following are the top introduced and enhanced features of Visual Studio 2017.

You can go through Visual Studio 2017 official home page for detail features description. I have highlighted here those features in short just to have a feel what VS 2017 is providing.

1. Advance IntelliSense

The intellisense has been improved a lot in Visual Studio 2017 with the introduction of prediction algorithm. For example, you can now type "this.LC" and it will show "LoadComplete" in the autocomplete list.



2. Fast Code Navigation

GoTo feature has been improved with fast navigation which will quickly highlight the types and it's references in the code base.


3. Connected Services

With Connected Services, you can see and connect to external could apps more easily. Azure apps, Office 356 and Hockey apps connectivity has been improved to manage your application.


4. Environment Synchronization

It's now more easy to migrate your development environment settings to different workstations. This includes but not limited to settings, preferences and development extensions.

5. Live Code Analysis

No need to integrate with code analysis tools or wait to develop, build and see code analysis errors post build. With live code analysis, the IDE immediately give you the code analysis feedback and suggestions with standard coding style and best coding practices as you write your code.


6. Xamarin Profiler

Building mobile apps in Visual Studio. This feature provides you with an enhance profiler dashboard where in you can see lots of stuffs regarding optimization, memory allocations, performance etc.

7. Debugging

"Run To Click" to execute any line of code without putting a debugging symbol there and "Exception Helper" that provides suggestions about exceptions that might occur at some line of code, has been introduced for better debugging support.



8. Live unit testing

You can setup to run unit test case to run at the background while you are changing your code. This will give you immediate feedback about the test case results.

9. Workloads

Are you installing Visual Studio for a specific work? Just select a specific workload (.Net desktop development, Desktop development with C++, ASP.Net and Web development etc). This will install minimal components required for that workload specific development tasks. It will install very less components as compared to Visual Studio 2015.

10. Developer tools in a nutshell

Integrated powershell, Docker and Continuous integration tools that will give a development team a richer dev experience.

11. Language Improvements

C# 7 : Enhancements in Tuples, expression bodied members, throw expressions, Pattern matching, numeric literal syntax, inline out variables.
C++ : Cross-platform build, Direct-X, latest C++ standards, improved compiler with code analysis, better security.
Typescript : All latest enhancements of Typescript included.
Azure CLI : Better integration with Azure Cloud and apps using Azure CLI.

If you find it useful, please share and subscribe to pass on this information. Thanks!