How to run bash script on Windows at system startup


This topic may be a bit confusing but here is the story.
Let say we have a SH script and we would like to run it on Windows because there is no equivalent BAT script available. In general if you want to run bash script you need some sort of bash command line interpreter. For example you can install Git bash:

Then it's simply - open Git bash and cd to the target script directory and run it manually by invoking the command:

Now if you would like to run it without touching the command line you can create a windows shortcut to run the bash script. In the shortcut command you also need to provide a bash program that will execute the script - in this case it will be Git bash. So the shortcut underlying command will be something like this:
"C:\Program Files\Git\bin\sh.exe" C:\tool\bin\

Or if the SH script takes parameter it could look like this:
"C:\Program Files\Git\bin\sh.exe" C:\tool\bin\ start

That's pretty cool :) Now if you would like to have it run at windows startup you place this shortcut in the menu start startup folder. On Windows 7 for example it's in the following location:
C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Just copy your shortcut there and you are done.

Hope that will help in some cases.

ProGuard - decoding obfuscated stack traces


If you develop and publish mobile apps you will most likely see some crash reports with some kind of stack trace attached. If you used ProGuard to obfuscate the code it may be difficult to read such error message / stack trace.
Luckily for us it can be easily decoded using the same tool.

Following command does the trick: [-verbose] mapping.txt <stacktrace_file>

Retrace tool is available in your proguard/bin path which usually is <sdk_root>/tools/proguard/bin directory

Important thing is to use the same mapping.txt file that has been used to obfuscate the code (this can be find in you <app_project_root>\proguard )


How to implement "share" functionality for Android app


Today basics of implementing the share action which should let share content via e-mail, SMS message, etc. The common way would most likely be to use the action bar and it's menu icons.
So first step is to add 'share' menu item:
<menu xmlns:android=""
    tools:context=".MainActivity" >


We use ShareActionProvider widget from support library to account for older devices.

Next step is to override onCreateOptionsMenu method in your MainActivity:

ShareActionProvider mShareActionProvider;
Intent mShareIntent;
public boolean onCreateOptionsMenu(Menu menu) {
    // this is common just inflate the menu
    getMenuInflater().inflate(, menu);

    MenuItem shareItem = menu.findItem(;

    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    if (mShareActionProvider != null) {
        if (mShareIntent == null) {
            mShareIntent = new Intent();

    // here you can put data that you would like to share
            mShareIntent.putExtra(Intent.EXTRA_TEXT, "SOME_SHARE_DATA");

    return true;


And that's basically it. Usually you don't need to do anything special in the implementation of onOptionsItemSelected.

You may notice that it works in the debug mode / locally but when you deploy to live it does not. That may happen if you use ProGuard. Following line should be added to the proguard configuration in order to make it work:
# to keep shareactionprovider working
-keep class { *; }


Create bootable Win 7 USB pendrive on Ubuntu


If anyone is looking for how to install Windows 7 from USB drive here it is. This guide is for people who run Linux.

One of the most popular and common tool for creating bootable pendrive is called unetbootin and will be using it for completing this task.

First of all you need to format your USB device to ntfs. You can do it using gparted tool (be careful to choose correct drive ;)

You may also need to install support for NTFS:
sudo apt-get install ntfs-3g

If you want your device to be bootable you can set such flag in gparted itself.

Here is the version of unetbootin that happens to support the NTFS:

After you run unetbootin follow on screen instruction, i.e. select image from ISO,
and select the correct drive - you may need to tick the checkbox called: "Show all drives". Make sure you know what drive is your USB to avoid destroying data on your real drive - follow at your own risk of course.

That's it.

ssh-add problems with SSH agent and related


Some time ago we have posted about resolving git errors related to permissions denied for the ssh keys:

The solution was to try running the following command:

However what if running it results in the following error:
"Could not open a connection to your authentication agent"

Well there is a solution to that one too :)

It may mean that the SSH agent is not running and you can try to start it prior to running the command. If you run GIT bash on Windows you can try the following command:
eval `ssh-agent -s`

or if that's not the case you can try directly start ssh-agent

After that just try again with ssh-add.

Hope that helps someone.


Java Mail API for Android and proguard errors


If you would like to send e-mails directly from within your mobile app you can use Java Mail API.  Here is the special lightweight port for Android:

You will need to include all 3 jar files in your libs folder:
  • additional.jar
  • mail.jar
  • activation.jar
Then you can use common way to implement sending e-mails. Both should work: TLS and SSL.

Everything seems to be working fine until you are ready to publish your app. If you are going to export signed APK and use ProGuard to obfuscator you may notice errors and warning for proguard saying about missing classes, references or jars.

In order to fix just add the following rules to your proguard config file:
-dontwarn java.awt.**
-dontwarn java.beans.Beans

-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}

-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}

This may or may not work for you but it did the trick for me :)

How to: backup and restore MySQL data

Dumping/backup table for the MySQL database
mysqldump -u <dbuser> -h <dbhost> -p <dbname> tablename > tablename.sql

Restoring data
mysql -u <dbuser> -h <dbhost> -p <dbname>
mysql> source <path>/tablename.sql

mysql -u <dbuser> -h <dbhost> -p db_name < /path/to/tablename.sql