A blog about technology, computer science, software engineering, physics and all other nerdy stuff!
Friday, August 8, 2014
Thursday, August 7, 2014
Change the name of remote git branch
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:
Local:
* 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
. * Command(s):
- git branch -v (Shows a list of all branches, with current branch highlighted)
Push the branch on the remote server, and then delete the older branch from both remote and local repositories.
* 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.
Enjoy!
Thursday, July 31, 2014
Use Jekyll to create a blog and host it on Github
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
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
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)
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
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
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
$ git fetch --all
After that use the following command:
$ git checkout --track origin/the_branch
Deleting the last commit pushed to remote repo
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
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
Following is an example in Fortran:
GitHub - Criteria Pattern