Tuesday 4 October 2016

Git Cheatsheet



Git is the open source distributed version control system that allows to perform GitHub activities on your desktop. This cheat sheet summarizes commonly used Git command line instructions for quick reference.

Git cheat list

  • list last 20 hashes in reverse
    git log -n 20 --reverse --format="%h %ae %s" --abbrev-commit
    
  • try a new output for diffing
    git diff --compaction-heuristic ...
             --color-words ...
    
  • enable more thorough comparison
    git config --global diff.algorithm patience
    
  • restoring a file from a certain commit relative to the latest
    git checkout HEAD~<NUMBER> -- <RELATIVE_PATH_TO_FILE>
    
  • restoring a file from a certain commit relative to the given commit
    git checkout <COMMIT_HASH>~<NUMBER> -- <RELATIVE_PATH_TO_FILE>
    
  • restoring a file from a certain commit
    git checkout <COMMIT_HASH> -- <RELATIVE_PATH_TO_FILE>
    
  • creating a diff file from unstaged changes for a specific folder
    git diff -- <RELATIVE_PATH_TO_FOLDER> changes.diff
    
  • applying a diff file
    • go to the root directory of your repository
    • run:  git apply changes.diff 
  • show differences between last commit and currrent changes:
    git difftool -d
    
  • referring to:
    • last commits ... HEAD~1 ...
    • last 3 commits ... HEAD~3 ...
  • show the history of changes of a file
    git log -p -- ./Scripts/Libs/select2.js
    
  • ignoring whitespaces
    git rebase --ignore-whitespace <BRANCH_NAME>
    
  • pulling for fast-forward only (eliminating a chance for unintended merging)
    git pull --ff-only
    
  • list of all tags
    git fetch
    git tag -l
    
  • archive a branch using tags
    git tag <TAG_NAME> <BRANCH_NAME>
    git push origin --tags
    
    you can delete your branch now
  • get a tagged branch
    git checkout -b <BRANCH_NAME> <TAG_NAME>
    
  • list of all branches that haven't been merged to master
    git branch --no-merge master
    
  • enable more elaborate diff algorithm by default
    git config --global diff.algorithm histogram
    
  • list of all developers
    git shortlog -s -n -e
    
  • display graph of branches
    git log --decorate --graph --all --date=relative
    
    or
    git log --decorate --graph --all --oneline 
    
  • remembering the password
    git config --global credential.helper store
    git fetch
    
    the first command tells git to remember the credentials that you are going to provide for the second command
  • path to the global config
    C:\Users\Bykov\.gitconfig
    
  • example of a global config
    [user]
       email = *****
       name = Aleksey Bykov
       password = *****
    [merge]
       tool = p4merge
    [mergetool "p4merge"]
       cmd = p4merge.exe \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"
       path = \"C:/Program Files/Perforce\"
       trustExitCode = false
    [push]
       default = simple
    [diff]
       tool = meld
       compactionHeuristic = true
    [difftool "p4merge"]
       cmd = p4merge.exe \"$LOCAL\" \"$REMOTE\"
       path = C:/Program Files/Perforce/p4merge.exe
    [difftool "meld"]
       cmd = \"C:/Program Files (x86)/Meld/Meld.exe\" \"$LOCAL\" \"$REMOTE\"
       path = C:/Program Files (x86)/Meld/Meld.exe
    
  • viewing differences between current and other branch
    git difftool -d BRANCH_NAME
    
  • viewing differences between current and stash
    git difftool -d stash
    
  • viewing differences between several commits in a diff tool
    git difftool -d HEAD@{2}...HEAD@{0}
    
  • view all global settings
    git config --global -l
    
  • delete tag
    git tag -d my-tag
    git push origin :refs/tags/my-tag
    
  • pushing tags
    git push --tags
    
  • checking the history of a file or a folder
    git log -- <FILE_OR_FOLDER>
    
  • disabling the scroller
    git --no-pager <...>
    
  • who pushed last which branch
    git for-each-ref --format="%(committerdate) %09 %(refname) %09 %(authorname)"
    
  • deleting remote branch
    git push origin :<BRANCH_NAME>
    
  • deleting remote branch localy
    git branch -r -D <BRANCH_NAME>
    
    or to sync with the remote
    git fetch --all --prune
    
  • deleting local branch
    git branch -d <BRANCH_NAME>
    
  • list actual remote branchs
    git ls-remote --heads origin
    
  • list all remote (fetched) branches
    git branch -r
    
  • list all local branches
    git branch -l
    
  • find to which branch a given commit belongs
    git branch --contains <COMMIT>
    
  • updating from a forked repository
    git remote add upstream https://github.com/Microsoft/TypeScript.git
    git fetch upstream
    git rebase upstream/master

References :

https://services.github.com/kit/downloads/github-git-cheat-sheet.pdf 

Sunday 18 September 2016

SOLID Principles


 SOLID Principles are set of rules that Help us to write Better quality of code . By Better quality of code  I mean Code that can talk , Code that is extensible , Code that is loosely coupled , Code that is abstract and secure .

SOLID Principles guide us how we should design our Software / Web Applications . Most of the Unsuccessful Software lack SOLID Principles , How you design / Architecture your Software Defines the Healthy Life Span of your software . If Developers Don't Follow Good Principles Like SOLID etc while coding Software that makes Base of Software week and that kind of Software Surely lacks in Providing High Performance , High Scalability etc .

Why We Need SOLID Principles ?

If you have ever suffered from  Software Performing slow , lagging while operating it . Its a bug in their Software Architecture Design . Its does not matter or you may not know / experience any problem while designing low scalable system for small traffic website but when software usage is increased site needs to be more scalable in that case your code architecture will be tested and It is the case when Design Pattern , Code Architectures and SOLID Principles came into existence 

When Do We Need SOLID Principles ?


I am not saying you should only use SOLID Principles and other Design Patterns and Principles only in large Scale Project .I am just saying their power , performance , scalability came Make Tangible Effect in Large Scale Projects .

MAKE SOLID Principles YOUR HABIT


Real World  Example Why we need SOLID

I love to connect code principles with real world examples that better way to understand them . Real world example for SOLID could be - 

Let say we all have good way of eating , sitting , wearing clothes , behaving with others , respecting others and we all follow our own made these principles both in home , office everywhere so All in All we have made our these rules Our HABITS . that's the thing i wish to say you why adopting these principles is good it is because they will improve our Code pattern and will eventually make our code quality better .

There is no definite tutorial to make code quality better you can only improve by improving your code habits .

SOLID Consist of 5 Principles :- 

1.  Single Responsibility Principle ( SIP )
2.  Open closed principle ( OCP )
3.  Liskov substitution principle ( LSP )
4.  Interface segregation principle ( ISP )
4.  Dependency injection principle ( DIP )

We will be Covering Each SOLID Principle One By One . In that way you will get proper time to reaad blog article and understand it . If you have any question or confusion feel free to comment below . We will start First Principle of SOLID S - SIGNGLE RESPONSIBLITY PRINCIPLE in next post .

Feel Free to Share geeksprogrammings with others .

Sunday 28 August 2016

Medical ATM's In India



Yes, You heard it right 'Medical ATM' . Similar to ATM Machines To Withdraw money Pilot Project for 1 year is launched in India in which Government has provided ATM's to Withdraw their medicines . You will be surprised & having  number of questions in your mind regarding what facility will be provided and how ?

Medical ATM Will Connect Patients To Online-Doctor Who Will Register the Patient and Advice the Machine to Dispense Right Medicine



Major Question in your mind could be Who Will Give Prescription ? Yes , so Under this Project Whenever you visit a doctor you will be get a printed Bill With a Bar Code on it and yes that bar code will contain all information about you prescribed medicines It will act like a Medical Card your all your Health Info and you just need to Show Bar Code on your Medical Slip in front of Bar Code Scanner on ATM then ATM will push our your prescribed medicines to you after collecting money from you .

Isn't this wonderful . Yes , Definitely . Five ATMs have been lauched in four states of India — MP, Himachal Pradesh, Odisha and Andhra Pradesh — under  Health Ministry pilot Project .

India currently has 0.51 doctors per 1,000 population, half the 1:1,000 ratio recommended by World Health Organization. Rural India’s ratio is 0.63 per 10,000. This project is lauched due to massive shortage of doctors in the Country to help some people and fullfill the shortage of doctors on required Locations and Situations .

From call centres, doctors will evaluate the condition of the patient — and if needed they will talk to Patients — and decide whether the person needs to be referred to a Clinic where doctor is available . In the latter case, a prescription will be generated and a command given automatically to the ATM to dispense only the drug prescribed, and no other. The MPHW will explain the dosage to the patient. And in case urgent referral is required, the 108 ambulance service will be made available at the sub-centre.

Every ATM will be managed by  multipurpose public health worker (MPHW) or an auxiliary nurse midwife (ANM) armed with a multi-parameter patient vital monitor and other devices required for checking basic health parameters After successfull registeration of Patient these indicators would be transmitted to a medical call centre through a GSM-based monitor. In Beginning basic health parameters such as temperature, blood pressure, blood glucose and blood haemoglobin will be checked and the data instantly transmitted.

Saturday 27 August 2016

Javascript Event Propagation vs Event PreventDefault


Event Propagation vs Event PreventDefault

Event Propagation

Event Propagation Stops the Event from bubbling or making the event Chain . 

Example : -  A Click Event on a <td> tag will also fire click event on it's parent <tr> and this event chain also continues to parent <table> tag of that <tr> this makes a event chain in order to stop this event Chain propagation we can Use StopPropagation that Prevents this from happening.

StopPropagation ( ) will stop that event from happening on parent (the entire ancestors). When We Use StopPropagation only < td > Event will fire as per our Example above its parent < tr > or            < table > Click event will not fire .

StopPropagation ( ) Tells downward propagation of the event is stopped and also its upward propagation

Event PreventDefault

Event PreventDefault () Prevents the Default Browser Action In Response the Event Triggered . The preventDefault method prevents an event from carrying out its default functionality

Example : If we want to Stop Form Submit on click of Submit Button in form we can use PreventDefault to stop the default form submit behaviour of submit button in form .

As its name tells it just prevent occurence of the default behavior of event like if you need to prevent the click to occur on click event or stop entering of symbols in textbox if its character then make a check it entered character is symbol on keypress press and execute preventdefault ( ) to prevent default behavior of execution of  event on keypress and nothing will enter in textbox if its symbol .



CODE EXAMPLE For StopPropagation


<div onclick='executeParent()'>
<a href='http://google.com'>Click here to visit google.com</a>
</div>
<script>
$('a').click(function(event) {
event.stopPropagation();
$('a').text('Click event is going to be executed');
$('a').contents().unwrap();
});
function executeParent() {
alert('here');
}
</script>


CODE EXPLANATION For StopPropagation


If you execute the code above, the function executeParent() will not be called and you will not get the javascript alert this time. This is due to us having prevented the propagation to the parent div using event.stopPropagation() method. Next you will see the hyperlink ‘Click here to visit google.com‘ replaced by the text ‘Click event is going to be executed‘ and immediately you will be redirected to google.com. This is because we haven’t prevented the default click action from triggering this time using event.preventDefault() method.


CODE EXAMPLE For PreventDefault


<div onclick='executeParent()'>
<a href='http://google.com'>Click here to visit google.com</a>
</div>
<script>
$('a').click(function(event) {
event.preventDefault();
event.stopPropagation();
$('a').text('Click event prevented');
$('a').contents().unwrap();
});
function executeParent() {
alert('here');
}
</script>


CODE EXPLANTION For PreventDefauls

If you execute the code above, the function executeParent() will not be called and you will not get the javascript alert. This is due to us having prevented the propagation to the parent div using event.stopPropagation() method. Next you will see the hyperlink ‘Click here to visit google.com‘ replaced by the text ‘Click event prevented‘ and you will not be redirected to google.com. This is because we have prevented the default click action from triggering this time using event.preventDefault() method.



Javascript Event StopPropagation


Event Propagation

Event Propagation Stops the Event from bubbling or making the event Chain . 

Example : -  A Click Event on a <td> tag will also fire click event on it's parent <tr> and this event chain also continues to parent <table> tag of that <tr> this makes a event chain in order to stop this event Chain propagation we can Use StopPropagation that Prevents this from happening.

StopPropagation ( ) will stop that event from happening on parent (the entire ancestors). When We Use StopPropagation only < td > Event will fire as per our Example above its parent < tr > or            < table > Click event will not fire .

StopPropagation ( ) Tells downward propagation of the event is stopped and also its upward propagation

CODE EXAMPLE 

<div onclick='executeParent()'>
<a href='http://google.com'>Click here to visit google.com</a>
</div>
<script>
$('a').click(function(event) {
event.stopPropagation();
$('a').text('Click event is going to be executed');
$('a').contents().unwrap();
});
function executeParent() {
alert('here');
}
</script>

CODE EXPLANATION
If you execute the code above, the function executeParent() will not be called and you will not get the javascript alert this time. This is due to us having prevented the propagation to the parent div using event.stopPropagation() method. Next you will see the hyperlink ‘Click here to visit google.com‘ replaced by the text ‘Click event is going to be executed‘ and immediately you will be redirected to google.com. This is because we haven’t prevented the default click action from triggering this time using event.preventDefault() method.

Event Prevent Default in Javascript


Event PreventDefault

Event PreventDefault () Prevents the Default Browser Action In Response the Event Triggered . The preventDefault method prevents an event from carrying out its default functionality

Example : If we want to Stop Form Submit on click of Submit Button in form we can use PreventDefault to stop the default form submit behaviour of submit button in form .

As its name tells it just prevent occurence of the default behavior of event like if you need to prevent the click to occur on click event or stop entering of symbols in textbox if its character then make a check it entered character is symbol on keypress press and execute preventdefault ( ) to prevent default behavior of execution of  event on keypress and nothing will enter in textbox if its symbol .

CODE EXAMPLE


<div onclick='executeParent()'>
<a href='http://google.com'>Click here to visit google.com</a>
</div>
<script>
$('a').click(function(event) {
event.preventDefault();
event.stopPropagation();
$('a').text('Click event prevented');
$('a').contents().unwrap();
});
function executeParent() {
alert('here');
}
</script>

CODE EXPLANTION

If you execute the code above, the function executeParent() will not be called and you will not get the javascript alert. This is due to us having prevented the propagation to the parent div using event.stopPropagation() method. Next you will see the hyperlink ‘Click here to visit google.com‘ replaced by the text ‘Click event prevented‘ and you will not be redirected to google.com. This is because we have prevented the default click action from triggering this time using event.preventDefault() method.


Saturday 13 August 2016

Difference Between http get and jsonp


An HTTP GET request is what you get when you enter a URI in your browser or when you click on a link on a web page. Certain HTML elements, like also generate GET requests. GET requests a resource from the server. You can pass additional information to a server-side script by adding 'query parameters' after the script, such as Example Domain.
Say you're on domain www.example.com, and you want to make a request to domainwww.example.net. To do so, you need to cross domain boundaries, a no-no in most of browserland.
Enter JSONP. When you make your request to a server that is JSONP enabled, you pass a special parameter that tells the server a little bit about your page. That way, the server is able to nicely wrap up its response in a way that your page can handle.
For example, say the server expects a parameter called "callback" to enable its JSONP capabilities. Then your request would look like:
  1. http://www.example.net/sample.aspx?callback=mycallback
Without JSONP, this might return some basic JavaScript object, like so:
  1. { foo: 'bar' }
However, with JSONP, when the server receives the "callback" parameter, it wraps up the result a little differently, returning something like this:
  1. mycallback({ foo: 'bar' });
As you can see, it will now invoke the method you specified. So, in your page, you define the callback function:
  1. mycallback = function(data){ alert(data.foo); };
Major issue with JSONP
you lose a lot of control of the request that creates doubts in maintaining security

Thursday 11 August 2016

Angularjs Vs Jquery


Answer Angularjs Vs Jquery On Quora 
Angularjs Vs Jquery

jQuery will be used for things like higher level APIs, updating DOM elements, adding classes and wrapping XHR calls up nicely. Angular 1.x actually uses jQuery lite (jQLite) inside itself, or can use the full jQuery library if it's present before Angular at runtime. Using jQuery with Angular will unleash more power to Angular core as it knows you're using it, so it binds onto jQuery and passes you the full jQuery API instead of it's built-in jQLite.Remember that Angular is a data-binding MVVM framework, of which jQuery is not.

See The Major Benefits in Angular JS as Compared To Jquery

Below is Table List of Difference between jquery and Angularjs . See the Point search what that point means then analyze do you need the power or usage of that point in the project . On the basis of that Analyze Which one of them you need in your project