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”

Advertisements
Posted in 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:

1 AND 2 AND 3 AND

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”

Posted in TED Talks

Asking for help is a strength, not a weakness

Enjoyed this TED Talk:
Asking for help is a strength, not a weakness by Michele L. Sullivan

Michele shares her experience how she got help from her family, her friends, her colleagues and many strangers. She is feeling good that she has a friendly support system. She says, “Asking for help is a strength, not a weakness.”

Continue reading “Asking for help is a strength, not a weakness”

Posted in Angular

Make bootstrap button group to work with Angular

Many developers face the trouble to make the Twitter Bootstrap’s button group, toggle buttons to work with Angular. For instance, following is the code for button group – btn-group

<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="options" id="option1" ng-model="radio.btnGroup" value="1"> Radio 1
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option2" ng-model="radio.btnGroup" value="2"> Radio 2
</label>
<label class="btn btn-primary">
<input type="radio" name="options" id="option3" ng-model="radio.btnGroup" value="3"> Radio 3
</label>
</div>

But ng-model doesn’t seem to work with this.

Continue reading “Make bootstrap button group to work with Angular”