Saturday, 29 November 2008

Two-faced kitten

Two faced kitten

Saturday, 8 November 2008

Re-ordering songs in a playlist in iTunes - you first need to click on the playlist number (1st column)

I haven't really had much to complain about when it comes to iTunes, until now.

I was preparing a CD songs for my son, and I had the songs in a playlist. The first group of songs I added was from a single CD, so that was easy enough. I added a few more songs later, and discovered that changing the order of the songs in a playlist can be a bit puzzling. Trying to drag around a song in the list, which normally you'd expect to be enough to change the sequence, had no effect. Googling it reveals that it doesn't work when the list of songs is already sorted on a column other than the first one, which is the list number. However, there is no indication anywhere in the interface that this restriction is in place!

Now from an implementation point of view, I can see why they don't allow it. For example, if the list of songs is sorted by Name, in ascending alphabetical order, allowing the songs to be dragged around and resequenced would be inconsistent with what the table widget is meant to
be doing.

But this is a totally inadequate user experience! If you can't drag and drop the songs while it's sorted on any of column after list number, then why couldn't they tell that to the user? There should be a drag/ drop event detectable from the GUI toolkit, so why couldn't they put in a condition like:

IF (song is being dragged and dropped) AND (songs are sorted on any
column from 2 onwards) THEN
SHOW MESSAGE "Click on 1st column before changing the order of the songs"

Unfortunately, iTunes has worked like this for a while (and so have complaints about it), so I don't think Apple will be making this operation a bit easier.

So to change the order of songs in an iTunes playlist, click on the first column to cancel out any other sorting on the list, before dragging the songs to the desired sequence.

NOTE: Make sure that the shuffle button in the bottom left is not clicked. (thanks Andrew!)

Thursday, 30 October 2008

Xpath info - don't use "/" at the end of a xpath query

Xpath info - don't use "/" at the end of a xpath query, otherwise
you'll get this error:

javax.xml.transform.TransformerException: A location step was expected
following the '/' or '//' token.

"A path expression never ends in "/", except for "/" used on its own
to refer to the root node."

Thursday, 11 September 2008

O'Reilly Maker

I'm pretty sure I've come across it before but didn't have the requisite brain cells to come up with something.

The things you do at 2 in the AM....

Sunday, 20 July 2008

Problem upgrading firmware on Billion 7300G ADSL Modem? Try using Firefox. + Hidden config pages.

I was trying to upgrade my Billion 7300G modem to firmware ver. 1.36 using my iMac, and kept getting up to a certain point and then bomb out around at the 24% mark and return an alert/dialog box that just had:

Great, talk about informative error messages!

After a bit of Googling, I found out that this problem only occurs when performing the upgrade from Safari, and Billion have supposedly promised to fix this. I But there haven't been any more firmware updates after ver. 1.36 anyway. The only solution is to use another browser like Firefox.

On another note, I've also sorted out my issues with my wi-fi at home simply by boosting my wireless signal.

My modem/wifi router is in a room on the second floor, while my main computer, a 24" iMac, is downstairs. Now the problem was the iMac would keep losing the wi-fi connection when it came back from Sleep mode. After this any open tabs in Safari would no longer work, and the only workaround I've had was to turn off Airport, then turn it back on again.

The Billion has some hidden configuration pages, and going to shows the Wireless signal is only transmitting at 70% strength! Setting the value to 100% sorted out my issues.

Google's Blogger widget for Mac OSX is rubbish

I wanted a quicker way of making posts to Blogger, so I downloaded Google's Blogger widget. Absolute crap. You can't even put a link or an image. All you can do is enter plain, bold and italicised text.

The only thing I found interesting was that it encodes punctuation marks so you end up with ' instead of the (') character. But that's probably Blogger itself, and not the widget making those changes.

WTF? It's 2008, guys. I'm sure you can do better than this!

I've never been so insulted by Google Ads!

So how are we meant to describe musicthing's audience, based on these two ads? "Overweight and buys a lot of games and DVDs"?

Quotes from Anchorman: The Legend of Ron Burgundy

It all started with me trying to clean up my hard drive, remove some movie files taking up precious space. Then I started watching Anchorman: The Legend of Ron Burgundy. I wrote down one quote that I thought was cool (the one about "I have many leather bound books..") . Then another. And another. After about two hours I decided I'd better just post what I have, then do another post later. I wonder if there's already a Ron Burgundy quotes app on Facebook? The world needs one!

Yes, I realise this has probably all been done before, and I this is all wasted effort and I should've Googled it first... but what can I say? I felt the urge! It was a labour of love. :P

"I know what you're asking yourself - and the answer is yes, I have a nickname for my penis. It's called The Octagon. But I also nicknamed my testes. My left one is James Westfall, and my right one is Dr Kenneth Noisewater. You ladies play your cards right you might just get to meet the whole gang."

"People seem to like me because I am polite and rarely late. I like to eat ice cream and enjoy a nice pair of slacks. "

"We've been coming to the same party for twelve years now, and in no way is that depressing."

"I don't usually do this, but I felt compelled to tell you something. You have ... an absolutely ... breathtaking ... heinie. I mean, that thing is good. I wanna be friends with it."

"I'm very important. I have many leather-bound books and my apartment smells of rich mahogany."

"(to Baxter the dog)You're so wise. Like a miniature Buddha, covered in hair."

"(to Baxter the dog) You know I don't speak Spanish. In English, please."

"(to Baxter the dog) You pooped in the refrigerator - and you ate a whole wheel of cheese? How'd you do that?"

"Well, I could be wrong, but I believe Diversity is an old, old wooden ship that was used during the Civil war era."

"It is anchor-MAN, not anchor-LADY, and that is a scientific fact!"

"It's terrible! She has beautiful eyes and her hair smells like cinnamon!"

"I read somewhere that their periods attract bears. The bears can smell the menstruation."

"Hey! Where did you get those clothes? At the... toilet store?"

"I will smash your face into a car windshield, and then take your mother Dorothy Mantooth out for a nice seafood dinner, and never call her again!"

"You know those ratings systems are flawed. They don't take into account houses that have more than two television sets."

"Can't say one word? Even the guy who can't think says something, and you guys just stand there?"

"But I think my son is just going through a phase. I have no idea where he would've gotten hold of German pornography."

"But you and I are mature adults who've both seen our share of pornographic materials - oh, you never have? Of course you haven't, how stupid of me, neither have I. I was just speaking in generalities.... I'll stop by the school later Sister Margaret."

"What do you say we go out on a date? Have some chicken, maybe some sex. You know, see what happens."

"It's called Sex Panther, by Odeon. It's illegal in nine countries. Yep, it's made of bits of real panther. So you know it's good."

"They've done studies, you know. Sixty percent of the time it works every time."

"Its smells like a used diaper filled with indian food!

What is that? Smells like a turd covered in burnt hair!

Smells like Bigfoot's dick!"

"I would like to extend to you an invitation to the pants party....

The party.. with the pants....

Party with pants..."

"The only way to bag a classy lady is give her two tickets to the guns show... (kisses 'guns').. and see if she likes the goods"

"But now I am too hurt.. and shocked.. and offended.. and... hurt!"

"Veronica: Mr Burgundy, you have a massive erection.

Ron: Yes... I do... I'm sorry... it's... the pleats. Essentially an optical illusion... the pattern on the pants it's not flattering in the... the crotchular region. I'm actually taking them back right now."

"This is a mistake, he's very cute... No he's not, he's not, he's hairy."

"San Diego - drink it in, it always goes down smooth. It's a fact, it's the greatest city in the history of mankind. Discovered by the Germans in 1904, they named it San Diago, which, of course, in German means 'a whale's vagina.'"

"Ron: I don't know what it means. I'll be honest, I don't think anyone knows what it means. Scholars maintain that the translation was lost hundreds of years ago.

Veronica: Doesn't it mean Saint Diego?

Ron: No."

"We have a saying in my country about people like him - 'The coyote of the desert always likes to eat the heart of the young, when the blood drips down to the children for breakfast, lunch and dinner, and only the ribs will be broken in two.'"

"Well, I have one great passion that lives deep within my loins like a flaming, golden hawk."

"Wait.. what if just for tonight we weren't co-workers - we were just co-people.

You be a woman. I'll be a man. That's all."

"Veronica and I are trying this new fad called jogging. I believe its 'jogging' or 'yogging', it might be a soft 'J', I'm not sure. But apparently you just run for an extended period of time."

"I know that one day Veronica and I are gonna get married on top of a mountain. And there's gonna be flutes playing, and trombones and flowers and garlands of fresh herbs. And we will dance til the sun rises, and then our children will form a family band. And we will tour the countryside and you won't be invited!"

"It seems our youngest, Chris, was on something called 'acid', and was firing a bow and arrow into a crowd. You know how kids are."

"This city needs its news, and you're gonna deprive them of that because I have breasts? Exquisite breasts?"

"I'm in a glass case of emotion!"

"Why are you being this way? Why can't you just be proud of me as a peer and as my gentleman lover?"

"Veronica: You have man boobs.

Ron: You've got a dirty whorish mouth. I'm gonna punch you in the ovary, that's what I'm gonna do.

Veronica: Jazz flautist for little fairy boys.

Ron: Okay, you know what - that's uncalled for! I can't work with this woman."

"Ron: There's only one thing a man can do when he's suffering from a spiritual and existential funk.

Champ: Go to the zoo? Flip off the monkeys?

Ron: No. Buy new suits.

All: YAAY!!!"

More to come once I get the urge to surge. No, I don't know what that meant.

Let's end this post on a high note. I wanna talk about love.

"Brick: I love... carpet. I love... desk.

Ron: Brick, are you just looking at things in the office and saying that you love them?

Brick: I love lamp.

Ron: Do you really love the lamp or are you just saying it because you saw it?

Brick: I love lamp. I love lamp."

You stay classy, Information Superhighway.

Thanks for stopping by.

Saturday, 19 July 2008

Video interview with Adrian Utley of Portishead at

Okay, so I really found this via good ole musicthing, but the more links to the interview the better! Still haven't decided whether I like Portishead's "Third" enough to get the CD.

Part 1:

Amazingly, his daughter actually sits still for this entire interview. I wonder if she's developed an affinity for modular synths by now. Bonus points for a really gritty sounding version of "I'm a little teapot". :P

Part 2:

More gear - mixing desks, drums

Part 3:

Mikes galore! And the el cheapo guitar used on "The Rip".

Monday, 26 May 2008

Java code to concatenate values from get__ methods of a class dynamically

Ended up discarding this code from a project, but this was a good
exercise to learn a little about Java reflection methods.

This was based on code from HashCodeBuilder in Apache commons-lang,
which can generate hashcodes via reflection - ie,

* Given an object of type clazz, go through the fields in that
class and concatenate the
* values of all the fields, excluding the ones listed in excludedFields.
* This will only work on bean-type getter methods that 1. do not
have parameters
* and 2. return a String.
* This code does not do any lookup on inherited methods.
* @param object instance where we are getting field values from.
* @param clazz the Class of the object.
* @param builder StringBuilder object to contain our concatenated values.
* @param excludeMethods fields that are not to be included in our builder.
* @throws InvocationTargetException when an error occurs while
calling a method in our object.
public static void concatenateFieldValues(Object object, Class
clazz, StringBuilder builder,
excludeMethods) throws InvocationTargetException

List excludedMethodList = excludeMethods != null ?
Arrays.asList(excludeMethods) : Collections.EMPTY_LIST;

Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods)
// only get values from public getter methods that are not
in exclusion list
if ((method.getName().indexOf("get") == 0)
&& !excludedMethodList.contains(method.getName())
&& (Modifier.isPublic(method.getModifiers()))
) {
try {

// this will only deal with bean-type get methods
without params
assert method.getParameterTypes().length == 0;

// TODO - shouldnt we explicitly check and throw
an exception here?
Object fieldValue = method.invoke(object);

if (fieldValue instanceof String) {

builder.append(StringUtils.remove(fieldValue.toString(), ' '));
} catch (InvocationTargetException e)
throw new InvocationTargetException(e, "Unable to
invoke the method: " + method.getName() +
" from
instance of: " + clazz.getName());
} catch (IllegalAccessException e) {
// this can't happen. Would get a Security exception instead
// throw a runtime exception in case the impossible happens.
throw new InternalError("Unexpected


Friday, 23 May 2008

Java generics - assigning a List<C> where type D implements interface D to a variable of List<D> - can't be done - AKA:Type Erasure ARRGH!

Java generics still confuse me.

A work colleague was asking me something about assigning typed lists
and it wasn't working the way
it would work if you were simply dealing with single variables.

Class C implements interface D.

Then we have a list of interface D.

Another class E has a method findAll() which returns a list of type C.

But we can't assign E.findAll() to a list of type D.

List<Comparable> listOne;

listOne.add(new Long(1000));


listTwo = new ArrayList<Long>();

listTwo.add(new Long(33));

listOne = listTwo;

Error: "Incompatible types, Required List<java.lang.Comparable> Found:

Hmm... maybe we can cast the list?

listOne = (List<Comparable>) listTwo;

Error: Inconvertible types; cannot cast
'java.util.List<java.lang.Long>' to

But why?

Maven IDEA plugin generating incorrect references in .ipr file in multi-module project

Is there a bug in the maven IDEA plugin when working with multi-module files?
I normally do most of my command-line work in the Cygwin environment, and
have not experienced this problem on my previous project, which was a
single-module project.

ERROR in parent project file:

- generated this when running mvn idea:idea under cygwin
- trying to open the project file results in error dialog box:
"Cannot load module file
File C:\work\Fads\C:\work\Fads\FeedProcessor\FeedProcessor.iml does not exist.
Would you like to remove the module from the project?"

<module fileurl="file://$PROJECT_DIR$/C:/work/FeedsProject/packaging/FeedsProject.iml"
<module fileurl="file://$PROJECT_DIR$/FadsParent.iml"
filepath="$PROJECT_DIR$/FadsParent.iml" />
<module fileurl="file://$PROJECT_DIR$/C:/work/FeedsProject/FeedProcessor/FeedProcessor.iml"
<module fileurl="file://$PROJECT_DIR$/C:/work/FeedsProject/FileService/FileService.iml"

- the fix is to generate the IDEA project file under DOS - mvn idea:idea
- this file is correct.

<module fileurl="file://$PROJECT_DIR$/packaging/FeedsProject.iml"
filepath="$PROJECT_DIR$/packaging/FeedsProject.iml" />
<module fileurl="file://$PROJECT_DIR$/FadsParent.iml"
filepath="$PROJECT_DIR$/FadsParent.iml" />
<module fileurl="file://$PROJECT_DIR$/FeedProcessor/FeedProcessor.iml"
filepath="$PROJECT_DIR$/FeedProcessor/FeedProcessor.iml" />
<module fileurl="file://$PROJECT_DIR$/FileService/FileService.iml"
filepath="$PROJECT_DIR$/FileService/FileService.iml" />

Saturday, 3 May 2008

OutOfMemory error when using Findbugs plugin in Maven? Set the Maven heap size via MAVEN_OPTS

I was doing a "mvn site" and I got an OutOfMemory error at the stage
where it's using the Findbugs plugin:

[INFO] Generating "FindBugs Report" report.
[INFO] No effort provided, using default effort.
[INFO] Using FindBugs Version: 1.2.0
[INFO] No threshold provided, using default threshold.
[INFO] Debugging is Off
[INFO] No bug include filter.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space

After a bit of research, I set this variable to give enough memory to
Maven, and it fixed the problem. Obviously, change the Xmx value
depending on how much RAM you have to spare.

MAVEN_OPTS="-Xmx1024m -Xms128m -XX:MaxPermSize=512m"

Other posts have mentioned that it's actually setting a MaxPermSize
higher than the default value (32m) that makes the difference. So
let's test it by just setting the first two values:

MAVEN_OPTS="-Xmx1024m -Xms128m"

Actually, it works!

INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 11 seconds

Other people have recommended setting the plugin property
"maven.findbugs.jvmargs" but I have not tried this out yet. Now in my
pom.xml, I currently have:


Which isn't actually the latest version anymore. Maybe the newest
version of the plugin - 1.2 has fixed it.. Let's change it to:


But this time, let's NOT have anything in MAVEN_OPTS. Let's see if the
newer version can do it with the default java settings. Now run mvn
site again.

(Long delay follows). Oh great, more jars to download. WTF? castor?
openejb? xstream? Hardly a build goes by where I don't get yet another
surprise download due to transitive dependencies. Am glad we have
Artifactory set up at work, so only one person has to suffer the
delays of downloading each new jar file.

No dice. OutOfMemoryError again. Let's set our heap to a smaller
figure, compared to before, see if that's enough.

MAVEN_OPTS="-Xmx256m -Xms128m"


I think this last one can be a safe starting value to use if you ever
run into the OutOfMemory error Findbugs from inside maven. I was
surprised to find out that the default heap is only 32m when JVM is in
client mode, and 64m when in server mode. See here:

Sunday, 20 April 2008

The Element Song: various versions

Got home at 2.30, after watching DJ Shadow + Cut Chemist at Luna Park
in the city... ( then checked my email... noticed a link about Tom Lehrer, who's famous for the Element Song, a crazy romp through the periodic table, sung to the tune of Gilbert and Sullivan's, "I Am the Very Model of a Modern Major-General" from Pirates of Penzance (thanks to Bob Funchess for the song title)

end result: just spent 30 minutes going through youtube, checking out
various versions of The Element Song.

Damn you Google blog!

(and he also did that song about "silent e" for Electric Company! OMG.)

my faves so far:

the original (audio only):

great version at a talent show:

sung by a 4-yr old (who kinda sounds like Martin Price from the Simpsons):

showing the elements' location in the table:

this isn't a version.. but still interesting rapping with *some* of
those elements..

Saturday, 19 April 2008

OpenSocial for MMOGs?

Woke up at 5.30 am, after dozing off last night without having dinner. Torrential rain pouring when I woke up but it's stopped now. Random browsing. Finally saw that Judd Apatow "Backlash" video that's been in an Opera browser tab for >1 month - shameless, self-aware viral marketing... lol. i think.

Came across an great post on another gaming site, "Player vs. Everything: When will the players leave WoW?", discussing why people aren't going to be leaving WoW anytime soon.

Interesting how the social aspect - in this case networks of friends from all over the net - is such a big factor in the "stickiness" of these games, whereas before it was completely based on the gameplay. It makes it much harder for rivals to make a significant dent in the market. Not only does your game need to be much more compelling, but you need to factor in that networking aspect, which goes beyond coding wizardry or eye candy.   You can't just fix pain points, or be slightly better.  You have to make it compelling enough not just for one new player, but all that player's friends to play and stay with your game. 

If you have a new player, how do you make it easy for them to move over as much of their current network to your game?   Signup bonuses? Almost-free copies of the game, which you can't really play standalone? (I think WoW already have this?) In-game equivalents of pyramid schemes? Those horrible Facebook apps do it by spamming everyone you know - actually, it's not the app, it's you doing the spamming! But how the hell will that apply to a MMOG?

It's quite similar to the stickiness of the current "web 2.0" hotspots like MySpace, YouTube... once you've built up relationships and conversations in one area, it'll be very difficult to get out and start anew, since you've built up all this content and would be loath to just throw it all away. Social networks are the new vendor lock-in. (yes, someone else came up with that)

The only sites I can think of that make it a bit easy to migrate are the blogs, but mainly because the content is fairly generic (text, tags, comments!) and easily restructrured. I can't see this model ever being applied to games - "Why sure, we'll let you move on to another MMO, no probs!"  OpenSocial for MMOGs, anyone? Of course, the question here becomes: is there anything at all that is portable across different games?

Saturday, 12 April 2008

How to run code when your Java program is being terminated? Use ShutdownHook!

The starting point for this was a problem I have at work, where we have a program that is using ScheduledExecutorService, and is meant to run continuously, but we also want to run some code when the program is terminated with Ctrl-C or a 'kill' command.

At first, I thought that a try-finally would give me what I wanted. A little bit of testing proved me wrong. The try-finally structure can handle exceptions, and ensure that code enclosed in finally is called, but only in the case where the process is running normally, and not terminated externally. The statement inside a finally{} will not execute if the JVM is terminated.

The ShutdownHook is what I needed, which was added in JDK 1.3.1.  The method to use is Runtime.addShutdownHook().  The shutdown hook is pretty much any code you put inside the that you pass to this method.

public class FinallyTest {
public static void main(String[] args) {

final int thisNumber = 9;
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
System.out.println("I am now calling my shutdown stuff. EVERYTIME!");
System.out.println("This number: " + thisNumber);

try {
boolean loopIt = true;
int i = 0;
System.out.println("Now entering infinite loop.");
while (loopIt) {
try {
} catch (InterruptedException e) {

} finally {
System.out.println("Finally has been called!");

Running the program, and then killing it gives me (this is on OS X, on an iMac):

krangsquared$ java -cp . FinallyTest &
[1] 5735
krangsquared$ FinallyTest.main
Now entering infinite loop.

Okay, we now have a process Id. Let's kill it! 

krangsquared$ kill 5735

krangsquared$ I am now calling my shutdown stuff. EVERYTIME!
This number: 9

[1]+ Exit 143 /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java -cp . FinallyTest

The only catch to this is that this will not work if you terminate the program using "kill -9".  And I haven't checked this yet on Windows to see what happens if you kill it using TaskManager. (is there a "kill -9" equivalent on XP?)

Hope this helps someone out there! Or maybe someone who has a better idea or suggestion can make a comment. I need all the help I can get.  :)

Btw, I've found a blog post with a nicer way of doing this - instead of dumping a whole lot of stuff in a as an anonymous inner class (insert. closures. proposal. here.), have another Runnable inner class to contain all the shutdown code, then pass that in to the constructor of a new Thread that you pass to addShutdownHook().

Sunday, 16 March 2008

Looking Through The Eyes of Love - chords

File under extra-cheesy. While doing some mp3 cleanup - for the nth night running - I found that I have two versions of this song. One by Melissa Manchester and the other is a version by Lea Salonga in concert.  

Blame it on my soft rock, love song-saturated childhood, but up to now I still like the song. Love it even, in my moments of supreme senti-ness. So much that I even sang it at karaoke. But only once. And with 4 other people. Way back in the early 90s. In a Chinese restaurant in Ashfield where we seemed to be the only ones who spoke English. (Or so we liked to believe, just to make us feel less guilty at inflicting our singing on them.)

And here are the chords, lifted from another page on the web that automatically plays a karaoke-ish MIDI file when you view it.  Dontcha hate those?

(Theme from Ice Castles)
Melissa Manchester

C                                        CM7
Please, don't let this feeling end
It's everything I am
                    F                F-Em-Dm
Everything I want to be
         G               Em    Am Am-Em-Dm
I can see what's mine now
             G              Em  Am7
Finding out what's true
         F   E7   Am   Am7-D7
Since I found you
              Dm                         G
Looking through the eyes of love

C                            CM7
Now, I can take the time
I can see my life
                         F                F-Em-Dm
As it comes up shining now
                G       Em   Am  Am-Em-Dm
Reaching out to touch you
         G        Em    Am7
I can feel so much
         F  E7    Am  Am7-D7
Since I found you
             Dm             G         C
Looking through the eyes of love
        Am     Em    Am
And now, I do believe
         Em          F             G              C
That even in a storm we'll find some light
Dm         Em          F                    G
Knowing you're beside me, I'm all right
Please, don't let this feeling end
It might not come again
And I want to remember
How it feels to touch you
How I feel so much
Since I found you
Looking through the eyes of love

Repeat II - Chords two frets higher

Thursday, 13 March 2008

Activating root account in OS X to enable sudo

This is the 2nd time I've had to do this and again have ended up
trawling the net for information, so I'll put it here.

If installing ruby gems, you need to do it as root or to do 'sudo gem
install [gem name]'

But you can't sudo if there's no root account!


1. Enable root

In OS X 10.5 - you do it using the Directory Utility application. Log
in on an Admin account, run Directory Utility, and in the Edit menu,
select 'Activate Root account' (or a menu item similarly named). You
then enter the root password and verify.

2. Add your normal account to sudoers file.

Run visudo - a command-line util to edit the sudoers file in
/etc/sudoers, which contains the users or group that are allowed to
su-su-sudio.. er, ahem.. run sudo. :P

Using visudo is better than editing sudoers file directly because it
prevents any changes being saved if there are any incorrect entries.
Incorrect entries are BAD news for sudoers, since it prevents you from
doing sudo, and you have to call sudo to edit it or run visudo!
(chicken or egg!)

Under the section "# User privilege specification" - add a similar
entry with your username, like:

[username] ALL=(ALL) ALL

In this case, the username is the unix user, not the long Mac user
name you see when you log in.

3. Log out of the Admin account, then try doing something with sudo, like

sudo gem install mechanize

to see the results of your handiwork.

Gurus, please send corrections if any of the above is not exactly correct!

Saturday, 8 March 2008

Maven settings.xml that uses Artifactory, and restricts snapshot repository use

Hopefully this information is useful for other people who have Maven
projects but have to use other libraries and Maven plugins that are
still in the pre-release stage.

We are using Artifactory at work as a local repository proxy for Maven.

We also have a project that makes use of some snapshot libraries for
the CXF project, which is currently under incubation in Apache.

Previously, we were just using a <mirrors> but this resulted in Maven
getting its metadata settings both from the central repository and the
snapshot locations. We ended up getting snapshots of Maven plugins
that we never really wanted, as Maven would get plugin metadata from
both the repository types, and of course, the latest version would be
the snapshot ones.

To remedy this, we had to change settings.xml so that the only time
the Apache snapshot plugin repositories are used is in the projects
that require the CXF plugin and associated dependencies. The important
thing is to make sure the id element in the repository settings match
the repository setting id in the project pom.xml. The pom.xml settings
can still point to the live, non-proxied repository, but Maven will
first look at the id in that pom file and see if there is an entry
with the same id in the settings.xml


<!-- uncomment this section and comment out the profiles section if
the Artifactory (local maven repository) is broken -->








<!-- used by SomeWebService/pom.xml The id here
*must* match what's in the pom file -->


<!-- used by SomeWebService/pom.xml The id here
*must* match what's in the pom file -->






<!-- used by SomeWebService/pom.xml The id here
*must* match what's in the pom file -->






I've seen this before but this time it made me feel more warm and fuzzy than before.

Wednesday, 5 March 2008

Maven reporting plugins - useful for generated reports in the Maven-generated project site

We're currently setting up CruiseControl at work and are looking to
have more documentation on various aspects of each project. Adding
these settings to a Maven projects pom.xml would generate a lot of
useful information that would cover our needs.




This plug-in provides functionality for accessing FindBugs
from Maven.



The JXR plugin produces a cross-reference of the project's sources.
The generated reports make it easier for the user to
reference or find
specific lines of code. It is also handy when used with
the PMD plugin
for referencing errors found in the code.
for multi-module projects, see:

The PMD plugin allows you to automatically run the PMD
code analysis tool on your
project's source code and generate a site report with its
results. It also supports
the separate Copy/Paste Detector tool (or CPD) distributed
with PMD.
This plugin is used to inform your users of the changes
that have occured
between different releases of your project. The plugin can
extract these changes,
either from a changes.xml file or from the JIRA issue
management system,
and present them as a report.


Updated 6 March 2008: Commented out the Findbugs plugin entry because I can't get it to work yet. The settings above are actually for Maven1. To use the Maven2 plugin it should be like this:


We are using Artifactory, but for some reason I get this Maven error:

[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build project for plugin 'org.codehaus.mojo:findbugs-maven-plugin': POM 'org.codehaus.mojo:findbugs-maven-plugin' not found in repository: Unable to download the artifact from any repository


from the specified remote repositories:
everything-else (,
snapshots (,
central (

However, when I got to (which is in my proxy configs), the Findbugs plugin is there at:

So why is Maven (or Artifactory) unable to retrieve this plugin?

Again, what is going on here?

I guess I should test this first by removing Artifactory from the picture, removing the proxy settings from my settings.xml. If it fails, then it's a Maven issue. If it works, maybe it's Artifactory.



Removed the Artifactory settings and Maven was able to download the plugin correctly. Maybe I should expire some caches and see if it is able to get the plugin?

Wednesday, 27 February 2008

Maven updates its plugin metadata then says it can't find the plugin - WTF?

Trying to generate the IntelliJ project files for a Maven 2 project.
Then I got an error:

mvn idea:idea
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'idea'.
[INFO] artifact org.apache.maven.plugins:maven-idea-plugin: checking
for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.apache.maven.plugins:maven-idea-plugin

Reason: Error getting POM for
'org.apache.maven.plugins:maven-idea-plugin' from the repository:
Failed to resolve artifact, possibly due to a repository list that is
not appropriately equipped for this artifact's metadata.

from the specified remote repositories:
central (

Now I look in my Maven repository, in the maven-idea-plugin directory, in


and I find the maven-metadata-central.xml which has this:

<?xml version="1.0"?><metadata>

But when I look in the location:

And get the maven-metadata.xml, it has:







The only possible reason I can think of for this happening is that
Maven is getting the metadata from somewhere else. We are using
Artifactory and one of the repositories we have set up is an entry
pointing to
The artifactory.config.xml contains this:


Now in this repository, there is a directory for maven-idea plugin, at

and there is a file
that contains:


Now the strange thing is that this info is not exactly the same as
what's in my local repository. So it looks like the
maven-metadata-central.xml I have for maven-idea-plugin did *not* come
from this location. So where did it come from? I should probably add
to the exclusion list for the above repository so it doesn't try and
get maven plugins from there. But from the error message I got, it
looks like it only goes to the central repository at
for plugin updates. If that's the case, why does it seem to go
somewhere else for it's plugin updates?

What the hell is Maven actually doing?

Thursday, 21 February 2008

Maven woes # 2923928923829: Maven metadata not reflecting what's on maven repository

(File under "Maven!!! GRRRRRR!")
Alternate longer title: What the hell is wrong with Maven and why do
they push out these SNAPSHOT plugins with releases to other SNAPSHOT
jars that don't even exist? As a matter of principle, should you
really be forcing non-release, snapshot software upon your users?
Here's what I was getting:
Error: Reason: Error getting POM for
Unable to run Maven archetype because it is trying to download a
plugin that it can't get from the central Maven repository.
Turns out it's because of an inconsistency between the settings it has
in the location
and what is actually on
C:\dev>mvn archetype:create -DartifactId=my-app
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin:
checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).

Project ID: org.apache.maven.plugins:maven-archetype-plugin

Reason: Error getting POM for
'org.apache.maven.plugins:maven-archetype-plugin' from the repository:
Failed to resolve
artifact, possibly due to a repository list that is not appropriately
equipped for this artifact's metadata.

from the specified remote repositories:
central (
for project org.apache.maven.plugins:maven-archetype-plugin
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Wed Feb 20 17:35:46 EST 2008
[INFO] Final Memory: 1M/254M
[INFO] ------------------------------------------------------------------------

1. Go into
rename this file or delete it.
2. Get the file
Download it to .m2\repository\org\apache\maven\plugins\maven-archetype-plugin\
and save it as maven-metadata-central.xml
3. Rerun the above process
mvn archetype:create -DartifactId=my-app
now maven metadata is pointing to files that actually exist on the repository.
But the big questions here are:
Why is there a discrepancy at all? What other repositories could the
maven-metadata-central.xml be talking about if not the main Where did the maven-metadata-central.xml come
from anyway?
As a matter of design, why do I end up receiving - without my asking
for it - bleeding edge snapshot plugins? Shouldn't the policy be to
only use release versions?
Okay, maybe this argument is not really valid in this instance because
we are talking about the archetype-plugin. From the looks of what's on
the repository, it went out as 1.0-alpha-3 then to 1.0-alpha-5, then
1.0-alpha-7 - and now it's at 2.0-alpha-1. Good god, is this thing
*ever* going to get to an actual release number, one that doesn't have
greek letters after the .0?

Update on 6 Oct 2011:
NOTE: As commenters below have pointed out, the mixup normally occurs when you are - probably unknowingly - getting artifacts from both release and snapshot repositories.
The thing to remember is to make a distinction between release and snapshot repositories. The fact that you are pointing to a public repository is not enough. A repository obviously has to be public so that other people can access it. The question is: what types of artifacts are the repository providing? They may actually have both types.  

Friday, 15 February 2008

iPhoto alternative found! Photo Mechanic - retains your directory structure, doesn't have its ownf format for your photos, allows editing of EXIF metadata

I've been trying to move my photos to my new iMac, but the vexed issue
of whether or not to use iPhoto is.. uh, pretty vexing. I've heard
iPhoto stores all of its photos in pretty much one database file, and
I've got about 50Gb of photos accumulated over the past 5 years, so I
want to be sure that 1) it won't slow down to a crawl and try to load
all my photos every time it runs; 2) will retain any EXIF information
I have in them and allow edits to them as well.

I found this blog entry about a program called PhotoMechanic that
seems to fit the bill and do a lot that I've gotten used to in Picasa
on the PC. It retains all the photos in their own directories,
according to how I've organised them, it allows editing of a *lot* of
EXIF metadata (which on the PC i perform using the excellent utility
Exifr), and it doesn't force you to add them to its database of

It doesn't allow photo editing, and is not as good at slideshows, but
I don't do much of the latter anyway. I hope I find a clean way of
integrating the photo editing into my photo workflow.

I'll download it and see if it's a better fit with the way I use my photos.

<2 minutes later>

Oh great. They don't sell it online.

"We do not have web sales setup yet. To place an order for the
products above, please contact Camera Bits, Inc. directly. We accept
Visa, Mastercard, and American Express credit cards for payment."

Haven't these people heard of Kagi? (
Shareware vendors have been using this for years!

Where is my Picasa for OS X? Pleeeease, Google-matrix-skynet, out with
it already! But put in a plug-in architecture so that people can
develop Flickr uploaders. I know you have your Picasa Web Albums but
it's not in the same league, not even the same country, not even the
same planet as Flickr.

Thursday, 14 February 2008

I've never been to me

I'm feeling kinda emotional tonight, as I found out that my bank
balance is NEGATIVE, which kinda threw shit on my plans to have a
romantic Valentine's dinner with my wife at the local Vietnamese

Now when I find myself in times of trouble, I turn to the classics. In
this case, the nearest one on hand was Charlene's "Never Been To Me".
I'd never listened to it closely before, but I worked out the part
where she's doing the narration, and I didn't realise it's actually a
bit of a cynical song.

"Hey, you know what paradise is? It's a lie, a fantasy we create about
people and places as we want them to be.

But you know what truth is? It's that little baby you're holding. It's
that man you fought with this morning, the same one you're going to
make love with tonight.

That's truth. That's love."

D'ya hear that people?


Now if that ain't fodder for your next up-and-coming emo band, I don't
know what is. Come on kids, work on those Charlene samples and get
'em into those anthemic choruses! I believe in you! Yizzgaarnoff,

That's the truth. That's love.

Wednesday, 13 February 2008

Configuring Subversion authentication using Windows Active Directory and Basic Auth from a file - problems encountered and workaround

At work we use Apache+SVN+SSPI to authenticate to Subversion using
Windows authentication. This keeps everyone's SVN logins updated
whenever their network logins change. All well and good, but then we
had to set up a build server using Cruisecontrol, and we are not able
to get a Windows network username for that. So we had to create a user
set up in a config file, and use Basic Auth for that.


The first attempt at configuring Apache's httpd.conf, which was the
example show in other blogs and forum posts was something like:
# Location of our Subversion repository
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath "D:\repository\svn"
AuthName "Subversion repositories"
AuthType SSPI
SSPIAuthoritative Off
SSPIOfferBasic On
# need to set this up so only select users/ group can have chk-in access.
# might want to restrict who can read as well.
# make sure this file is outside the SVNParentPath
AuthzSVNAccessFile "D:\repository\svnaccessfile.txt"

AuthType Basic
# make sure this file is outside the SVNParentPath
AuthUserFile "D:\repository\svn-httpasswd.txt"
AuthBasicAuthoritative Off
Require valid-user

The problem was it never worked. The Basic Authentication never
worked. Only the Windows Authentication allowed me to get in.


So I ended up creating another Apache <Location> for use solely by
CruiseControl. And this has worked fine without any problems.

# Location of our Subversion repository
<Location /svn>
DAV svn
SVNListParentPath on
SVNParentPath "D:\repository\svn"
AuthType SSPI
AuthName "Subversion repositories - Active Directory authentication"
SSPIAuthoritative On
SSPIOfferBasic On
# need to set this up so only select users/ group can have chk-in access.
# might want to restrict who can read as well.
# make sure this file is outside the SVNParentPath
AuthzSVNAccessFile "D:\repository\svnaccessfile.txt"
Require valid-user
# we were unable to get the /svn working to use BOTH Active Directory
and Basic Auth from a file,
# so we have to set up another one.
# Location of our Subversion repository used only by CruiseControl
# all others should use the standard /svn URL defined above
<Location /cruisecontrol>
DAV svn
SVNListParentPath on
SVNParentPath "D:\repository\svn"
AuthName "Cruisecontrol Subversion repositories"
AuthType Basic
# make sure this file is outside the SVNParentPath
AuthUserFile "D:\repository\svn-httpasswd.txt"
Require user cruisecontrol

Tuesday, 12 February 2008

GTD - toread

I have yet to achieve GTD nerdvana. Feeling a bit overwhelmed with my
lists, not checking them enough, and haven't implemented enough task
breakdowns and specific, more physical "Next Actions". Actually, I
only have a big to-do list, not broken down into Projects (with more
than one action) and simple To Do list. And I don't have that Someday/
Maybe list.

I mentioned it to a friend and he sent me a link:

Then all these links got added, as the article links to these, etc etc.

Then found software that looks perfect for GTD (and it's free):

Sunday, 3 February 2008

Email to Flickr about Microsoft bid for Yahoo + Flick reply

Sent this email to Flickr recently, just to tell them I care. Yes, I truly do:

"I am terribly depressed about the news of the Microsoft bid for
Yahoo. Would there be any way on earth of ensuring that MS keep their
fists of ham away from Flickr, thus keeping it as the world's best
photo sharing site? Somehow, I think the answer is no. The very least
they would do is re-brand this sucka, which I can live with. But
almost certainly they won't leave it at that. That would be too
different from past behaviour.

I can't imagine that this mass acquisition of web properties won't tie
into their grand scheme of "fixing this platform independent internet
problem". Of course they'd use this to extend their hold on the
desktop. A Flickr uploader that requires Vista *and* Silverlight?
Start boning up on your .Net, guys... And maybe they'll get some of
those ad dollars going to Google... ads and IE-only pages on Flickr,
even for paid users... coming soon.

Good thing I don't keep stuff on Yahoo Mail, or I'd be in utter torment. "



And last night got a reply from Flickr:


Thank you for contacting Flickr Customer Care.

On January 31, 2008, Yahoo! received an unsolicited proposal from Microsoft to acquire the Company. The Company's Board of  Directors will evaluate this proposal carefully and promptly in the context of Yahoo!'s strategic plans and pursue the best course of action to maximize long-term value for shareholders.

We remain committed to you and to continue to provide you with industry-leading products and service.

Thank you again for contacting us. If you have any other questions, please feel free to reply to this email.


Flickr Customer Care"

Saturday, 2 February 2008

Unix tips: count total number of lines in a directory tree of files

to count the number of lines in a subdirectory of files.

find monthly_reports/ -iname '*.csv' \
| xargs -n 1 wc -l \
| cut -d' ' -f1 \
| (SUM=0; while read NUM; do SUM=$(($SUM+$NUM)); done; echo $SUM)

PROBLEM: this has trouble if file names have spaces in them.

To find out how many lines in total are contained in a subdirectory of
files, there is the "Wc" command, which is a recursive version of "wc"

Wc -l monthly_reports/*/*.csv

-l specifies count the lines

Tuesday, 15 January 2008

Problems connecting to WiFi from 24" aluminum iMac

I finally solved my problem connecting to my wireless router. I couldn't believe that I was having more luck connecting to my neighbour's unsecured WiFi connection than to my wireless modem/router (a Billion 7300G) in the same room.

My wireless setup was:

Channel 6
Encryption: AES

Now all along I was thinking it was one of these reasons:

1. the Airport card was faulty
2. it was an OS X config problem - WPA2 encryption-related
3. it was a Leopard problem

Now I was really hoping it wasn't #1, because it would have been a royal pain in the ass to try and send back a 9kg computer in the mail. It didn't seem likely because I was able to connect to my neighbour's wifi network without problem. Which leads us to #2 - well, no way was I going to leave my connection unsecured, but just to test out this theory, I turned off the wifi security for a while. And for a couple of times it worked - I could connect to the network and use a browser, etc. Until it stopped doing it.

The last one was #3, and I was all ready to update to 10.5.1 - but I remembered that when I first set up my wireless connection I was using Channel 1. I moved to Channel 6 because I was getting some trouble connecting from the Powerbook downstairs. So I hooked up the iMac to the router, changed to Channel 1, unplugged from the router - voila! all working!

I later found a forum posting ( which claimed that Apple engineers had mentioned a conflict between Bluetooth and Channel 6 on wifi. Looks like that was the problem I was having. Bluetooth is on by default, so I turned it off. But I haven't changed the router back to Channel 6. I figure it's better to leave things alone once they work!

Solution to Problem:

4. change wireless channel from channel 6 to channel 1. In some cases Channel 6 conflicts with Bluetooth. So either turn off Bluetooth or stop using Channel 6.

Thursday, 10 January 2008

To get listing of directories use ls -d */

I've been trying to get a listing of the directories contained in two
different directories so i can compare their contents. The usual 'ls'
returns too much info. Finally got it working with:

ls -d */

- gets listing of directories ending in /
- will not get the '.' entry

Wednesday, 9 January 2008

Problems installing mysql gem on Centos? Try installing the mysql development headers first

Was trying to install the mysql gem on a Centos linux server, but was having a problem. It was like:

> gem install mysql
Updating metadata for 6 gems from
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.

/usr/bin/ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:

Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

I managed to fix it by installing the mysql development headers first. We had already downloaded it onto the server, so instead of using yum, we used rpm -i to install it. Yum wouldn't have worked anyway, because we were using Mysql 5.1.22, which is not yet on the yum repository (only 5.0.45 is there).

rpm -i MySQL-devel-community-5.1.22-0.rhel5.x86_64.rpm

[root@cr1sescl01 mysql]# gem install mysql
Updating metadata for 32 gems from
Building native extensions. This could take a while...
Successfully installed mysql-2.7
1 gem installed