Pages

Thursday, August 7, 2014

Change the name of remote git branch

Warning: Reader is strongly encouraged to take a backup of the local repository before performing the steps mentioned in this post.

This post is intended to guide the reader about how to change the name of a remote branch in Github. Suppose there is a branch named feature/branch_a, and it is to be renamed to test/branch_a. The initial remote and local repositories may look something like this:

Remote:

enter image description here

Local:

enter image description here
* Command(s):
-  git branch -v (Shows a list of all branches, with current branch highlighted)

With the branch feature/branch_a checked out, create a new branch with the name test/branch_a.

enter image description here
* Command(s):
-  git branch -v (Shows a list of all branches, with current branch highlighted)
-  git checkout -b test/branch_a (Creates a new branch and at the same time switches to the branch)

Push the branch on the remote server, and then delete the older branch from both remote and local repositories.

enter image description here
* Command(s):
-  git push --set-upstream origin test/branch_a (link locally create branch to the remote server, and push it)
-  git push origin :feature/branch_a test/branch_a (Deletes branch from remote and replaces it with the new one)

That is it! You are good to go.

enter image description here

Enjoy!

Thursday, July 31, 2014

Use Jekyll to create a blog and host it on Github

Github is an attractive option for hosting a technical blog. The process is as simple as creating a repository, and adding index.html to it. Details can be looked up at https://pages.github.com/. Github uses Jekyll to generate the site. Jekyll is a simple, blog aware, static site generator. Using markup for the blog entries is one of the features of Jekyll. The installation can be done via gem ruby tool. http://jekyllrb.com/docs/quickstart/
Once installed, follow the following steps:
  • Clone the github page repository.
    git clone abc.github.io
  • Create a new file in the local git repository.
    touch Gemfile
  • Edit the file and put the following lines in it.
    source 'https://rubygems.org'
    gem 'github-pages'
  • Install Bundler http://bundler.io/
    gem install bundler
    bundle install
  • To run Jekyll with Bundler, issue the following command in the root repository.
    bundle exec jekyll serve
  • The site should now be available at:
    http://localhost:4000
More can be read about working with Jekyll at http://jekyllrb.com/docs/structure/. A very good example can be found at https://github.com/maciakl/Sample-Jekyll-Site/.

Wednesday, July 30, 2014

Fix INSTALL_FAILED_INSUFFICIENT_STORAGE while installing the Android App during development phase

On a device like Samsung Y Duos with only 160MB of internal memory, it is common that the app gets installed first time but when you reinstall the app, you get:

Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]

This is an annoyance when an IDE is being used to deploy and redeploy app while in development.

Usually the IDE does the following to install the package:

adb shell "pm install -r '/data/local/tmp/com.your.package'"

This results in the INSTALL_FAILED_INSUFFICIENT_STORAGE error if the app is already installed on the device. A simple solution to this is to uninstall the app first through command line (uninstalling does not work when using Application manager in phone's settings):

adb shell "pm uninstall com.your.package"

And once the app is uninstalled, then either do a command line install or let the IDE handle installation.

adb install YOUR_APK

Monday, July 21, 2014

Check Google Cloud Messaging (GCM) Client for Android using Curl

This post deals with testing a GCM Client without implementing a formal backend server. It uses the unix command line tool curl to send messages to the devices registered with GCM. Please note that this is not an end-to-end tutorial on how to implement GCM in your apps. If you want more information on the topic, please refer to http://developer.android.com/google/gcm/index.html.
You can run the following script on terminal to send messages to your test device.
curl -X POST \
-H "Authorization: key= YOUR_AUTHORIZATION_KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR_DEVICE_TOKEN"
],
"data": {
"message": "YOUR_MESSAGE"
}
}' \
https://android.googleapis.com/gcm/send

YOUR_AUTHORIZATION_KEY:



YOUR_DEVICE_TOKEN: Token received when the client device registers with GCM server.

YOUR_MESSAGE: Message to send.

Happy messaging!

Monday, April 7, 2014

Grab Screenshot from Android device using Command line (adb)

The simple one liner will be:

adb shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png

The above command:

1. Uses adb to grab the screenshot and sends binary data to stdout, which is then ...
2. ... appended to a file screen.jpg. The perl command in between converts CRLF to LF.

Source

Sunday, March 30, 2014

Using OSX keychain to store git credentials

On Mac if you have the latest version of git, you can use following command to tell git to use OS X keychain.

git config --global credential.helper osxkeychain

Note that the credential helper only works with HTTPS requests.

Wednesday, March 12, 2014

Updating git repo with changes in .gitignore

When .gitignore file is updated, the changes do not appear to take effect in the output of git status. Following set of commands will update git with the changes.

git rm -r --cached .
git add . --all
git commit -am "Updated .gitignore"

Note that these commands must be executed in your project root.


Friday, January 31, 2014

Fetching a remote git branch

The following command will update your local repo with remote changes.
$ git fetch --all

After that use the following command:
git checkout --track origin/the_branch


Deleting the last commit pushed to remote repo

Let's say that you have a repo called "origin" with a branch named "UK-December". In order to remove the last commit, follow these steps:

1. Get the commit history.

$git hist
* ef92aa4 2014-01-31 | pretty sure?
* e5d2440 2014-01-30 | Bitmap loading
* 954b23a 2014-01-30 | PRIO-40: fixed?
...

The commit we want to delete is ef92aa4

2. Use the following command to force git to rebase the UK-December repo to the parent of ef92aa4.

$git push origin +ef92aa4^:O2UK-December

Thats it. Your remote commit is gone!

Friday, January 3, 2014

Decorator Pattern Using Fortran

Structural design patterns deals with using existing classes. One of the structural pattern is Decorator. It acts as a wrapper to existing class object and adds functionality to it without changing the signature of the class. It attaches additional responsibilities to the object without modifying the class.

Following is an example of Decorator pattern implemented in Fortran:

GitHub - Decorator Pattern In Fortran
Fork

Wednesday, January 1, 2014

Criteria Design Pattern In Fortran

"Criteria" is a simple yet useful structural design pattern. It is applied in the cases where there are different types of object of the same class and it is a requirement to fetch objects of certain kinds. The criteria pattern helps defining a class hierarchy which makes applying any possible criteria for the objects trivial. Adding a criteria to the existing set of criteria is as simple as adding a class.

Following is an example in Fortran:

GitHub - Criteria Pattern
Fork