Skip to main content

Posts

Showing posts from 2009

Shorten links to be Twitter-friendly with j.mp

Any Twitter users out there will know that URLs and 140 characters don't really mix that well, especially if you actually want to talk about the link as well!  Typically you would use a URL shortening service such as the original tinyurl.com or one of the newer, shorter versions such as bit.ly.

Well there is a new kid on the block who's even shorter: j.mp

J.mp is another member of the bit.ly family just with two less letters, but it's going to be perfect for Twitter.  I use the bit.ly bookmarklet to generate my links but it appears that there is not a version for j.mp yet, so I created my own:

Drag this link to your browser toolbar to get started:    Shorten with j.mp

Technorati Tags: , , , ,

Summary of December's Manchester Spring User Group Meeting

The December Spring meeting was held on Tuesday 1st December at the same venue as previous meetings. Two talks were lined up: one on Grails by Adam Evans and one on Spring 3.0 by Rick Evans.

Guy Remond of Cake Solutions started the evening off with introductions and explained that the Spring User Group was going to be expanding to become the 'Open Source Central User Group' so as to attract a more diverse audience. He also discussed the Open Source Central website which has plans to become the 'Hub for successful Open Source Enterprise Application Development'. It's going to pull various blogs together into one central place as well as offering video and podcasts of open source technologies. We were also some of the first people to get a physical copy of the Open Source Journal, a 5,000-copy print run (sponsored by Hays IT).

Practical Grails Demonstration by Adam Evans of CTI

Adam started his presentation with a brief run through of what is Grails, what is Groovy

Don't miss the December Manchester Spring User Group on Tuesday 1st December

There was a little doubt recently if this event was going to take place as the main speaker had to pull out at the last minute.  We now have a new and excellent speaker Rick Evans talking about Spring 3.0 - Weapons for the War on Java Complexity".

Doors open at 6pm and the main keynote normally starts around 6:30 (a chance for coffee and a chat before hand).It's in the usual place, just don't forget to register if you plan on going!

Technorati Tags: , , , ,

Paste Email Plus - perfect for multiple text snippets in Firefox

I've found recently when commenting on various blogs that I want to add a little footer to the comment with my name and blog address. For one or two comments typing it out by hand is fine but after a while I decided to try and find an automated way to deal with this issue.

So I was looking for something that allows me to enter multiple lines of text and then very easily insert this text wherever I choose. Well I quickly found the perfect solution - a Firefox add-on called Paste Email Plus by Chuck Baker.

You simply open the Paste Email Plus options window, enter a 'Label' to help identify this text, then enter the multi-line text in the 'Pastetext' field and click 'Save changes':




You are now set up and ready to start pasting that text snippet, in any area where you would normally type text just right-click and select 'Paste Email Plus' (below 'Paste' on my system) and then choose your labelled snippet:




You will now see your text chunk past…

JavaScript splits & matches with regular expressions (regex)

I had been developing some client-side validation code in jQuery/JavaScript and using Firefox (and the excellent Firebug) to test and debug it. I was then asked to ensure that it worked in IE6 & IE7 and that's when the problems started.

Apart from the usual "which file does that line number equate to, and why does it not tie up?" issues I found that IE doesn't like taking a regular expression as it's parameter to the JavaScript split function. Firefox will happily accept this and works fine but IE doesn't. After some searching it appears that Firefox might be the odd one out and that it's non-standard to pass in a regex.

So what do you do if you want to split up a string based on a regular expression or rather a rule that can't be simply expressed in the way that the split function wants it? Wouldn't it be nice if you could ask if a string matches a regex but then use certain matched bits of the string in your next few lines of code?

Well …

How to disable the auto-completion 'bell' in Cygwin (using RXVT)

If you have ever hit TAB a few times in bash (via RXVT) you will probably be greeted with the loudest 'bell' your PC can muster. After a while this gets pretty annoying so here's how to disable it if you are using RXVT inside Cygwin (this might work for other Cygwin terminals, I've just not checked)

Navigate to your home directory (normally just by typing cd and either edit or create a file called .inputrc

Add the following lines to the .inputrc file:# Disable the annoying bell set bell-style none Save the file, close the terminal and reopen - you should now be bell-less!

Technorati Tags: , ,

How to get Scala working with the RXVT terminal on Cygwin

Out of the box Scala support Cygwin, but this is only with the Windows command prompt-based bash terminal. If you have opted for the more UNIX-like terminal of RXVT then you will find that although the interactive Scala interpreter runs, you can't get it to do anything!

This has been raised as a bug (Ticket #2097) against the Scala project and graehl even posted a patch to changed the generation of the scala runtime scripts.  As my Scala install was based on the downloaded Windows binaries (scala-2.7.6.final.zip) I couldn't directly use this patch, but I could examine it to see what graehl's fix was.

It appears that the key bit was to add the following Java command line option to the java statement that starts the scala interactive interpreter:-Djline.terminal=jline.UnixTerminalSo the last line of my bin/scala file is:exec "${JAVACMD:=java}" $JAVA_OPTS -cp "$TOOL_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.classpath="$CLASSPATH" -De…

The next Manchester Spring User Group meetup is 13th October

Details of the next Manchester Spring User Group meeting are now available, as a taster for what it could be like I blogged about the last meeting. It looks like the main talk is going be from Jonas Partner on Spring Integration.

It's a 6pm start in the usual place (there's a lovely space-age building where the building site is on Google maps...) Remember there's free parking if you pull up to the barrier and mention the Spring User Group.

Hope to see you there - if you see a skinhead with glasses please come over and say hello! Oh and make sure you register to be guaranteed entry!

Technorati Tags: , , , , ,

Use Pidgin? Send screenshots with this great new plugin!

I've been a big fan of Pidgin (formerly Gaim) for the past few years and one feature that I've always wanted was an easy way to send a screenshot to a buddy.

Well Raoul Berger obviously wanted it too and he's gone and developed the excellent 'send screenshot' plugin. Download and install it and make sure you have enabled it:


Then you can right-click and buddy in your buddy list and choose 'Send screen capture...' - your screen then darkens and you have a crosshair with which to select the region that you would like to send to you 'buddy':


You can also send a screenshot within a existing conversation by choosing the 'Convesation' -> 'More' -> 'Send screen capture...' option:



Another and fast, better way is to ensure that you have 'Show detailed information' selected in the 'Conversations' tab of the preferences and then you can simply right-click on the person's banner and select the option:


Also, af…

You NEED an X-mini II speaker for your MP3 player or iPod

My wife was looking around for an external speaker for her MP3 player and in our searching we came across the XMI X-Mini speaker on Amazon. This little mono speaker has 105 five star reviews (out of 115) on Amazon and at the time was £20 (it's now £16.96 - was £15 for a short time).

It's an absolutely cracking speaker - the internal (rechargeable) battery lasts for hours and this thing can really pump it out - with the bass expansion chamber opened up it sounds amazing. We have used it as a speaker for an MP3 player as well as an output speaker for a guitar headphone amp - true rock guitar sound on the move!

If you are on the look out for a mini speaker for your MP3 player you will not be disappointed with an X-Mini!

Technorati Tags: , , , , ,

Summary of August's Manchester Spring User Group Meeting

The August Spring meeting was held on Tuesday 11th August at the same venue as June's meeting. The location was the the excellent University of Manchester Core Technology Facility which has free parking immediately outside the building, just press the buzzer and mention the Spring User Group and they let you in. The evening was introduced by Guy Remond of Cake Solutions who laid out the agenda.

The first talk was by Cornel Foltea of Cake Solutions entitled:

Hello World! (OSGi debugging in IDEA)

Cornel started out by giving a little overview of OSGi including a walk-through of the layered approach that the Open Service Gateway Initiative takes. He pointed out that it's key objectives were:modularization
versioning
services
access controlThe key component of any OSGi system is a 'bundle' which get deployed into an OSGi container. A bundle can then be dynamically installed, started, stopped, updated and uninstalled. They are modular in nature 'assuming nothing' - the…

Installing Ubuntu inside Windows XP using VirtualBox

Since moving companies over a year ago I've missed my Ubuntu desktop having moved back to development on Windows. I've had a few comments that some of my old Ubuntu blog posts are now out of date and I've wanted a way to ensure that they remain 'correct'.

After discussing virtualisation with a friend I opted to install VirtualBox - an open source virtualization tool which is free and easy to get going. This blog post contains my installation notes from installing VirtualBox and then creating an Ubuntu9 virtual machine...

First I downloaded the latest version of VirtualBox (version 3.0.0) and selected the "VirtualBox 3.0.0 for Windows hosts". Then I downloaded the latest version of the Ubuntu Desktop edition.

After both of these were fully downloaded I double-clicked the VirtualBox installer and choose to install everything.When the "not passed Windows Logo testing" alerts pop-up choose to "Continue anyway" then register if you wish.
Onc…

Better Java Dates, Times & Calendars with Joda-Time

Anyone who has used Java to manipulate Dates will know that it's one of the most frustrating parts of the core APIs - it should just be so easy!

As an example, here is one way to create a 'date of birth' Date - in this object we want the time part of the Date to be all zeros (midnight):import java.util.Calendar;
import java.util.Date;

Calendar calendar = Calendar.getInstance();
calendar.clear();
calendar.set(2004, Calendar.JULY, 10);
Date dob = calendar.getTime();There are a few gotchas to be aware of here, first is that you can't specify the month value as just "7" or "07" as that would give the month as August (as month 0 = January!) and the other is that without the call to clear() the time part will be set to the time when the Calendar.getInstance() was called.

Now compare this to creating a 'date of birth' Date object using Joda-Time:import org.joda.time.DateMidnight;

Date dob = new DateMidnight(2004, 07, 10).toDate();The DateMidnight class ind…

The next Manchester Spring User Group meetup is 11th August

Following on from an excellent gathering in June, Guy Remond (MD of Cake Solutions) has announced the details of August's meeting:

"Introducing Spring Batch 2.0 plus Spring Framework 3.0 update" by Dave Syer:
Well known as lead committer to the Spring Batch project as well as having a major influence throughout SpringSource, Dave will be sharing insight into the use of Spring Batch, showing some demonstrations and unveiling enhancements (scalability, XML config, Java 5…) within Spring Batch 2.0. In addition he has promised some interesting thoughts on the long awaited Spring Framework 3.0.There was a brief mention of Spring Batch at the last SUG meeting so I'm looking forward to finding out more...

Oh, don't forget to register for the August meeting over on the Spring User Group website.

Technorati Tags: , , , , ,

Supporting the Oracle XMLTYPE datatype via JPA (Spring, Hibernate & JDBC)

On a recent project I was tasked with developing two domain objects which mapped via JPA to a couple of tables. This would have been easy apart from one table used the the Oracle-specific XMLTYPE data type:create table PERSON
(
P_ID number not null,
P_NAME varchar2(50),
P_UPDATED date,
P_XML xmltype
);The XMLTYPE datatype is not supported by JPA (or any Hibernate-specific annotations) and so I had to use a different approach. I created the JPA-based Person class as normal, adding @Column annotations to the class, ignoring the P_XML column. I then added the following bit of code to be a placeholder for the XML:@Transient
// required so that JPA doesn't try to persist it, we need JDBC for that
private String xml;I then developed the JpaPersonDao as normal, using the getJpaTemplate() methods to select, insert and update the database. This handles all the columns except the XMLTYPE one - you need to use JDBC for that one due to the way in which Oracle expects the column to be filled an…

MP3 purchase comparison between Amazon.co.uk & Play.com

My first foray into purchasing MP3 was from Amazon.co.uk some months back. It was a smooth experience much like buying anything else from Amazon and it's quirky MP3 downloader popped the nicely named MP3 files into my music folder in the normal directory structure of Artist name/Album name/track number & name.

This week I purchased an album from Play.com's MP3 catalogue due to it being a little cheap than Amazon. It's download format was a large zip file that had to be saved to the desktop, it's content was just the tracks - no artist/album directory structure, no track numbers. Because I don't have an iPod I had to look up the track listing on the net and rename the files just to put them in the right album order!

Next time I want to buy some music online I think I will be skipping Play.com's offering completely and paying the little more that Amazon.co.uk was charging - it will be worth it to just have my music just download straight into the right place …

A new way to label in GMail (and the end of Right-Sided Labels)

Back in March I blogged about my favourite GMail labs. One of them has died today - Right-side Labels.

Google are grouping labels together with Inbox, Drafts, Chats and other system labels, and so putting the labels over on the right-hand side doesn't make sense anymore.

The problem is, my GMail's not been updated yet so I can't play with the new features! :)

Technorati Tags: , , ,

Be careful writing hashCode() methods when using HashCodeBuilder

I've blogged in the past about using the Apache Commons EqualsBuilder and HashCodeBuilder to write simpler equals() & hashCode() methods.

My colleague recently blogged about a potential pitfall when using this approach, I'll summarise his findings here:

Be VERY careful when you ask the HashCodeBuilder to generate the resulting hashcode value:

Make sure you call builder.toHashCode() rather than builder.hashCode()

The first correctly generates a hashcode value based on the objects that you have added to the builder, the second gives you the hashcode of the builder object itself - definitely not the value you would be expecting (and would be a sure fire way to lose your objects in a Collection)...

Technorati Tags: , , , ,

How to escape text when pasting into Eclipse (including XML)

When you paste text into Eclipse it does just that - places where the cursor is in it's full un-altered original form. This is fine most of the time apart from when you might want to copy a chunk of XML (or a similar large body of text). What you end up with in this case is the text pasted in with red lines everywhere because the text hasn't been properly escaped for Java code.

To enable escaping of pasted text open the Preferences panel ('Window' menu -> 'Preferences...' option), then choose: 'Java' -> 'Editor' -> 'Typing' and tick the box which says "Escape text when pasting in a string literal":


Now whenever you post in text which is broken over multiple lines, Eclipse will insert the relevant quotes of Java to make Eclipse happy.

Technorati Tags: , , , , ,

Summary of June's Manchester Spring User Group Meeting

I missed the first Manchester Spring User Group meeting back in April which I heard was excellent so I made sure I didn't miss June's meeting.

The sessions (based at the University of Manchester Core Technology Facility - cool building BTW) were organised by Cake Solutions (in particular their MD Guy Remond) and it was Guy that introduced the evening and laid out the agenda. Just a quick note about the venue, it's a very new tidy building, the room was an excellent size (seating for 50+ people) and coffee (and cake!) were provided. Parking was free and immediately outside the building, just press the buzzer and mention the Spring User Group...

The first talk was by Paul Sweby (of CapGemini) entitled:

Spring in Government - Improving System & Personal Performance

Paul works on the HM Revenue & Customs website and started his talk by providing some pretty impressive statistics: around 40 million tax payers use the HMRC web site for various purposes. The software is de…

Improving slow wifi bandwidth performance on an Acer Aspire One

We've noticed over the past few days that it was taking a long time to download stuff on our Acer Aspire One. Tonight I found out that it was only slow when it was unplugged from the mains - so it's a power-saving 'feature'. I couldn't find any options within the power saving section of Windows control panel, so it was off to google for some help.

Within seconds I found the perfect solution explained very clearly over on Peve's Blog. I'm not going to repeat his instructions as he explains it great already so head over there to read his post entitled Acer Aspire One Slow Wifi - Thanks Peve!

Technorati Tags: , , , ,

How to copy recorded TV programmes off your PVR (Humax 9200T)

We have had a Humax 9200T PVR for quite some time now and occasionally we have wanted a more portable copy (think DVD) of a particular programme that we have recorded.


If you flip down the right-hand panel you will notice an unlabelled standard USB B socket. It's by the use of this socket that you can stream recorded programmes off the Humax and onto a PC ready for converting to a DVD (or just watching on the PC).


Here's how you do it:

Visit Humax's support site and download & install their rather old and flaky Media E-Linker software (Click the "Media E-Linker software (Version 2.5) download link).

Get a regular USB lead with an 'A' type plug on one end, and a 'B' type plug on the other. Plug the 'B' end into the Humax, and the 'A' into any USB socket on your PC. Your PC should now 'find' the Humax and request to install the drivers, I let mine 'auto-search' and it found and installed the drivers just fine (I think t…

The Spring User Group comes back to Manchester on June 15th

Back in March I blogged about the first North West Spring User Group meeting. Well on the 15th June they are coming back to Manchester. I wasn't able to attend the last one but an old colleague Bill Comerattended the session.

June's session is on "Grails eye for the Spring guy" by Russ Miles (MD of OpenCredo). Russ has also blogged about the future talk over on his blog. It sounds good and I'm planning on attending this time so if you see me there come over and say hi!

Technorati Tags: , , , , , ,

Replace your broadband provider's DNS servers with OpenDNS ones for more reliable service

I had an 'internet issue' last week when around 10am my connection to the internet was lost. Well not completely lost - my work PC (a remote box accessed via VPN) was still working fine so I still had a connection (at an IP level), but I couldn't visit any websites. The problem was that Pipex's DNS servers were offline (I couldn't ping them) and it wasn't planned maintenance.

So I replace them with settings for the free OpenDNS servers. These DNS servers are used by millions of people around the world, I suppose I've not migrated to them before because I've not had an issue until now. The migration couldn't have been easier - I logged into my router, accessed the 'internet settings' menu option, and selected 'DNS'. Then I unticked the "Automatic from ISP" box and entered the OpenDNS server details in the IP address boxes:


The OpenDNS DNS server IP addresses are:Primary DNS Server: 208.67.222.222
Secondary DNS Server: 20…

JSTL date comparisons with the current time (now) in JSPs

When you are coding JSPs and using the JSTL tags you will often be presenting information captured in a domain object, using the JavaBean-style getters to pull out the values within the JSP page.

What do you do if you need to show some text if the date stored within the domain object is before (or after) the current time?

There are many wrong or messy solutions - polluting the domain object by adding a method to 'get' the text to display, do the comparison in the controller and add the text to display to the request, etc.

One clean way is to use the jsp:useBean tag to create a page-scoped variable containing the current date/time and then use normal JSTL to compare the objects.

First create the page-scoped java.util.Date object (using jsp:useBean), then use ${now} to reference the current date/time. This is a regular JSP object now and so the normal JSTL operators work with this variable:
<jsp:useBean id="now" class="java.util.Date"/>

<c:if test="${…

Acer Aspire One: Backing up the hidden Windows XP factory image partition

My wife recently got the Windows XP 160GB version of the amazing popular Acer Aspire One (this seems to be the only netbook people ever have!).

I'd heard from a friend that we should save off the backup image which is preloaded onto a hidden partition (called PQSERVICE). But how do you gain access to the partition in order to save it off?

After much research I came up with the following options:Install Linux on a USB pendrive, boot from that, then save the partition using Linux tools
Hack the master boot record to remove the 'hidden' attribute of the partition, then save it somehow
Numerous other tough/dangerous/involved methods
Follow my method below which is easy, safe and free!Here are the steps you need to follow to be able to save off a backup image of the factory install of your Acer Aspire One as well as save a copy of your Master Boot Record (MBR) incase your hard drive dies...

Saving your hidden PQSERVICE partition

Download the free version of Macrium Reflect and insta…

Easy, collaborative web UI mockups with Balsamiq

Every now and again you come across a tool that is so easy to understand, so fast to use and so effective at conveying it's ideas that you just have to tell people about it. One such tool is Mockups by Balsamic.

It's a web page mockup drawing tool written using Adobe Air which provides a palette of HTML widgets with which to 'draw' your screens. It has a querky 'freehand' style which lends itself to conveying the components and ideas that a web page should have without forcing the designer to code it up in HTML (or for the customer to think that because the HTML is done, the app must nearly be ready...).

Here is a very simple web page for search and listing users which I 'mocked up' in less than 10 minutes:
As you can see it's got a number of standard HTML widgets on it as well as a very useful 'post it' note allowing you to add distinctive notes and comments to the mockups themselves. So this in itself is enough to warrant using it to creat…

JSTL 'forEach' looping tricks using varStatus

Do you have a JSTLforEach loop in your JSP page displaying a list of results? Have you ever wanted to do something different for each row, or maybe do something for all but the last row?

varStatus is what you want!

You declare a new variable within the main forEach JSP block which will allow you to access the internal loop counter of the for-each loop. Then you can call a number of methods on that object to be able to do conditional processing.

The code example below will display a horizontal rule under each item apart from the very last one:<c:forEach var="thing" items="${things}" varStatus="status">

<a href="${thing.link}">${thing.description}</a>

${not status.last ? '<hr/>' : ''}

</c:forEach>The important bits of the above snippet are the varStatus="status" and status.last. The first one defines a 'status' variable, and the second one accesses it to ask if this row is the &#…