December 02, 2012

parse UUID

Nice & easy tool for converting string to UUID:
# login to ruby shell
yasemin$ irb

# Make sure UUID tools is loaded. 
>> UUIDTools
NameError: uninitialized constant UUIDTools
 from (irb):1
>> require "uuidtools"
=> true
>> UUIDTools
=> UUIDTools

# Parse string to UUID
>> UUIDTools::UUID.parse_hexdigest(s).to_s
>> UUIDTools::UUID.parse_hexdigest("CEBBA579AE1A4C4A9EE0D1BCDC8C3E1E").to_s
=> "cebba579-ae1a-4c4a-9ee0-d1bcdc8c3e1e"

November 18, 2012

yum doesn't find the package

I've been facing "no package available" error when I try installing packages through yum. Here is an example error message:
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled. 
Setting up Install Process
No package google-chrome-stable available.
Nothing to do
This message simply implies that your system is not registered with Red Hat. For details see this post. Solution is simple - just install the public repository manually:
$  cd /etc/yum.repos.d
$  wget

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 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 file here. Then just click on the power button on KF twice to install. Once installation is completed, reboot the KF.
# Copy to KF 
$ ./adb push /sdcard/
# Push on the reboot button twice to install.
# Once installed, reboot the KF.
$ ./adb reboot

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