Ubuntu Linux unable to mount non-journaled hfsplus drive for write

I have a drive from a Macbook that I made into a USB drive to share files between Linux and Macs. To do this I of course disabled journaling on the drive before removing it from the Macbook, and all was well. Both Linux (a Debian desktop machine) and various Mac machines could both read and write to the drive. However, I got a new notebook, which I installed Ubuntu on, and found it could only mount this non-journaled hfsplus USB drive as read only, though “mount” shows it mounted rw, for read and write. I tried many things and read many blogs and forum posts and decided to try the tools that come with in the “hfsprogs” package, and specifically “fsck.hfsplus” as someone speculated that the drive might have been become corrupt during an unmount.  The command I ran was:

sudo fsck.hfsplus /dev/sdb2

This check did indeed find some errors and report it had correct them and afterwards I could once again write to the drive.

I hope this helps the next person searching for this issue. I tried to get all the terms I was searching for, unsuccessfully, into title of this post to help folks locate it. Searching for this issue seems to turn up 99.9% responses about “You have to turn off journaling before mounting with Linux” which I knew already and was not part of the problem at all.

Use the Android SDK Emulator with Eclipse behind a Proxy

In the office we have a pretty stern internet proxy and I needed to test something from the Android Emulator using the network today, and therefore the Proxy. This seemed like a simple thing to do, and there are instructions for adding proxy information when launching the Emulator  on the Android Developer site (http://developer.android.com/guide/developing/tools/emulator.html#proxy). So I went into preferences for Eclipse, chose the Android preferences and sure enough, on the lunch tab there is a field for parameters when launching the Emulator. I added the proxy string there as per the document (-http-proxy user:pass@server:port) e.g.

-http-proxy http://user:pass@proxy.example.com:1234

but it did not seem to take. A little searching in some forums solved this however. I am adding it here with a title that matches what I was searching for via Google so that the next person can find it without reading a lot of forum threads.

The trick is that you need to add this info on for the project you are going to be running it from, and there is a convenient place to do so in Eclipse. With the project selected,  choose “Run” from the menu bar at the top, then “Run Configurations” This will show all the run configurations, and have the current project selected. You can also choose the Run/Configurations items from any project and select the correct one once inside. Once a configuration is chosen, choose the “Target” tab from the tabs on the right side of the Run Configurations dialog and look for the Text field labeled “Additional Emulator Command Line Options”. I had to resize the Dialog window to get this box to appear as there are no scrollpanes used there (I am using Linux version 3.5.2. of Eclipse). Below are a couple screen shots of these dialogs.

Access and use Java Properties in Spring Context file

This seems like such a simple thing to do, and yet finding a nice simple example online was a real bear (A BEAR!!! actually). So here is my example so the next person will have an easier time of it.

Add properties to your properties file:



Load the properties file inside the context file:

<property name=”locations”>

Access properties from the properties file when setting properties of a bean:

<bean id=”searchButtonBean” init-method=”init” class=”javax.swing.JButton”>
<property name=”text”>
<property name=”buttonIcon” value=”${button.icon.search}”/>

Apache ANT If Else Condition without ANT-Contrib

Sometimes I must make an ANT Build file that will need to work on many different machines, where I cannot be sure of the version or configuration of ANT nor the environment it is running in. This can cause some discomfort when it comes to complex builds involving conditions. The ANT-Contrib library has a convenient If/Else condition but this library is not always installed with ANT or even when it is, the build environment may not be configured to use it. So in either case, I use the following method which, though a little wordy, gets the job done without relying on anything beyond a standard ANT install. The method uses three ANT targets to do the work, one for the <if>, one for the <then> and one for the <else>. As you can see it creates a bit of extra code, but I believe the portability is worth it.

Below the explanation, the example referred to in the post will be made available. Now lets get started.

First Create a target that should do some bit of work based on a condition. Make the target depend on two other targets (here these are “setup” and “fail”), and only allow it to execute if a boolean variable has the right value, using the “if” attribute of the “target” element.

<target name=”go” depends=”setup, fail” if=”allIsWellBool”>

Next, have one of the dependencies create a boolean property based on the condition. The process is a little convoluted, in that you need to use a <condition> construct that has an <equals> test against text to create a boolean property. For instance, in the example for this post, this dependency target, “setup”, asks for some user input, then checks to see if an empty string was entered. A new boolean property is added based on the test.

<target name=”setup”>
<input message=”Please enter something:” addproperty=”somethingProp”/>

<condition property=”allIsWellBool”>
<equals arg1=”${somethingProp}” arg2=”” trim=”true”/>

After this target either there is a new boolean property called “allIsWellBool” or there is not. Subsequent test for this property will pass if the property is there, and true, or fail if it is not.

Finally, create a target to execute if the test fails, the else condition basically. This is done by only allowing it to execute if a boolean variable has the right value again, but this time using the “unless” attribute of the “target” element. In the case of the example for this post, this target will execute unless the “allIsWellBool” exists and is true.

<target name=”fail” depends=”setup” unless=”allIsWellBool”>
<fail message=”You must enter something”/>

See also that we are adding the dependency for the “setup” target here as well. This is because this target depends on a property that is set in the “setup” target, and “setup” should therefore happen first.

The full source of the example mentioned in this post is below.

<?xml version="1.0" encoding="UTF-8"?>
    Simple example of how to do an If/Else condition in
    your build file without using the ANT-Contrib libs

    This source code is provided free of charge and placed in the
    public domain. It is not supported by anyone.

    Use this at your own risk.
<project name="Test If Else Condition without ANT-Contrib" default="go">

    <!-- ======================= -->
    <target name="go" depends="setup, fail" if="allIsWellBool">

        <echo message="Great, passed the test, lets do something!"/>
        <!-- SHOULD DO SOMETHING -->


    <!-- =================================================== -->
    <target name="setup">

        <input message="Please enter something: " addproperty="somethingProp"/>

        <condition property="allIsWellBool">
                <equals arg1="${somethingProp}" arg2="" trim="true"/>

    <!-- ============================================ -->
         IS FALSE
    <target name="fail" depends="setup" unless="allIsWellBool">
        <fail message="You must enter something"/>


Install Google’s Go programming language using a proxy

Installing the Go Programming Language is pretty easy, but can be a pain when done behind a firewall and there isn’t one page with all the information necessary. So, here is the one page.

For step: “$ sudo easy_install mercurial”

“mercurial” is probably already in your favorite distro, it is for debian at least. So instead of using the easy_install script, try your distro’s package management app. For debian, apt-get install mercurial did the trick.  If you insist on doing it manually, you might need a proxy statement in your env like:

export http_proxy=”http://user:pass@myproxy.example.com:1234/&#8221;

For step: “hg clone -r release https://go.googlecode.com/hg/ $GOROOT”

You should probably have an .hgrc file with proxy information in it, including the user name and password for the proxy (be sure to take the credentials out again after install, and only put em in when using hg again)

———– .hgrc with just the minimum necessary contents —————-
# Used to access web-based Mercurial repositories through a HTTP proxy.




For step: “$ ./all.bash”

At the moment there are tests ran during the build, requiring network connectivity. There is discussion on the go-nuts mailing list about fixing it,  but until then removing “http” and “net” from tests in the make file:


will get you “Go”-ing again.

To do this, search for NOTEST and add entries “http\” and “net\” to the end, using tabs for the indentation. The complete list should look like the following when complete:

Configure Debian apt-get to use a proxy

So it seems configuring apt-get to use a proxy would be a pretty simple thing. The syntax for the entries in ” /etc/apt/apt.conf” are real simple; the HTTP entry, for example, is just:

Acquire::http::Proxy “http://user:password@proxy.example.com:0000&#8243;;

However, other forces, on your machine behind the firewall, are at work against you, and you probably put them them there.

If you have set up for using the proxy elsewhere, like setting environment variables:




in .bashrc or the like

or used Gnome’s  System -> Preferences -> Network Proxy tool to set a proxy server, which do not include the user name and password (or cannot) in the entries, then you are probably feeling the pain I had this morning. It seems that having the environment variables http_proxy and ftp_proxy set, trumps the entry “apt.conf” that can take the user name and password.

So to get it going, add the entries in “apt.conf” with the user name and password (and probably want to remember to take em out after getting updated or whatever) and temporarily remove other proxy server entries from the other places you may stuck them, then get a new shell and you should be happily apt-getting away though the proxy.

I love reading and writing Regular Expressions

Reading and writing Regular Expressions is the only time I feel I do what people think computer programmers do.

s/(R\w{6}([ ](\w{2,11}|I)){18}\.)/It is like magic\./g

Never thought I would praise Microsoft

It really surprises me to speak positively about these folks but damn, this is the right thing to do at the right time.

Microsoft appear to be converting their support site (the Microsoft Answers Forum) into a kind of open market place where amateur Microsoft experts can answer questions from users while negotiating their own prices for their time. Microsoft (again) appear to be simply hosting the site, and not trying to take a cut of the amateur experts’ take, saying they only intend to reduce the cost of their tech support.

There are other sites around like stackoverflow, and Experts-Exchange who either don’t allow the expert to make money or have some elaborate membership/fee system, but so far this is the first I have seen that operate like a free market. It will be interesting to watch.

Now if I only had not ignored windows for the last 13 years, I could work at home in my jammies helping people reboot. Dang!

You can read more about this in the at the sites linked here but it is not something you cant sign up for easily yet. It seems it is an invite only beta with new users being chosen from participants in the existing Microsoft Answers Forum



Recursive Grep Example

Nothing really needing explaining here, but wanted an example for doing a recursive grep handy as I can never remember it.


grep -RH –include “*.java” TEXT_I_AM_LOOKING_FOR *


Batch resize images with imagemagick (convert)

I am often asked how to resize a directory full of images, for free. This is definitely possible and probable there are many ways to do it, but I like to use ImageMagick for this. ImageMagick is available for almost any OS here:


Here is an example of converting a directory of JPEGs using a little scripting and imagemagick:

for i in $( ls *.jpg); do convert $i -resize 1024x768 sm_$i; done;