Tuesday, January 30, 2018

cookie vs token

We all have doubts about what to use when implementing authentication at client side,whether I save the token I get from the server as cookie or should i use the local storage of browser. Here I will point out some of the differences between cookie and token. You can decide what fits more into your application.

Cookie
Token
Automatically included in all requests
We must manually include in the requests
Cookie is unique to each domain. We have different cookies for amazon, eBay, google etc.
We can send token to any domain
Requset:
Headers
Cookie:{}
Body{
Name:’ABc’
}
Requset:
Headers
Authorization:’adbdghgber495yjfkhjhl’
Body{
Name:’AB’
}
Cookies bring state to stateless http protocol



Sunday, December 3, 2017

Setting github webhook on your repository to trigger an action in Jenkins

The following steps show how to trigger a build by using github webhooks in Jenkins. The rpre requirements here are :

  • make sure jenkins in installed and git plugin is installed.
  • git is installed .
  • path of git.exe is valid in jenkins global tool configuration.
Please refer to my other articles if you have trouble in setting up the environment.


  1. open jenkins and click on new item. This would take you to the screen as shown below:
  2. Give a name and select freestyle project.Click Ok. 
  3. This will redirect to another screen.Enter description of the job if needed or else move the source code management section.
  4. Under source code management section select git and paste the git repository url as shown below:
  5. Now if you move to next section you find build triggers , under that select GitHub hook trigger for GITScm polling.
  6. Selecting this, if jenkins will receive PUSH GitHub hook from repo defined in Git SCM section it will trigger Git SCM polling logic.
  7. Now we need to set up webhook on our repositpory. So go to the github repository mentioned above in the git scm section.
  8. When we go to the repository, click on settings and then webhooks. Under webhooks click on add new webhook. The screen should look like this:
  9. Here under the payload URL we need to mention the details of the jenkins service we are running inorder to receive the HTTP POST information from github.com
  10. Here in my case I am running jenkins on my local machine, so I am providing the URL as below:
  11. If you have a secret provided during jenkins installation you can add this here and there is also a flexibility to select on which event we want the webhook to trigger.

In this way, we can setup webhook and trigger build in Jenkins.




Github Webhooks

Consider a situation where you are in an organisation which makes use of GIT source code management and you need to trigger a build only when there is a new commit on the repository, alternatively you may have a build triggerred at any custome interval of your preference but it is a waste of resource if we are building the same source code without any updates.
             The above requirement can be achieved by making use of github webhooks. Github webhooks allow applications to subscribe to certain events on github.com, so whenever one of those events is triggered , a HTTP POST payload is sent to the configured webhooks URL. Webhooks can be used to trigger builds, deploy code to production server, track issues and also send notifications.

Saturday, December 2, 2017

Errror while connecting to a repository in Jenkins

"Failed to connect to repository : Error performing command: git.exe ls-remote -h https://github.com/narendravenkata/React-Demo.git HEAD"




I was getting this error when I installed Jenkins on my windows 10 machine and trying to build my first job.

The error is caused because either git is not installed on your machine or the path of git.exe is not provided correctly.

Solution:
  1. After you install Jenkins, you will be running Jenkins as a service and we can access it at http://localhost:8080/ .
  2. Go to the url and login with the registered credentials.On the left hand side you see a side bar with items and click on Manage Jenkins and go to Global Tool Configuration.
  3. When yo see under git you will have an error like below.
  4. Now as I mentioned earlier we need to specify the correct path of the git.exe.
  5. After we specify the correct path, the error disappears and looks like below.
  6. After the above step ,we can now comfortably add the repository in our job and it looks like below.

In this manner we can resolve the error while adding a git repository in our jenkins job .

Tuesday, September 26, 2017

JavaScript

JavaScript is a lightweight, cross platform, object oriented programming language.

lightweight: it takes very less system memory

cross platform: can be run on multiple platforms and systems

object oriented : js is a language based on object

JavaScript is one of the three core technologies(HTML & CSS)

JavaScript is most commonly used as a part of webpages. It can be used in different places.
  • Client Side : JavaScript was used only in browser  for many years.
  • Server Side : With development of Node.js we are able to use JavaScript in the server side as well.
JavaScript made modern web development possible. With JS we are able to have dynamic effects and are building modern web applications that we can interact with.

Different states of a PROCESS

As a process executes it changes its state. The state of a process is defined in part by the current activity of that process. A process may be in one of the following states.


  • New : The process is being created.
  • Running : Instructions are being executed.
  • Waiting : The process is waiting for some event to occur.
  • Ready: The process is waiting to be assigned to a processor.
  • Terminated: The process has finished execution.

The state diagram gives you the detailed understanding on how the process changes its state.



Monday, September 25, 2017

JSX

JSX - JavaScript Syntax Extension

A preprocessor step that adds XML syntax to javascript.


  • It looks like XML/HTML
  • Defines a familiar syntax to define tree structure with attributes
  • It is not requires but makes things easier while writing react components.

     
The left side represents code written in JSX and right hand side is the corresponding javascript . Just to make a list of four colors you can see the amount of code we have to write if we are not using JSX.

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...