September 01, 2012

Git Reference

Create a local branch
$ git checkout -b config origin/mainline
See the current branch and switch to another one
# Lists all branches and identifies the current one with *
$ git branch -a 
# Switches to "mainline" branch $ git checkout mainline
Copy commits from one branch ($B1) to another ($B2)
# Figure out the commit hash in $B1 with  
$ git checkout $B1
$ git log 
# Reset $B2 with this hash. # Keep in mind that all commits previous to this one will also be copied to $B2. $ git checkout $B2 $ git reset --hard $long-commit-hash
Pull from remote repository and make sure local changes are merged properly.
$ git pull --rebase
# If there are conflicts, they will appear in the "not staged to commit" list. 
# Open files (vim, emacs etc..), and fix them manually. 
# Then add them.
$ git add -u 
# Then complete the merge. 
$ git rebase --continue
# If something goes wrong, roll back at any time with 
$ git rebase --abort
Aggregate/re-arrange commits with rebase
# List all commits and figure out how many of them you want to change  
$ git log 
# Say, you want to update 5 last commits. 
# Open them up and rearrange according to instructions. 
$ git rebase -i HEAD~5
Add all files under "not staged for commit" list into "staged for commit" list
  
$ git add -u 
Show changes in a specific commit, i.e. diff a commit
  
$ git show $commit-hash

June 15, 2012

Quick Links: Mockito

@InjectMocks: Easy way to initialize and set mocks.
ArgumentCaptor: See what was evaluated in the arguments.

January 23, 2012

How to get a bricked kindle fire back to live

I've rooted my kindle fire and then started playing with /system/build.prop file to get any app I wanted from android market. However I ended up with a bricked KF - it was stuck at the kindle fire logo.

I thought "luckily I've backed up the build.prop file, so I can just copy it back". But the process I went through wasn't that easy.. It took me a while to figure out how to revert build.prop file.

Here are the steps I followed t get KF back to live again:

1. First of all download latest android-sdk tools. This comes with ./adb and ./fastboot which will be your main tools to access KF.

# see all options
./adb --help  

# Common commands
./adb kill-server #kills
./adb devices #searches for devices
./adb shell  #goes to FK linux shell
./adb push from_file_dir_in_pc to_file_dir_in_kf

2. Next, make sure KF is recognized.  Go to KF shell and type su. If moves to # shell, great, you have root permissions. Move to step 4. If there is an error eg. segmentation fault, then move to step3.

3. Download fastboot, copy it to KF and execute. Then reboot and go to KF shell again. This time you should have root permissions. Try su. Refer to this post for further details.
$ ./adb push fbmode /data/local/tmp
$ ./adb shell chmod 755 /data/local/tmp/fbmode
$ ./adb shell /data/local/tmp/fbmode
$ ./adb reboot
$ ./adb shell
  $ su
4. At this point, you should have root permissions and can just go ahead and revert changes in build.prop. Copy stock build.prop in your work directory if does not exist. Download here.
$ ./adb push build.prop /system/

5. Next, follow instructions here. In my case, ./fastboot command never recognized the device and I ended up in cwm-based recovery screen. Since KF has only one button, I was only able to pick the first choice in each screen. At the beginning, this option is "install update" and in the next screen it is a "NO". So "install update" option looks for an update.zip file under /sdcard/ and then just installs if the file is there - even though you have to pick "NO" in the confirmation screen.
So to do this, first download the update.zip file here. Then just click on the power button on KF twice to install. Once installation is completed, reboot the KF.
# Copy update.zip to KF 
$ ./adb push update.zip /sdcard/
# Push on the reboot button twice to install.
# Once installed, reboot the KF.
$ ./adb reboot

And, it's done, the KF is back!

November 28, 2011

How to get android app store apps on kindle fire

It was not happy to realize that kindle fire does not allow access to android market place. Probably this is a well thought out marketing strategy of Amazon, but if you're tired of keep being redirected to "can not find app" message and don't want to root your kindle, keep reading :)

The default kindle fire browser (Silk) redirects all android market links to amazon app store. After googling a little bit, idea of getting another browser and using that to access android market seemed like to be a smart way. I tried accessing via dolphin - but failure, still redirect to amazon app store (btw - give a try to dolphin if you haven't done yet, it is a pretty cool browser.). So I'm left with the last option, sideloading apps through third parties such as freewarelovers.com and getjar.com. Just search for the apps online, download the apk file, and click on it to install. Before installing, make sure "allow applications from unknown sources" option is enabled through Settings->Device.

November 08, 2011

Scalable Manipulation of Archival Web Graphs

I was working on archival web graphs till last June. Actually, most of the Hadoop related posts on this blog are things I learned while working on this project.

We looked at the problem of processing large-scale archival web graphs and generating a simple representation for the raw input graph data. This representation should allow the end user to be able to analyze & query the graph efficiently. Also, the representation should be flexible enough - so it can be loaded into a database or can be processed using distributed computing frameworks, ie. Hadoop.
To achieve these goals, we developed a workflow for archival graph processing within Hadoop. This project is still going on and its current status has appeared at LSDS-IR '11 workshop at CIKM conference last month. I like to share the paper [acm] [pdf]  for those who are interested in further details. The abstract is following:
In this paper, we study efficient ways to construct, represent and analyze large-scale archival web graphs. We first discuss details of the distributed graph construction algorithm implemented in MapReduce and the design of a space-efficient layered graph representation. While designing this representation, we consider both offline and online algorithms for the graph analysis. The offline algorithms, such as PageRank, can use MapReduce and similar large-scale, distributed frameworks for computation. On the other side, online algorithms can be implemented by tapping into a scalable repository (similar to DEC’s Connectivity Server or Scalable Hyperlink Store by Najork), in order to perform the computations. Moreover, we also consider updating the graph representation with the most recent information available and propose an efficient way to perform updates using MapReduce. We survey various storage options and outline essential API calls for the archival web graph specific real-time access repository. Finally, we conclude with a discussion of ideas for interesting archival web graph analysis that can lead us to discover novel patterns for designing state-of-art compression techniques.
Also, the source code for "graph construction algorithm" is open sourced at GitHub.