avp::ptr weblog

Everything that is in our mind.

How to set up a fast emulator for Android on Linux?

without comments

This article describes how to setup a new emulator which allows to install apps which use Google Play Services.

Recently, Android 4.3 (API level 18) has been published. As former releases it contains system images for ARM and Intel Atom (x86). When creating an emulator via the Android Virtual Device Manager one can choose to target either the “plain” API level or include Google APIs. The “plain” configuration can benefit from both hardware acceleration options (ARM and  Intel Atom). Running such a virtual device is quite comfortable as it behaves similar to a hardware device. The Google API targets however do not allow to use Intel Atom architecture.

Android Virtual Device

Read the rest of this entry »

Written by tobi

September 12th, 2013 at 12:35 am

Android button states understood

without comments

After a lot of research, trial and error I finally understood how I can specify four different button states via XML. The important detail is that you need to add both state parameters in every item. In the following example those are android:state_checked and android:state_pressed which can be combined to four different states.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
finger is on while button is up
<item android:state_checked="false" android:state_pressed="true"
finger is gone, button is up, default
<item android:state_checked="false" android:state_pressed="false"
finger is gone, button is down
<item android:state_checked="true" android:state_pressed="false"
finger is on while button is down
<item android:state_checked="true" android:state_pressed="true"

If you are unsure why you want to have four states for a single button just imagine the button can stay in its checked state.

Written by weblogger

March 21st, 2013 at 7:11 pm

Posted in Uncategorized

Tagged with , , ,

Git: How to copy a range of commits from one branch to another?

with 6 comments

Sometimes it is useful to copy a series of commit to another branch. This post describes how to do this using git rebase. Two example illustrate different scenarios which should help to understand the command arguments in generell.

Example 1: The commit P, Q, R which are contained in branch feature should be copied to branch master. The commits should be appended to commit M.

git rebase --onto M O R && git rebase HEAD master

The first command git rebase --onto M O R copies the commits P, Q, R to the branch master. They won’t be visible if you check the visual graph in gitk. This is because there is no branch reference that points to one of the three commits. To update the branch master run the second command git rebase HEAD master which moves up the HEAD to commit R.

Read the rest of this entry »

Written by tobi

September 28th, 2012 at 11:45 pm

Posted in Uncategorized

Tagged with , , , ,

How to fix Eclipse colors for autocompletion and tooltips

with 11 comments

Sadly Eclipse ships with a broken color theme when it comes to autocompletion and tooltips. I cannot tell if the problem is limited to Ubuntu Precise, however, it is worth getting fixed immediately. The following screenshots illustrate the broken color settings in both situations. The tooltip window shows up with a black background color and blue links.

Eclipse IDE - Tooltip with default colors settings

Eclipse – Tooltip with default colors settings

When autocompletion popup appears the first suggestions is not readable at all.

Eclipse IDE - Autocompletion with default colors settings

Eclipse – Autocompletion with default colors settings

So, here is what you need to do to fix the colors. Read the rest of this entry »

Written by tobi

July 28th, 2012 at 5:11 pm

How to manually install TeX Live 2012

with 3 comments

Some days ago, at July 8, TeX Live 2012 has been released. In the meantime, I also updated to Ubuntu 12.04. (Precise) but I did not find the time to install TeX Live. I am happy to report that there is nothing new to learn regarding the installation. You can straight follow the very same instructions I posted earlier for TeX Live 2011. Have fun.

Update: I noticed that TeX Live 2012 has been made available via apt-get. I recommend testing it out (I haven’t done so yet).

Written by tobi

July 10th, 2012 at 11:50 pm

Search and replace across multiple directories

without comments

Today, I tried to find a convenient way to unify the spelling of a word used in various text files spread across multiple directories. Of course vim has a solution to this. In my case all files are of type *.txt. The term I want to search for is “re-use” which should be replaced by “reuse“. Here is what I did:

  1. Open vim while loading all relevant files recursively as a argument list the editor. vim **/*.txt
  2. Start recording a macro in register “a”. Type qa
  3. Enter the substitution command to search and replace a specific character pattern :%s/re\-use/reuse/ge
  4. Change to the next file in the argument list. Type :wnext
  5. Stop recording the macro in register “a”. Press q
  6. Playback the macro 999-times by entering. 999@a

The posts “Vim 101: Search and Replace on Multiple Files” and “Vim. How to replace a word (string) in several files.” guided me. Please have a look there for further information.

Written by tobi

April 7th, 2012 at 5:00 pm

Colored Diffs add-on for Thunderbird

with 2 comments

Reading todays post-hook emails with the latest diffs of some project the thought rushed to my head that it would be nice to have the diffs displayed in color. Since I am using Thunderbird as my email client I found a great add-on named “Colored Diff”.

Although, the add-on seems to be outdated to work with the latest Thunderbird version (which is 10.0 right now) there is an easy way to install the add-on while the automatic installer refuses to do so. Here is what you can do to make the installation work.

  1. Download the colored diffs *.xpi file
  2. Open the archive with an archive manager of your choice
  3. Edit the contained install.rdf with a text editor of your choice
  4. Change the maxVersion parameter to be equal or greater then the current version of Thunderbird
    Before: <em:maxVersion>3.1.*</em:maxVersion>
    After: <em:maxVersion>13.1.*</em:maxVersion>
  5. Save the changes and store them back into the archive
  6. Install the add-on

Do not forget to check out the preferences after you installed the add-on. You can choose 4 different types to display the diffs and customize the colors as well.

If you feel interested to enhance the add-on you can do so. The “Colored diffs” project is hosted on Google Code open for people to participate.

Written by tobi

February 8th, 2012 at 4:33 pm

Amend files to a git commit without changing the commit message

with 2 comments

Quiet often there is the need to add files to the recent commit. This can be done with 2 simple commands.

git add file
git commit --amend

In case you do not wand to change the commit message there is the new option --no-edit for git commit introduced in git 1.7.9. The git release notes describe how the --no-edit option can be used.

git commit --amend” learned “--no-edit” option to say that the
user is amending the tree being recorded, without updating the
commit log message.

git commit --amend --no-edit

Of course, I added an alias for the new option to my global git configuration.

ci = commit
cm = commit -m
ca = commit --amend
cn = commit --amend --no-edit

Written by tobi

February 5th, 2012 at 10:11 pm

Posted in Uncategorized

Tagged with , , ,

Reset the author of a git commit

without comments

Once in a while one forgets to configure the user name and email address for git when initializing or cloning a new git repository. So do I. But git would not be git if it does not have an answer to that problem. Here is what git prints out when you commit without previously configuring the user credentials.

$ git cm 'Initial import.';
[master (root-commit) 0396c37] Initial import.
Committer: User User@Machine.(none);
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name ''Your Name''
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 file

Well done git!

Written by tobi

February 5th, 2012 at 9:54 pm

Posted in Uncategorized

Tagged with , , , ,

Custom NSLog for Xcode 4

without comments

This post describes how you can to setup a custom NSLog snippet in Xcode 4. By default, this custom NSLog prints the class and method name of the position it is inserted.

NSLog auto completion

NSLog auto completion

Please follow these steps to add the code snippet to the scripts in Xcode 4.

  1. Copy and paste the following code into your editor. Anywhere.
    NSLog(@"%@ %@", self.className, NSStringFromSelector(_cmd)); /* DEBUG LOG */
  2. Open up the code snippets library which sits in the utility pane on the right side. Look for the curly braces {}.
  3. Highlight the above mentioned code – click and hold the mouse over the text  (for a short while) – drag them into the code snippet library.
  4. Afterwards you can edit the snippet and add a title, summary and a completion shortcut. I used the following settings:
                  Title: Custom NSLog (Class & method name)
                Summary: NSLog prints the class and method name
               Platform: All
               Language: Objective-C
    Completion Shortcut: NSLog
      Completion Scopes: All
Custom NSLog snippet

Custom NSLog snippet

You are welcome to comment and post your custom code snippets!
This article is inspired by the post “Easy Doxygen code snippets for Xcode 4” by Chris Powell.

Written by tobi

October 26th, 2011 at 9:06 pm