Thursday 12 November 2015

How Formatted drives or Deleted files and folders are easily recovered from Hard disk ,Pen drive, Memory cards

In this post we are going to see why deleted files and folders are recovered from Hard disk and pendrive. Let we see first what are the different types of disk present. HDD and SSD are the two types present to store a data, 

HDD is the Hard disk Drive which have a plate of Disk coated with magnetic.

                                          


SSD is a Solid State Drive which doesn't have the plates to store the data instead it have a memory chips integrated with the board or separated.

                                          

All the Data are stored in the format of 1's and 0's.

Both the Drive are used to store the data.Now let we see how the operating system are works. Normally when ever users store a data in Drives, it will store the records  in the drive and make a entry in the Sectors table, about the Files and Folders, So File systesm have a pointer to each file in the sector table and have the information about the File like length, start index and end index, name etc

Whenever you give a delete to the File , Operating system checks the File in the Sector table and removes the pointer to the File,and mark the space for available for another write, so now what happens the data is actually present in the disk, but the Pointer to the data is removed from the sector, Again if some file are stored in the Computer now , operating system checks for the available space and make a entry to the Drive, if the storage space is marked for deleted, then it's overwrite the data and make a new entry in sector. Now the existing data is partially over written by another data.

There is a chance that sometimes  storage is not used by file system, so existing data will be available in Hard disk.Now if we have recover tool we can recover the whole data stored in Hard disk, What recover tool will do is read the drive information and gives data So every time if you don't want  others to recover your files from drive then delete it permanently,  

Now days some SSD have a trim concepts that is you cant recover the deleted data, because whenever deletion happens it removes the pointer as well as delete the storage by overwriting the data with empty spaces are full of Zero's.

Keep one thing in mind that Deletion also takes the almost same time as copying because it rewrite the every single block of storage.

Now days because of these reasons only many person's personnel information are recovered by third persons easily form there Hard disk, memory chips and pen drives, Because end users doesn't have knowledge of  concept of storing records in the Drives, so whenever they delete a file or folder , they thought it is deleted from disk or drive, but actually they doesn't that it is retained there in the blocks of actual storage,they doesn't know that only the pointer are removed from the sectors for that file . 

We can easily recover the data from the formatted Drive also, i am also recovered data from my formatted hard disk many times by myself. So Formatting drives also doesn't remove the records,it also can give back your stored data when you tried recover.


So every time while you delete a file or giving the Hard drive to others persons. Delete the data's permanently from the storage. Because it will safe for you as well as for confidential document like PDF, DOC, .music's , videos, etc .. every single block storage files can be recovered from  drives. because every data is 0's and 1's


Now most of the companies are providing the Recover software for the storage Drives while buying itself. From this post you may know why the deleted files are recovered easily from Hard drive or Pen drive or Memory sticks 


Wednesday 11 November 2015

Create a directive which will track the model changes and acts as a Converters between the View and the Model using $parsers and $formatters

In this post we are going to see how to create a converters between the View and the Model in angular js. For this we take an example that maintain a history in the model like oldvalue and newvalue in model, but display the newvalue in the view, how we can do this ? This can be only done by the directive which have implemented the ng-model.

Let we see in example: 
We are going to create a Directive which will tracking the model changes .... Let name it as track-change.

First we understand about the $parsers and $formatters.

$parsers : which consists of a collection of functions, where executes when the value  changes in the View. 
                   ie. View -> Model

$formatters: which consists of a collection of functions, where executes when the value changes in the model
                      i.e Model - . View

Now we create a Directive which will track the elements by maintaining the NewValue and OldValue.

Directive:




Controller:
*************************

appRoot.controller('MainController', function ($scope) {
    'use strict';   
     $scope.Product = {};
    
     $scope.sourceList = [{"id":1,"name":"Apple"},
                          {"id":2,"name":"Orange"},
                          {"id":3,"name":"Banana"},
                          {"id":4,"name":"Papaya"},
                          {"id":5,"name":"Jackfruit"}];
    $scope.Product.Selected = $scope.sourceList[0];
    
});




Html:
*************
Use the track-change directive in tag that you implement the ng-model, in this example i am used in select , where whenever user selects the new value, old value is retained in OldValue property, you can see the Model that maintains the history, but in view when we bind it shows only the latest value ,This is because of $formatters.




Output:
*******************




Full Code:
*********************

appRoot.directive('trackChange',function(){
    return{
        restrict:'A',
        require:'ngModel',
        link:function(scope,element,attrs,ngModel){
            
            var historyObject = {NewValue:undefined,OldValue:undefined};
            var OldValue = {};
            var NewValue = {};
            ngModel.$formatters.push(function(value){
                if(historyObject.NewValue!=undefined)
                    return historyObject.NewValue;
                if(value!=undefined){
                    historyObject.NewValue = value;
                }
                return value;
            });
            
            ngModel.$parsers.push(function(value){             
                
                historyObject.OldValue = historyObject.NewValue;;
                historyObject.NewValue =  value;
                ngModel.$setViewValue(historyObject.NewValue);
                ngModel.$render();
                ngModel.$setValidity('is_valid',true);
                return historyObject;
            });
            
        }
    }
})

var appRoot = angular.module('appRoot',[]);

appRoot.controller('MainController', function ($scope) {
    'use strict';   
     $scope.Product = {};
    
     $scope.sourceList = [{"id":1,"name":"Apple"},
                          {"id":2,"name":"Orange"},
                          {"id":3,"name":"Banana"},
                          {"id":4,"name":"Papaya"},
                          {"id":5,"name":"Jackfruit"}];
    $scope.Product.Selected = $scope.sourceList[0];
    
});

<div ng-app="appRoot">
    <div style="margin-left:40px;" ng-controller="MainController">
      
        <br />
        <select ng-change="modelChange()" track-change="" ng-model="Product.Selected" 
                ng-options="prod.name for prod in sourceList" >
        </select>  
        <span style="color:orange">[[Product.Selected]]</span>
</div>
</div>


From this post you can learn how to create a Directive which will track the model changes and acts as a Converters between the View and Model using $parsers and $formatters.

Sunday 8 November 2015

Visibility of the Factory across the modules in angular Js

In this post we are going to see the visibility of Factory across the modules in angular Js, Generally whenever we create a factory we will inject the dependencies for that factory,If the Dependency is from another Module,then we will inject that module to the Factory related module, But instead of doing like we can get the Visiblity of that module while injecting from the root module and we can get the instance across the module.

For Example: Let we take two difference modules Department and Employees. Each module have a Factory

Department - > Factory Development

Employees -> Factory Developer   (Depends on the Development Factory needs Department module to be injected), But instead of inject the module, we are injecting the  Development Factory to Developer Factory, Later in the main module we are injecting the all module, so now the visiblity of Deparment module is across the modules.

App.Js
*****************











Html:
**************




Output:
**************





From this post you can learn the visibility of the modules in angular js.


How to declare the Constants in the Angular JS

In this post we are going to see how to create a constants in angular js. Any programming language have declaration of constants, because it can be used any where with out change in the value. likewise we can use the constants in the Angular JS





From the above example you can see the Version and Name are declare as constant inside a method , it can be access using the instance Application. Later the Constant is injected in to the controller and access the variable which is required from the package. Now inside the Maincontroller it is assigned in the new variables and uses in the Footer tag.
In the above code i interpolated the symbol to [[ ]] from  {{ }}, that is why the expression is written as like that [[Name]] @ [[Version]]

Output:
************

Angular Sample @ 1.0.0.0


From this post you can learn how to use the constants in angular js.

Change the default Symbol of evaluate expression in angular js

In this post we are going to see how to change the symbol of evaluate expression in Angular Js. Generally in angular js expression are evaluated when it is placed inside the curly braces,It is a default one,But it can be changed we can set the symbol whatever we want. For example we can change the symbol from {{ }} braces to [[ ]] braces

How to do that ? using interpolateProvider
We have to register the interpolateProvider with Start Symbol and End Symbol.




From the sample you can see how to change the symbol of evaluate expression in angular js.

usage of Run method in the Angular JS

In this post we are going to see what is the usage of Run method in the Angular Js. Normally this method is used to Register any component or assign any variable before the Bootstrap of a application. i.e it is run at before the Application bootstraps.




In the above example you may notice that the Variable Project is assigned in the $rootScope. Then the Variable is rendered in the h1 tag. we can able to get the value of project after the bootstrap, but value is initialized before the application bootstrap


Output:
**********


From this post you may understand what is the usage of Run method in the Angular Js.