Posted in GIT

Git revert back to older commit

You have multiple commits in a branch but all gone wrong somehow and now you want to revert back to a specific commit. This is how you do:

Situation 1: Reverting to older commit

Danger Alert: All your uncommitted changes will be lost doing this. If you have such, prefer next situation.

git reset --hard <commit_code>
git commit -m "Reverted to <commit_code>"

Replace <commit_code> with your commit SHA Eg. 9acbb770

Continue reading “Git revert back to older commit”

Posted in Angular, Code Snippets

AngularJS – UI-Router : Multiple states with same URL

Usually, with angular ui-router, we can have one url for a single state something like this:

.state('app', {
  url: "/home",
  templateUrl: "....",
  controller: "myController",
  roles: ['administrator','authenticated']

Continue reading “AngularJS – UI-Router : Multiple states with same URL”

Posted in Code Snippets, PHP

PHP: Implode or Trim – Concatenating strings in a loop

There are bunch of questions circulating in Stack Overflow like this. People when trying to concatenate some strings with another string or a character, they simply concatenate with . inside the loop like this:

$values = [1, 2, 3];
$string = '';
foreach ($values as $value) {
   $string .= $value . " AND ";
echo $string;

This leaves string like this:


Then they come up with a question as how to remove the last AND.

Continue reading “PHP: Implode or Trim – Concatenating strings in a loop”