Working with branch in GIT

A strong point in GIT is so flexible when working with branch. So now I will share some GIT commands that usually use when working with branch.


You never know how strong you are until being strong is the ONLY option you have


In software development process, when your production was go live, you should create new branch for each issue. And after finishing a issue you should merge code carefully.

List all branch of repository (both local and remote)

Checkout code from a remote branch

Update code from all remote branch

Merge code between two branch

Merge specify commit to branch:

Create branch from previous comit

Checkout specify file from other branch:


AngularJS change image style after loaded

Sometimes you need place image at center of div tag. The script below will help you calculate the size of image and change margin-top to set image into right position.

It is AngularJS and CoffeeScript


Fix “Position Fixed” in Phonegap IOS App

When I build a Phonegap App on IOS that has header and footer with “position fixed”. Everything works well on web version, and I start to test IOS app version, it seems work well too. But a problem orcurs when virtual keyboard opens and close, then the layout breaks (“position fixed”  of header and footer does not work). I took 2 hours to research and google. Finally, I work out a solution, it is quite simple. I just set “position static” for header footer when virtual keyboard close (input blur event) and set  a time out about 200 miliseconds to change back “position fixed”, the layout will be perfect again. The below is my code, you will be easy to understand it if you ever work with angularjs, coffeescript

[Linux] Convert SVG to PNG with background transparent

As you know, ImageMagicK is powerfully library on linux, that is used to convert or edit image.

Now, It is small command to help you convert all svg file in directory to png file with transparent background

Please make note that ImageMagick was installed on you linux.

With Ubuntu, you can use command below to install ImageMagick

It is simple.

AngularJS Datetime Format

When you use angularJS to build an app at client-side, a issue frequently orcur is datetime format.  My post will share with you the way that angularjs support you customize datetime format.

– Customize datetime format in controller (AngularJS):

Note: Please do not forget to inject $filter to your controller

– Customize datetime format in views (AngularJS):

Note: item_date is datetime with microsecond unixtimestamp format. E.g, 1288323623006

Actually, you can use raw javascript to customize your datetime format as the below way:

But my advice for you is if your project use AngularJS, you should not use raw javascript to cutomize datetime format, because in some cases, it will not work on Safari browser.



Cookies or LocalStorage Service in AngularJS

When you develop a web application, sometimes you need store data in client-side. In this case, you can use cookies or local storage. Some browsers do not support local storage (eg. IE 7,8), you should use cookies, but if you are building a phonegap application, local storage is unique choice.

The below code is coffee scripts, this is an anglarjs service that you can use to get, set or remove data from/to local storage.

And the below is an AngularJS service that will write data to cookies for the case the browser does not support local storage.


PHP LinkedIn Oauth2 Example

The source code below implements 3 steps to get user information from LinkedIn.

Step 1: Start authorization process

Step 2: Get access token

Step 3: Fetch user information (user name, first name, last name …)


Backup all databases of MYSQL

This is small tip to help you backup all database mysql by one command. And you also can use this command to backup database every night.

Using the command below:

Or using crontab to backup database every day:


[.vimrc] Add key map to comment out your code

Some times you want to add a comment to let who read your code will  understand easier. It is easy way to let every one who read your code know who and what time you did it

This tip will help do that. You just need to add the below code to [ .vimrc]. If you are using Ubuntu like me, the vimrc file will locate at / home/son.nguyen


How to GIT

As you know, with GIT,  you can setup a social network for developer. Everyone in everywhere can code your project, as long as they know how to use git.

How to push your change to remote

How to create new branch in local

How to switch branch

How to create new branch in remote

How to delete branch in local

How to delete branch in remote

How to merge 2 branches in remote


How to revert changes before add

How to remove file in remote

How to remove folder in remote


How to show git history

How to ‘undo’ git commit

How to ‘undo’ git add

How to ‘undo’ git push

How to add a tag

How to delete a tag in local

How to push a tag to remote


How to checkout to tag

How to delete a tag in remote

How to checkout a remote branch

How to edit a commit message

How to revert changes in local

How to list of file changes

How to pull a git branch from remote

How to ignore file locally

Move a tag