Adding aFileChooser to your Android project

I had the problem of adding the aFileChooser library and here is how I solved it.
First you need to download the zipped source code from here:
https://github.com/iPaulPro/aFileChooser
Then I unpacked it
Folder structure afileChooser

As I did not need the examples I only copied the aFileChooser directory into my existing Android project directly under the /lib directory. I like this as this will provide me with all code that I use in one directory.

Folder structure afileChooser in your own project

Then in Eclipse you have to open the library as a NEW project by selecting:
File -> New -> Project…
Bildschirmfoto vom 2013-05-15 21:20:52

Next you will need to add the aFileChooser library to your project.
You do this by selecting your project in the explorer and right clicking on it’s name. This will open the context menu where you have to click on Properties to get to the following screen.
Eclipse project properties

By clicking Add you can then select the aFileChosser library.
Eclipse library dialoge

Press OK on this and the previous dialoge.

If you are unlucky like me you will now see an error occuring as your own project and the aFileChooser library project have under their respective /lib directory the same JAR file “android-support-v4.jar” but of different size and therefore version.
Error in the Eclipse console.

Just copy your android-support-v4.jar file to the /lib/aFileChooser/lib folder and press F5 back in Eclipse to get a refresh.

NAS+Ubuntu+SVN

My NAS a “MyBook World Edition™ from  WesternDigital®” was sitting in the background just keeping the back-ups from time to time. Over the holiday period I took the time to setup and integrate the network drive better with Ubuntu and try to use the drive with subversion which I failed some time ago and did not bother to look any closer into it.

So here is what helped me (some of it is rather trivial).

As always this is without any warranty, try this at your own risk!

Ubuntu integration

For the integration with Ubuntu you just have to install an nfs package as shown below

[bash gutter=”false”]sudo apt-get install nfs-common[/bash]

Then you have to change the fstab file in an editor with root privileges by executing:

[bash gutter=”false”]sudo gedit /etc/fstab[/bash]

In this file you have to add for each of your partitions of your NAS a line. An example is given below, which works for me. You have to change the following to adapt it to your situatin.

  1. You should assign to your NAS a fixed IP
  2. The fixed IP has to go where in the example below you have the 192….100 address
  3. The path on the NAS drive follows the fixed IP address
  4. After some spaces you have to enter where on your Ubuntu machine the partitions are mounted

[code]# NAS Drive
192.168.1.100:/DataVolume/georg      /media/georg    nfs  defaults,user      0       0
192.168.1.100:/DataVolume/backup     /media/backup   nfs  defaults           0       0
192.168.1.100:/DataVolume/Public     /media/public   nfs  defaults,user      0       0[/code]

SVN integration

With the plain integration shown above SVN will not work properly. The nasty point is here that if you put your repository to the NAS you can check-out a working directory. But once you have made changes and want to commit you fail with an error that tells you that subversion was not able to get a lock on the file …db/txn-current-lock.

This can be worked around by adding to the fstab file options additional entries. For the previous example a change for a partition would look as given in the example below.

[code]# NAS Drive
192.168.1.100:/DataVolume/georg           /media/georg    nfs  defaults,user,nolock,bg      0       0
[/code]

A side effect will be probably (I am not 100% sure here) that in such an environment you should better not work with more than one person on the repository as otherwise you may get conflicts if 2 or more try to commit at the same point in time.

Exchanging files between Nexus 10 and Ubuntu

Nexus 10 does not attach itself as a USB storage card. Instead it uses the protocols PTP and MTP. The former is quite nicely supported on my Ubuntu 11.10.
-I know I should upgrade-.

So what happens? First of all nothing! If you attach the Nexus 10 via USB there is no notification on ubuntu. On the Nexus you get a little status hint (upper left corner a box with an arrow inside) that there are now some USB actions available. From the status you can directly jump into the USB settings where you find two possible connection modes. The ticked default mode is MTP.
If on your Nexus you now tick PTP, Ubuntu immediately detects a camera device and opens up the Nautilus explorer showing the DCIM folder and you can access the files.

But I just wanted to put some music on the new device and I don’t want to slingshot it from my PC to some internet server and then back to my device. After all they are just 10cm apart from each other right in front of me?!

So next thought is to look for an application that advertises MTP capabilities and the Ubuntu Software Center shows me gMTP.

After installing gMTP it works. Not automatically, you still have to fire up gMTP manually and at first you do not have access to any files but if you open the file menu of gMTP and select “Close devices” (hope this is the correct English translation) you get the content of your Nexus.

Transfering mp3 files is now possible but is a bit cumbersome. Every file requires to be OKed with an error message. But finally they end up on the Nexus and can be used and that’s what I wanted in the first place.

Creating folders is possible and while I am at it, I uploaded some pdf files to the Nexus, which were all uploaded without complaints and error messages in an instant.

A word of caution I also tried the application Qlix in my case version 0.2.6 on Ubuntu. Well and I failed, it just started shortly and stopped after a second and that’s it, no error no nothing. It might be a good and don’t forget free application and for other devices it might even work perfectly but what nagged me here is the fact that there is no hint from the GUI.

Starting it from the console reveals a bit more information. There you get the info that you should report the device ID to the libmtp team.

Device 0 (VID=18d1 and PID=4ee1) is UNKNOWN.
Please report this VID/PID and the device model to the libmtp development team
Ouch! – Qlix received signal 11

So overall file transfer is possible but not yet perfect.

 

Syntax Highlighting for rhtml and erb with gedit

I like to use gedit for coding with ruby on rails and it features syntax highlighting for ruby and html but unfortunately not for rhtml and erb files.

So in this article I will show you how to get syntax highlighting for .rhtml and .erb files within the gedit editor as shown here.

Gedit Screen Shot with syntax highlighting

Gedit uses the GTK toolkit, which in turn has a configuration for language parsing and highlighting. The syntax files delivered with Ubuntu reside under

/usr/share/gtksourceview-3.0/language-specs/

and the files can be extended or overruled by installing new files in your home directory under

~/.local/share/gtksourceview-3.0/language-specs/

This is a safer place for your changed files as the /user/share path might be changed with upgrades.

I have created based on the html.lang file an rhtml.lang file, which you find below.

So here are the two steps what you need to do:

First, create the following directory

Second, downdload this file and copy it into the just created directory.

If you now restart gedit and load a file with the .rhtml and .erb ending you should see a result similar to the example above.

Installing Rails Version 2.3.11

I have just recently re-installed rails, mysql and mongrel in an older version 2.3.11 and its required libraries and tools on 3 computers. As not all instructions I found in the web did work for me here is my learned procedure to get up and running on Linux Ubuntu 12.04.

Installing ruby

[bash]sudo apt-get install ruby rubygems[/bash]

To get access to the ruby documentation and to enable “./script/console” you have to install ri and interactive ruby.

[bash]sudo apt-get install ri irb[/bash]

Installing rails

As Rails version 3 caused some problems for me and some of my aps are not yet ported to Rails 3, I explicitly installed v2.3.8.

[bash]sudo gem install rails -v 2.3.11 -V[/bash]

I prefer to use the verbose option “-V” as the installation is sometimes just sitting around seemingly not responding anymore. In verbose mode however after a few seconds you should see what URLs are queried. So give it some time and be patient.

Installing MySQL

[bash]sudo apt-get install mysql-server mysql-client
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo apt-get install ruby1.8-dev
sudo gem install mysql [/bash]

Preparing the environment

Ok, the previous steps installed some gems but the executables are not yet accessible. So we have to add their path to our shell.

For this we first check where the binaries were installed, just call:

[bash]gem env[/bash]

Which provides the following output on my computer.

[bash]RubyGems Environment:
– RUBYGEMS VERSION: 1.3.5
– RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
– INSTALLATION DIRECTORY: /var/lib/gems/1.8
– RUBY EXECUTABLE: /usr/bin/ruby1.8
– EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
– RUBYGEMS PLATFORMS:
– ruby
– x86-linux
– GEM PATHS:
– /var/lib/gems/1.8
– /home/georg/.gem/ruby/1.8
– GEM CONFIGURATION:
– :update_sources => true
– :verbose => true
– :benchmark => false
– :backtrace => false
– :bulk_threshold => 1000
– REMOTE SOURCES:
– http://gems.rubyforge.org/ [/bash]

We then take the executable path and add it to our shells path.

[bash]cd ~
gedit .bashrc [/bash]

And in the just opened editor we add the following lines and save the file again.

[bash]# Ruby environment
export PATH=${PATH}:/var/lib/gems/1.8/bin [/bash]

Calling the “which” command should then produce the following output, given your gems path is identical to mine.

[bash]which ruby gem rails rake mongrel_rails
/usr/bin/ruby
/usr/bin/gem
/var/lib/gems/1.8/bin/rails
/var/lib/gems/1.8/bin/rake
/var/lib/gems/1.8/bin/mongrel_rails
[/bash]

Remaining is now the installation of helpful tools and helpers such as the mongrel application server, SSL- or the debugging support.

[bash]sudo gem install mongrel ruby-debug log4r
sudo apt-get install libopenssl-ruby[/bash]