Wednesday, July 26, 2017

How would you try to save or print a string with escape like this '\' ?

Today I got an issue working with a file path which contains '\' I wanted to save it to the database but I was unable to do.

The path is "C:\Narendra\Work"

Later I tried as "C:\\Narendra\\Work"

Tuesday, July 25, 2017

Monday, July 10, 2017

What is Mocking?

The process of replacing a module with generic and mostly empty object, called a mock.

Advantages:

  • Isolates our code from its dependencies.
  • Write tests with no knowledge of dependencies.
  • No need to change tests after change of dependencies.
  • Reduces false positives.
  • Tests will be less fragile.
  • Easier for other developers to understand.

Tuesday, June 13, 2017

How do you get id of a record newly inserted into the database with only one query .

In my project I was inserting a project into a database and I need to assign the "id" created when project is inserted into database.

r.db("DatabaseName").table("TableName").insert("Values")


{
"deleted": 0 ,
"errors": 0 ,
"generated_keys": [
"6538d988-f8e8-4ab0-bf71-f363fce91b9f"
] ,
"inserted": 1 ,
"replaced": 0 ,
"skipped": 0 ,
"unchanged": 0

}



The query to insert will provide a response as shown above and we can make use of the generated_keys to use for our purpose.

The database used is rethinkdb and query is written in reql language.



Sunday, June 11, 2017

get in rethinkdb

In rethink db when we want to have a row selected we can make use of this get.

table.get(key) will give us a single row. if there are no documents null is returned.

Saturday, June 10, 2017

Building your C# application

I am going to describe how to create a basic C# console application in which we generate a random number and then guess it.Before diving in I am just giving an introduction on C# and .NET and also which tools we will be using in building this application.

          C# is an object oriented programming language created by Microsoft and it is one of the many languages used along with .NET framework. There is generally a confusion between C# and .NET, I will try to clear this. C# is basically a programming language and we use it along with .NET framework to build applications for Windows and we can also use C# to build applications for other platforms like Linux  by making use of Mono, which is a open source implementation of Microsoft .NET Framework.
          .NET is a framework for building windows applications and web applications and this is not limited to one language. We can use C#, VB.Net, F#, C++, J# and many more like around sixty languages. It has two important components say Common Language Run-time and Class Library. CLR is a virtual machine component and manages execution of .NET programs. Common Language Runtime or CLR is the run-time execution environment of .Net Framework. Converting MS-IL into platform or OS specific code is done by the CLR. CLR is responsible for bringing application to life and its also the CLR’s job to tear down application when its finished executing or if it has an unrecoverable error. CLR actively tracks all the memory a program uses and it knows when the program is finished with memory so it will clean things up and allows program to have enough memory as it runs. 

We make use of an IDE(Integrated Development Environment) to build our application. We use Visual Studio (Community edition) as it is free.

First we should decide the algorithm on how we are writing our program. The algorithm is as follows:

1.Generate a random number .
2.Take input from user.
3.Check whether both are equal.
4.Make user know whether value he entered is greater or lesser than the secret number.
5.Continue steps 2 ,3,4 until guess is correct.
6.If user quits close or else continue from step 1 again.

Get Microsoft Visual Studio installed and Create a new project. In creating new project select Console Application and select location where you want
 to save the project.



Once you click on OK you have a new screen with defaults loaded. We have a program.cs file created for us with an empty main method which is our entry point.


Now we can start writing our application. First we need to generate a random number for this we make use of Random class .


After generating this number we should prompt the user to guess a value.


Now we should check whether the guess and secret number are equal or not. We should do this until user enters the correct value.


We should allow user to play the game until he wants to quit.


now the application is done and we can start using it to play with your friends.

Friday, June 9, 2017

Nancy

Nancy is a light-weight ,low ceremony framework for building HTTP-based services on .NET. It provides a super-duper-happy-path to all interactions.

You might be wondering what the super-duper-path is. Here I will explain things clearly.


  • It just works
  • Easily Customizable
  • Low ceremony
  • Low friction

Call a function in child component from parent component in React

Consider the following parent component class Parent extends React.Component { constructor(props) { super(props);         thi...