Software Projects

Installing the Android SDK from the Command Line

Posted in Uncategorized by rmt on July 24, 2012

(Ubuntu 12.04)

The following are instructions for setting up the Android SDK from the command line.

Install Eclipse:

sudo apt-get install eclipse

Install Android SDK:

sudo apt-get install ia32-libs
tar xzvf android-sdk_*
echo ‘export ANDROID_HOME=/home/$USER/android-sdk-linux’ >> /home/$USER/.bashrc
echo ‘PATH=$PATH:$ANDROID_HOME/tools’ >> /home/$USER/.bashrc
echo ‘export PATH=$PATH:$ANDROID_HOME/platform-tools’ >> /home/$USER/.bashrc
source ~/.bashrc
android update sdk –no-ui –force

Install Android NDK:

bunzip2 android-ndk-
tar xvf android-ndk-

echo ‘export ANDROID_NDK_HOME=/home/$USER/android-ndk-r8’ >> /home/$USER/.bashrc
echo ‘export PATH=$PATH:$ANDROID_NDK_HOME’ >> /home/$USER/.bashrc
source ~/.bashrc

Install Android ADT Plugin:


Help->Install New Software->Add>Developer Tools

Preferences->SDK Location->(Set the SDK Location)

Help->Check for Updates

Create an AVD:

android create avd -n 4.0.3 -t 27 –abi armeabi-v7a

Maven Installation

Install Maven 3:

tar xzvf apache-maven-3.0.4-bin.tar.gz
echo ‘export M3_HOME=/home/$USER/apache-maven-3.0.4’ >> /home/$USER/.bashrc
echo ‘export M3=$M3_HOME/bin’ >> /home/$USER/.bashrc
echo ‘export PATH=$PATH:$M3_HOME’ >> /home/$USER/.bashrc
source ~/.bashrc

Install android-maven-plugin:

sudo apt-get install git
git clone
cd maven-android-plugin
mvn clean install

Install maven-android-sdk-deployer:

git clone
cd maven-android-sdk-deployer
mvn install

Install maven-android-plugin-samples:

git clone
cd maven-android-plugin-samples
mvn clean install

Converting a YYYYMMDD Number to Date Format in Microsoft Excel

Posted in Uncategorized by rmt on May 17, 2012

To tell Excel to interpret the number that’s in cell A1 as a date in YYYYMMDD format, enter this formula in a separate cell:


Then do Format Cells->Date on the cell into which you just entered the formula.

App Videos

Posted in Uncategorized by rmt on December 4, 2011

ARB Installation

Posted in Uncategorized by rmt on August 13, 2011

sudo apt-get install libmotif4 libpng3 xloadimage gnuplot gv xfig libglew1.5 libmotif-dev libtiff4-dev libx11-dev libxaw7-dev libxext-dev libxml2-utils libxp-dev libxpm-dev libxt-dev lynx x11proto-print-dev xsltproc xutils-dev freeglut3-dev libglew1.5-dev libpng12-dev
mkdir /home/share/apps/arb
cd /home/share/apps/arb
sudo tar xvfz arb.64.ubuntu.OPENGL.tgz
sudo /bin/sh
sudo ln -s /usr/lib/ /usr/lib/

Using Tesseract Tools for Android to Create a Basic OCR App

Posted in Uncategorized by rmt on August 6, 2011

Jan. 24, 2012 UPDATE: This tutorial is out of date. The tesseract-android-tools build files and the Android SDK Tools have both been updated, so the build should now succeed without requiring the modifications shown below. There’s an up-to-date tutorial available here.

I’ve published a project that combines the tesseract-android-tools project code with the source code for the Tesseract/Leptonica dependencies in a single project that’s intended to be easier to build here.

Note: The below instructions were written for the Android SDK Tools r12. To compile using r14+, after ndk-build do rm build.xml, then android update project --path . , then ant release (without modifying build.xml). Running the test cases on new versions of the SDK Tools will require other modifications.

These instructions assume you have already installed the Android SDK and NDK along with Eclipse and Subversion on Ubuntu.

Overall, what you need to do is to set up the tesseract-android-tools project as a library project in Eclipse, and tell your project to refer to the library project. So you’ll need two projects in Eclipse, whereas for an ordinary app you would have just one.


Check out the latest tesseract-android-tools source code using Subversion (don’t use the outdated code from “Downloads”):

git clone

Build the project according to the instructions in the readme file. Make sure that ndk-build successfully creates the .so object files, and that you get “BUILD SUCCESSFUL” when ant finishes. You may need to make three modifications:
Modification 1. Apparently the site is unavailable for the libjpeg download, and it’s been pointed out elsewhere that using an alternative repository works, so use the following command instead of the existing git clone command:

git clone git:// libjpeg

Modification 2. Before running ant, edit the existing build.xml as a workaround for Android bug #13024. Put the following lines immediately before the ending </project> tag:

<!-- beginning of modification -->
  <path id="android.libraries.src"><path refid="project.libraries.src" /></path>
  <path id="android.libraries.jars"><path refid="project.libraries.jars" /></path>
<!-- end of modification -->

Modification 3. Do ant compile instead of ant release.

Create an AVD running Android 2.2 or higher, and with an SD card.

Import the tesseract-android-tools project into Eclipse:

File->Import->Existing Projects Into Workspace->Choose tesseract-android-tools->Finish

If you get an error complaining about a compiler level 5.0 compatibility problem, right-click the project name for tesseract-android-tools and do Properties->Java Compiler->Enable project specific settings and Uncheck “Use default compliance settings,” then set “Generated .class files compatibility” to 1.5, and set “Source compatibility” to 1.5. Answer yes if asked to rebuild.

Add tesseract-android-tools as a library project:

Right-click tesseract-android-tools project name->Properties->Android->check “Is Library”.

[Optional] Install the built-in test case package by importing the tesseract-android-tools-test project:

File->Import->Existing Projects Into Workspace->Choose tesseract-android-tools-test->Finish

[Optional] Start the AVD, wait for it to boot, and install the traineddata file required by the test cases:


gunzip eng.traineddata.gz

adb shell mkdir /mnt/sdcard/tesseract

adb shell mkdir /mnt/sdcard/tesseract/tessdata

adb push eng.traineddata /mnt/sdcard/tesseract/tessdata

[Optional] Run the test cases–the test cases should pass, saying “OK (3 tests)”:

adb install tesseract-android-tools-test/bin/tesseract-android-tools-test.apk

adb shell am instrument -w -e package \

Create your new app as a new Android project.

Configure your project to use the tesseract-android-tools project as a library project: Right click your new project name, do Properties->Android->Library->Add, and choose tesseract-android-tools.
You can now create a TessBaseAPI object in your app’s onCreate():

File myDir = getExternalFilesDir(Environment.MEDIA_MOUNTED);

TessBaseAPI baseApi = new TessBaseAPI();
baseApi.init(myDir.toString(), "eng"); // myDir + "/tessdata/eng.traineddata" must be present

String recognizedText = baseApi.getUTF8Text(); // Log or otherwise display this string...

Run your project on the AVD.
Other basic examples can be found in the file in the tesseract-android-tools-test project.

Using VNC to Connect to an Ubuntu Server with a Full Screen Window Manager

Posted in Uncategorized by rmt on July 22, 2011

Do the one-time setup:

Install the VNC server package:

sudo apt-get install vnc4server

Set the password you want to use, entering a strong password:


Run the following command to create your VNC configuration file:

vncserver :1 -geometry 1366x768 -depth 16

Then kill the session:

vncserver -kill :1

You should now have a config file at: ~/.vnc/xstartup. Edit that file and uncomment the following directives:


sh /etc/X11/xinit/xinitrc


Each time you want to connect:

Connect by ssh to the server, and start your VNC server session on the server:

vncserver :1 -geometry 1366x768 -depth 16

Run your VNC client (Chicken of the VNC for Mac, Putty for Windows) on your local machine and connect to the server, using the password you set up above, and the display number as specified above (“:1“).

Setting up X11 Forwarding on Ubuntu

Posted in Uncategorized by rmt on July 22, 2011

Edit /etc/ssh/ssh_config to contain the following:

ForwardX11 yes

Now you can connect from a remote location by doing:

ssh -X user@hostname

set DISPLAY localhost:0.0

Test the X11 forwarding:

xclock &

Setting Up an sftp Site on Amazon Web Services EC2, and a Guest Account

Posted in Uncategorized by rmt on July 3, 2011

(Adapted from and

This consists of three parts:

  • setting up an sftp site on EC2
  • creating a new user account
  • configuring the new user account to do read-only ftp, with no ssh privileges

This is intended for transferring files to and from trusted users. I use this as an adequate solution for occasionally sending very large files to clients, using an EC2 instance dedicated to that task. After the transfer is complete, I shut down or delete the instance.

Set up a server using Amazon Web Services EC2, choosing an Ubuntu Amazon Machine Image (AMI). (You can find an AMI using You may want to choose one that’s free tier eligible, such as ami-1aad5273)

ssh into the server:

ssh -i keyfile.pem

Install vsftpd:

sudo apt-get install vsftpd

Create a new user:

sudo adduser newusername

Using the AWS Management Console, generate a new key pair for the third-party user.

Using puttygen, import the new key (keyname.pem) and copy its public key.

On the server, create the .ssh directory for the new user:

sudo mkdir /home/newusername/.ssh

Paste the public key into /home/newusername/.ssh/authorized_keys.

Set permissions:

sudo chmod 700 /home/newusername/.ssh

sudo chmod 600 /home/newusername/.ssh/authorized_keys

sudo chown -R newusername:newusername /home/newusername/.ssh

Test the new user’s sftp login from your local machine:

sftp -o IdentityFile=newkeypair1.pem

Make a new group for users who should be limited to using only sftp:

sudo groupadd sftponly

sudo adduser newusername sftponly

Edit /etc/ssh/sshd_config and change the Subsystem line to:

Subsystem sftp internal-sftp

and add these lines to the end of /etc/ssh/sshd_config:

Match group sftponly
ChrootDirectory /home/%u
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp

Set permissions, without clobbering files necessary for EC2’s key-based authentication:

sudo chown root:root /home/newusername

sudo chown -R newusername:newusername /home/newusername/.ssh

sudo /etc/init.d/ssh restart

Now the new user can connect by sftp, but not by ssh. Place the files you want to share in /home/newusername, and share the key with the user.

Search for a Package Using apt-get

Posted in Uncategorized by rmt on June 25, 2011

sudo apt-cache search some-software-name

Setting up a Static IP Address and Enabling ssh on Ubuntu

Posted in Uncategorized by rmt on June 25, 2011

To use a static IP address, edit /etc/network/interfaces to contain:

# The primary network interface
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address <IP address>
netmask <value, which is sometimes>
network <value, sometimes same as IP but ending with .0>
broadcast <value, sometimes same as IP but ending with .255>
gateway <value, sometimes same as IP but ending with .254>

# The loopback network interface
auto lo
iface lo inet loopback

To install ssh:

sudo apt-get install openssh-server

This should configure the ssh service to be automatically started during boot.