Pages

Friday, February 3, 2017

Threats for Blockchain

What Is Blockchain

Blockchains, in simple terms are database that maintains a list which is continuously growing and maintain a list of records which is called Chain. Each of the blocks or chain contains a timestamp and a link to the previous block. The blocks are so secured that once the blocks are recorded it cannot be modified. These are open-source agreements or licensed from an independent vendor and are de-centralized software ledgers that make transactions visible to multiple parties.

They are robust and secure and can help speed up business with high security. So there is need of centralized systems maintain by companies and organizations. Many companies and organization like Banks, insurers, shippers etc can use them to set up smart contracts/agreement that automatically respond to events, results into time saving communication and e-mail chains. Blockchain are so secured that hackers cannot take access easily by taking over individual computers in a network.

How does BlockChain security work?

The underlying technology or algorithm behind BlockChain technology is a type of mathematics called RSA Cryptography.
In RSA Cryptography, a Secret Key is created to 'sign' the transactions and a Public Key is created to prove that a transaction was 'signed' by the Secret Key. For example if person X have to pay some amount to person Y then person X will create a transaction for transferring the money form his account to person Y account and will 'sign' it. There will not be a case of any dispute since person X has signed it using his secure key. Any other person can easily identify the transaction by checking the transaction signature against his Public Key, Thus, making it secure transaction.
                                                   A third person or hacker cannot create the transaction or access it without permission; if they intended to do so then they would need the Secret Key. A Hacker need not to access your private residence or place of work to access the key what max can be done is, guessing it! The BlockChain is stored on computer.

Threats

Even though the system is so secured and robust but still there are many threats like.

Quantum Computing 

It is a new type of computer chip which are more powerful and can able to process records much more faster that today’s super computers. BlockChain is secured by some algorithm that assumes that the today’s generation computer will not be able to process the data fast enough which can hack or break the logic behind storing the identity of each block, Therefore, if quantum computing becomes reality, there is a possibility that the system will become powerful enough to process the algorithm which can reveal the identity system of each blocks in BlockChain.
High Speed of Quantum Computing

The current computer processing is handles data using the digital wave, which understand data using signals, either On or Off’ (1-0-1) to store and process data. Whereas Quantum computing uses parts of an atom to store multiple states of signals (on, off and a superposition of both). This is significantly more 'faster' than current computers.

Just to indicate the improvement in speed, there is an exponential link between the size of a printed circuit and its enhancement. Today’s smallest Intel chips on the market are around 15nm. An atom is 0.1nm with its quantum components being tiny fractions of that.
Today, quantum computing is not a practical reality. There are inherent problems with quantum computers, particularly around the stability of data storage in the quantum realm although companies such as Google are working on error-correction systems on these, but, some think it's just a matter of time.


Regulatory

Blockchain has given regulatory something to think about. Regulators are still working out to finalize their approach towards IoT data and payment transfers. Just for example
1. How to go with cross-border payments or transfer.
2. How does the taxation will apply?
3. Who will be responsible for any fraud?
4. How to legalize this kind of transaction etc.

There is still no clarity on this and regulators have to spend a lot of time in regulating these things.


Throughput 

At the moment the speed of this kind of BlockChain or bitcoin transaction is limited 6-7 transaction per second (as per a study), but as we move on, the number of users and the number of transactions will going to increase exponentially. In the Era of superfast network the amount of transaction should not be limited to countable numbers every seconds or minutes. One more risk will be of the security, as more the number of transaction there are more chances of the security risk. The security concern will be major issue as we increase the throughput in BlockChain.


Adoption By Mass 

Even though the BlockChain are getting popularity day by day, but still there are many people who are not aware of this, we have to see that how the people are going to adopt this in their day to day life and what will be the response, till then I think this will remain a potential risk for Blockchain.

I hope you like this post. please provide your valuable comments and suggestion.

Regards
Anil Kumar Pandey


Wednesday, August 26, 2015

What is Node.js???

Hi friends,

Now a days there is a new word in the market called Node.js.

What is node.js?
What is the use of node.js?
How can we use node.js in visual studio?
What are the benefits of using it?

 There are a lot of questions comes in mind.  we will discuss all , but first of all lets find out what do we mean about node.js Node.js is an open source, cross-platform runtime environment for server-side and networking applications.

Node.js® is a platform built on Chrome's JavaScript run time for easily building fast, salable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Node.js is open source, completely free, and used by thousands of developers around the world.

So how node.js is different from the others, to get the details of it lets have a look on the below diagram.



Node.js Vs Traditional 


This means instead of for each process each request node js will serve all the request using a single thread. Node.js operates on a single thread, using non-blocking I/O calls, allowing it to support tens of thousands of concurrent connections without incurring the cost of thread context-switching. The design of sharing a single thread between all the requests means it can be used to build highly concurrent applications. The design goal of a Node.js application is that any function performing I/O must use a callback.

A downside of this approach is that Node.js doesn't allow scaling with the number of CPU cores of the machine it is running on without using an additional module such as cluster,

Following are few of the important features which are making Node.js as the first choice of software architects.

Asynchronous and Event Driven All APIs of Node.js library are asynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

Very Fast Being built on Google Chrome's V8 JavaScript Engine, Node.js library is very fast in code execution.

Single Threaded but highly Scalable - Node.js uses a single threaded model with event looping. Event mechanism helps server to respond in a non-bloking ways and makes server highly scalable as opposed to traditional servers which create limited threads to handle requests. Node.js uses a single threaded program and same program can services much larger number of requests than traditional server like Apache HTTP Server.

No Buffering - Node.js applications never buffer any data. These applications simply output the data in chunks.

So we have now know that where the node,js is ideal. There are also some area where the node.js should not be avoided like

Application with heavy server side processing and business logic

Applications with large \relational database connections.

And large client and server side technology based applications.


Node.js can be installed from below locations

For Windows

For MAC

In windows Use the MSI file and follow the prompts to install the Node.js. By default, the installer uses the Node.js distribution in C:\Program Files\nodejs. The installer should set the C:\Program Files\nodejs\bin directory in window's PATH environment variable. Restart any open command prompts for the change to take effect.


Here is a simple application on Node.js


This simple web server written in Node responds with "Hello World" for every request.

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');

To run the server, put the code into a file example.js and execute it with the node program from the command line:

% node example.js

Server running at http://127.0.0.1:1337/

For tools in Visual studio you can check the below link to get more details. Node.js Tools for Visual Studio

I hope you all have got some basic information about Node.js. I will come up with some more details and sample code in Node.js in the coming articles. For any more details you can directly visit the official site of Node.js  https://nodejs.org/



Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM



Wednesday, April 29, 2015

Filters In Angular JS



Filters are the way to format data in certain order, type to be displayed on the View. Angular filters are one of the cool concepts to work with. They are great; they're very powerful for transforming our data so easily into reusable and scalable little chunks. Filters help in picking out the data in our style or format. The API for the filters in Angular JS is filterProvider.

How To Add Filters:

A filter can be added in the Expression using the Pipe (|) symbol.  It is a reserved operator which denoted that we are applying filters for the expression.

<p>The name is {{ UserName | uppercase }}</p>

Usage:

We can Use the filter either in HTML Expression on using Javascript. Here are the samples for them
 {{ expression | filter : expression : comparator}}

In Javascript

$filter('filter') (array, expression, comparator)

Using Multiple Filters

Multiple filters can be applied using PIPE (|) separation as below

                {{ expression | filter1 | filter2 | ... }}

If we have to pass arguments to these filters then we can pass them using the Colon (:) Symbol

{{ expression | filter:argument1:argument2:... }}

Some Common Filter used for data transformation are

  1. Currency : Used to format data in currency format.
  
<div ng-app="" ng-controller="currencyCtrl">
<input type="number" ng-model="quantity">
<input type="number" ng-model="price">
<p> Total = {{ (quantity * price) | currency }} </p>
</div>


  1. Data Filter :  These filter are used to filter some subset of data from a given set of data.
<body ng-app="TestApp">
  <div ng-controller="TestCtrl">
    <form class="form-inline">
      <input ng-model="Search" type="text"
        placeholder="Filter by" autofocus>
    </form>
    <ul ng-repeat="customers in customers | filter:search | orderBy: 'name' ">
      <li>{{customer.name}}</li>
    </ul>
  </div>
</body>


  1. Upper and Lower case filter
<div ng-app="" ng-controller=" TestCtrl ">
<p>The name is {{ Name | uppercase }}</p>
</div>

<div ng-app="" ng-controller=" TestCtrl ">
<p>The name is {{ Name | lowercase }}</p>
</div>


  1. Order by :  These can be applied to sort the filter data
<body ng-app="TestApp">
  <div ng-controller="TestCtrl">
    <form class="form-inline">
      <input ng-model="Search" type="text"  placeholder="Filter by" autofocus>
    </form>
    <ul ng-repeat="customers in customers | filter:search | orderBy: 'name' ">
      <li>{{customer.name}}</li>
    </ul>
  </div>
</body>


  1. LimitTo :  These are used to restrict the value in the expression for example if we want to display only 10 items from collection we can use
<div ng-controller="TestCtrl">
 <li ng-repeat="customer in customers | limitTo:10 ">
</div>

  1. Date
<div>
   <p class="OrderDate">Items Order On: {{item.dateOrdered | date:'dd/MM/yy'}}</p>
</div>

  1. Number:  To restrict the decimal value to certain place we set this filter so that the No of decimal will appear accordingly.
<div>    
        <p class="itemPrice">{{item.price | number:2 }}</p>
                <p> {{item.description}}</p>
</div>


  1. Custom Filter :   We can create custom filter by adding and using existing filters in combination. Here is a sample code for it.
<div ng-controller="TestController">
  <input ng-model="CustomTest" type="text"><br> 
  Reverse String: {{CustomTest|reverse}}<br>
  Reverse string in uppercase: {{CustomTest|reverse:true}}<br>
</div>


Hope you all like this piece of information. Filter is very powerful way for the data formatting using Angular JS. Please provide your feedback or comment so that I can improve further. I will come up with some more points in Angular JS soon.

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM



Wednesday, March 11, 2015

Visual Studio 2015 CTP 5

Visual Studio 2015

Last week the Preview for Visual studio 2015 for Community user is released. Multiple innovative Ideas and featured has been included in it. Which include update in ASP.Net as well. I have tried to summarize some of the Key feature for this CTP release. Some of the key features are listed below.
  1. UI Debugging  :       There are 2 new tools are added for XAML UI debugging named as
    1.  Live Visual Tree
            This feature allows us to view the complete visual tree while we are debugging a code. We can select any element from the visual tree and use the live property to view respective property of that control or element.
    1.  Live Property Explorer
This feature enables us view the property of the element in XAML while we are debugging the code. We can set some changes immediately and can view the effect.
  1. Single Sign On :      This is mainly deals when we are using any cloud environment for example either for our data base or our code base. In this situation we would require to sign on all the application. With this new Single Sign On feature the single signing in in application will allows us smooth access for all our application and environments.

  1. CodeLense :            This is a very interesting tool added in VS 2015, with the help of CodeLense we can any time check the History or version of our C++, SQL and JavaScript file, while we are working on the Editor. The Information related to work items associated with code in TFS can also be viewed with this.






  1. Code Maps:             Maps are the best way to navigate among the dependency for the code. With this feature you can jump between them quickly and even can drag drop, create links between them. You can show or hide code elements on a map based on their category, as well as group code elements by solution folders, assemblies, namespaces, project folders, and types.

  1. Diagnostic Tools:  The Improvement for the Diagnostic tool debugger is done  with 64 bit Windows store app and zoom for most recent event break.


  1. Exception Settings:          The exception related settings can be done using this tool which will not impact in the code and will improve the performance.




7.     Java script Editor:                          As requested earlier there will be a Java script editor which will allows us to use the TASK LIST feature  and the more advanced Intellisence will be available.

  1. Unit Test:                 The improvement towards the Unit testing side is also done. Now we can create Parameterized Unit test means there will be an API available for test data generation and correcting the properties. The Library for this is Microsoft.Pex.Framework.  The Context menu Smart Unit Test will be available.
Along with that the “Create Unit Text” context menu will also be available which will improve the performance by faster addition of test class or test stub.

  1. Android Emulator:            The Emulator will come up with some additional features like  Android 4.3 and 4.4. Along with that the IOS 6, 7 and 8 will also be supported.  Windows Mobile 8.1 will also be supported.

  1. Mobile Development for Cross platform:                Now Visual studio can be used to create mobile application for across the platform with a single solution only.  Android Lollipop API, Android Logcat support is added, using which we can search log message, scroll messaged, can clear previous message and move between various log levels.  We will also get precompiled headers in the template.

  1. ASP.NET :     various new enhancement are done in ASP.NET as well like Run and Debug setting are now captured in debugSetting.jsonIntellisense is more advanced, lot new API templates, Windows PowerShell script can be used and customized for ASP.NET 5. And the long required debugging option for debugger window for LAMBDA expression.



I hope you will enjoy these features. Microsoft has request the community members to use the Windows 2015 and provide there valuable suggestion and feedback along with reporting option for Bug if at all any you find while using visual studio 2015.  You can download the Visual Studio 2015 from the below location. Download.  Please provide your suggestion for the above article and please feel free to share your comments and any question if you are having.

Saturday, February 21, 2015

Code Quality and Test Coverage using NCover

For any Developer the code quality is at most important, every organization put emphasis and focus on a very good code quality whether it is a Product based company or a service organization. All the process which we follow to improve the Quality are mainly focused on finding defect if at all any present in the code and fixing them ASAP.

Now days everyone is going for agile methodology, which is one of the best methodology to improve the code quality and deliver highly efficient code. Agile also force to make most of the automation test so that in a quick time limit we can have maximum code tested.

Then the Question arises:-

How much code is covered in or test case?

How Can I Cover entire code in test case?

What can be done to reduce less tested code?

In this case we go for a Test coverage tool or option which will give some figures and facts that how much percentage of the code is tested, covered and left untouched. There are a l lot of statistics and measurement required to baseline the approach and finalize that we are having maximum code coverage.

There are a lot of test coverage tools are present in the market. Recently I came across one of them and I was really happy with the result it has given to me. That tool is NCover. NCover provides a very powerful and flexible tool set which can integrate into your build process and help you deliver higher quality code. The flexibility provided by the NCover tools may seem a little intimidating at first, but with a little experimentation it is easy integrate NCover with any build process. 

The latest version of NCover is NCover 5. I have tried this application with some of my application and I am pleased with the kind of response it has given to me. Some of the latest features added in NCover 5 are


      1.       Improved static analysis for expanded merging

2.       Public browsing of code central projects

3.       Enhancements to ncover user interface
 
4.       Pre-instrumentation
 
5.       Coverage for windows store apps
 
6.       Condition coverage
 
7.       Baseline executions
 
8.       Self-contained html report
 
9.       Expanded coverage data exporting
 
10.   Visual studio theme support
 
11.   Expanded test runner support
 
12.   Improved bolt performance




Implementing Code Coverage using NCover.


NCover performs analysis on code by instrumenting it behind the scenes while the tests are running. If using NUnit as the unit testing tool, simply prefix the NUnit command line with the NCover command.
NUnit command line:

nunit-console MyTests.dll

NUnit with NCover:

NCover.Console nunit-console MyTests.dll

It's easy enough to create code coverage data, but analysis is where you actually begin to improve your tests. We include NCoverExplorer with NCover for this purpose. NCoverExplorer highlights those lines of your code that are uncovered, and does statistical analysis of your coverage data as well. It can even run a program and collect coverage data for you, so many developers never touch the command line version of NCover. NCover also includes an HTML reporting feature for teams that want to generate analysis reports including highlighted code directly from their continuous integration server


Some of the GUI option for NCover are








You can download the Trail version from Below location. NCover Download. For more details Please visit the below location. https://www.ncover.com/support/docs/index.  I  hope you will like using this tool and improve the quality of the code. Please provide your feed back for this article or any more support on the NCover tool. I will try to resolve them or will take them directly to the NCover team.

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM




Wednesday, October 1, 2014

Constraints in Attribute Based Routing MVC5

In the previous article we have discussed about the attribute based Routing where the Routes can be specified directly above the Action method or Controller class itself. Now going ahead we will discuss about the Constrained that can be used in the Route.

Constraints are nothing but the validation which we can directly apply on the action methods using the Attribute based routing. With this you also gain the ability to validate your actions more like function overrides, a route will only be matched if the data type matches or the validation we have applied otherwise the request will fall through to the next route matching the pattern, looking for a supported data type.

Some of the common and widely used Constraints are as follows.

Data Type Related

[Route("MyRoute/{x:int}")]  // Matches 32 Bit integer value
public User GetUserById(int id) { ... }
 

[Route("MyRoute/{x:long}")]  // Matches 64 Bit integer value
public User GetUserById(long id) { ... }


[Route("MyRoute/{x:float}")]  // Matches 32 Bit floating point value
public User GetUserById(float id) { ... }


 [Route("MyRoute/{x:double}")]  // Matches 64 Bit floating point value
public User GetUserById(double id) { ... }

[Route("MyRoute/{x:decimal}")]  // Matches a decimal value
public User GetUserById(decimal id) { ... }


[Route("MyRoute/{x:bool}")]  // Matches a boolean value
public User GetUserByCondition(bool id) { ... }


[Route("MyRoute/{x:guid}")] // Matches a Unique Identifier value
public User GetUserById(GUID id) { ... }
 

[Route("MyRoute/{x:datetime}")]  // Matches a datetime value
public User GetUserByIdLoginTime(datetime id) { ... }
 

String Related Constraints 

[Route("MyRoute/{x:alpha}")]  // Matches upper and lower case value from a-z
public User GetUserByName(string id) { ... }
 
[Route("MyRoute/{x:length(5)}")]  // Matchesstring value with specified length
public User GetUserByName(string id) { ... }
 
[Route("MyRoute/{x:length(2,100)}")]  // Matches string value with specified length range
public User SetUserByName(string id) { .. }


[Route("MyRoute/{x:minlength(8)}")]  // Matches a string with minimum specified length
public User SetUserByName(string id) { ... }
                                                  

[Route("MyRoute/{x:maxlength(20)}")]  // Matches a string value with specified maximum length
public User SetUserByName(string id) { ... }
 

Other Common Constraints

[Route("MyRoute/{x:min(1)}")]  // Matches integer value with minimum specified value
public Product GetAmount(int id) { ... }
 

[Route("MyRoute/{x:max (100)}")]  // Matches integer with specified maximum value
public Product GetAmount(int id) { ... }
 

[Route("MyRoute/{x:range(1, 100)}")]  // Matches integer with specified range of value
public Product GetProducts(int id) { ... }


[Route("MyRoute/{x:regex(^[a-z][0-9]$)}")]  // Matches value with specified regular expression
public Product GetProducts(int id) { ... }
 

[Route("QuerystringParameterExists?{X})]  // Matched Query string parameter if it exist or not
public Product GetProducts(int id) { ... }


[Route("QuerystringParameterConstraints{x:int}&{y:int}")]  // Matched Query string parameter if they are of specified type or not
public Product GetProducts(int id) { ... }
 

Custom Route Constraints

You can create custom route constraints by implementing the IHttpRouteConstraint interface. For example, the following constraint restricts a parameter to a set of predefined values.


public class CorrectConstraint: IRouteConstraint
{
   private readonly string[] correctOptions;
   public CorrectConstraint(string strOptions)
   {
        correctOptions = strOptions.Split('#');
    }

p        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
           {
                 object value;
                 if (values.TryGetValue(parameterName, out value) && value != null)
                     {
                  return correctOptions.Contains(value.ToString(), StringComparer.OrdinalIgnoreCase);
                  return false;
             }
}


     To register this value in the Constraint we have to add the code in the Route config as below.

      public static void RegisterRoutes(RouteCollection routes)
       {
               routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        var constraintsResolver = new DefaultInlineConstraintResolver();
        constraintsResolver.ConstraintMap.Add("values", typeof(ValuesConstraint));
        routes.MapMvcAttributeRoutes(constraintsResolver);
  }


And the Route can be called as  below.

     public class BusinessController : Controller
       {
             [Route("ValidRange/{SetValue:values(23#32#34#4435#54#65)}")]
             public ActionResult Show(string scale)
              {
                 return Content("Valid set of value is " + scale);
       }
}

Hope you now Understand that how the constraints in the Attribute based route can be used and applied and how can we create a custom base Route.  Please feel free to provide your valuable comment on the same.

Thanks & Regards
Anil Kumar Pandey
Microsoft MVP, Microsoft MCC, DNS MVM



Kontera