Tuesday 14 June 2011

Maven Command Line from Eclipse

Eclipse comes with a bunch of maven support but if you want to avoid going back to the command line to type in your particularly obscure command you can use external tools configuration to get a prompt in Eclipse.

In Eclipse click External tools -> External Tools Configurations then add a new launch configuration. Then simply add:
  • the location of your maven installation
  • use ${project_loc} as your working directory
  • use ${string_prompt} in arguments
Here's what my configuration looks like:
Now you can run that from the external tools drop down menu and you'll get a command prompt. Then just type in your favourite maven command.



Enjoy!

Monday 7 February 2011

Fixing Linux after installing Windows on dual boot system

My daughters are back to school this week so I decided I should install Windows 7 on a spare hard drive in my machine, as they say that sometimes they need to use Windows specific programs. In fact, one of their peers told me his IT homework consisted of following a step by step guide of clicking through a worksheet in a particular flavour of Office (I think it was 2010) and apparently he would fail by using any other version. If this is the case, its a sad state of affairs for IT learning but that's a whole other rant.

Up until now, I've been super happy with Linux, specifically Mint although I've played with Ubuntu, Fedora and Suse but figured if I don't install it now the night that they've got some assignment to complete, I'll have to go through the install pain so might as well have it ready.

Anyway in order to install Windows I had to unplug my main hard drive and leave just the soon to be Windows drive because apparently Windows has a drama if there is more than one drive present. This one drive had previously had Ubuntu on it. I booted from the CD and ran through the lengthy install process. Once it was all installed I rebooted a couple of more times to pick up any updates.
Then I plugged my other hard drive back in, expecting to just need to update Grub and all would be fine. However I found that Windows deletes or installs Master Boot Record which overwrites grub. I turned to Google and found this problem was well documented. After trying a number of solutions with no joy, I found that grub needed to be installed on the Windows hard drive as this was the first drive being accessed during boot up. The process to reinstall grub was to boot from the live CD (in this case Mint 10) then mount the disk with the Mint partition. In this instance my Mint install was on sdb, and windows on sda. The trick is to install grub to sda. The full instructions are:

sudo fdisk -l
sudo mount /dev/sdb6 /mnt
sudo grub-install --root-directory=/mnt /dev/sda
 
The first command lists your devices and you use this to work out which partition is your Linux installation. The second mounts that drive and the third funnily enough does the grub install. Note that we're installing grub on the first device, sda. After this a reboot and you should see the grub menu. If both partitions don't show up, boot into Linux and refresh the grub menu with

sudo update-grub

This worked perfectly for me with Linux Mint 10.

Tuesday 4 January 2011

Vim..a n00b's experience

Vim is an improved version of the Vi text editor which has been kicking around since 1976. After some initial scepticism I've found that is an incredibly powerful and useful tool. I'm just learning but all ready feel that my productivity is increasing.


Why Vim?

I never thought I'd feel excited enough about a text editor that I pony up the cash to pay for it. After all its just a text editor right? Well that's what I thought until I found Textmate for my Mac. This seemed to bring a whole slew of new features that made coding faster and easier. I'm sure that I wasn't even using a fraction of the available abilities. Then I moved to Linux and found gEdit which is just a plain old text editor. Now I spend a lot of time at work ssh-ing to unix boxes and if I need to view or edit a file my choices are limited. The commands used in less and more, translate to Vim so I needed to learn about more (bad pun intended) about it. I found that once you've learned relatively few commands you can navigate round a file in no time. I decided to see if Vim could be useful as my default editor at home as well. The Vim website has binaries available for installing gVim (a Gui based version) for Linux, Mac and PC so I didn't have to code inside a terminal window. I also downloaded an excellent 4 part video tutorial from Net Tut's called Venturing into Vim by Jeffrey Way. This series was very useful in explaining the basics (and some advanced stuff). If you're wanting to learn more I'd highly recommend this series.

So what's so cool about it?

When I work I prefer to have my hands on the keyboard as much as I can. I don't like to be continually moving my hand off to grab the mouse. Vim lets me not only insert and edit text but also to navigate without having to wave my arm around. This translates to faster input. Once you're familiar with the Vim way, most commands are intuitive and seem to be the logical way to do things. Even though its text based you can still use tabs or split the screen vertically or horizontally (and multiple times). You can carve up your workspace to make it however you want. Check out this screenshot.  I defy you to do that in your vanilla flavoured editor.
This is just one of the many flexible things you can do with Vim. Its not an IDE but its totally lightweight and can support syntax highlighting.

The trick with Vim is that it is like a language all on its own. Once you've become familiar with it, it will quickly become second nature. Part of the curve is that Vim has a number of different modes: command, insert and visual. Depending on what mode you're in, keystrokes will mean different things. For example, in command mode [shift] + g will move you to the end of the document, while in insert mode it will give you a capital G. By default you start in command mode and you choose to enter text by one of the many insert commands. For example i to insert before the cursor, o to insert on the next line, a to insert after the cursor, A to insert at the end of the line. The options are plentiful. Do a quick google and you'll find any number of cheatsheets and shortcut lists available for Vim so I'll not repeat them here. The thing to remember is that once you've finished in insert mode hit [esc] to go back to command mode. This is a lesson that's learned from experience as I seemed to finish my text files with :w!

You can change the colour scheme from the plain black and white to a number of provided colourful schemes. I'm using the quite dark "ron" scheme at the moment. If you want to set a scheme to load by default you can add a .vimrc file to your home directory. This can be used to customise your Vim with all sorts of things, such as line numbering, syntax highlighting (I've tested it with Java, Groovy and HTML) and auto indenting.

I'll post more about Vim as I learn but so far I'm thinking that if you can type Vim might be the editor for you.

Monday 3 January 2011

Samsung NF210 Netbook Opinion

For Christmas 2010, we got my youngest daughter Em a Samsung NF210 netbook. She's a budding nerd and has been hacking away on some Python scripts and I really enjoy working on this together with her. She had previously been using a hand me down Powerbook but its best days are now long gone. I didn't want to spend a bucket of cash and she liked the funky shape of this particular model (girls really!!).

The hardware
This Sammy comes with a 1.66 GHz Atom process, 1 GB RAM and 250 GB hard drive. I'm not sure of the weight but it seems much much lighter than my Macbook. The screen is bright and battery life is quoted as up to 14 hours. Even taking out the usual marketing spin the battery life is awesome. Anything better than 8 hours is dynamite IMHO. In addition there's a built in web cam which is unnecessary for me but Em thinks its pretty cool.

The software
Ok so here's a bit of a negative, the shipped OS is Windows 7... Starter!! I had to hide my natural bias and told Em we'd see how it worked out. Em was excited because she'd be able to run all those programs that she couldn't run on the Mac. In actual fact, there really wasn't anything in this category aside from ridiculous smileys and other .exe malware. Em was disappointed that one of the unnecessary features removed from the Starter edition was the ability to change desktop backgrounds.
So within 24 hours, Win 7 Starter was gone and Linux had been installed. We tried a bunch of different flavours, Meego, Moblin, Smeegol, Mint (XCFE), Ubuntu UNR. Meego and Moblin in particular have a beautiful interfaces for portable devices. Initially I couldn't get wifi working as the netbook uses proprietary Broadcom drivers (although I'm told these are now open). After much mucking around I finally got the drivers installed and it worked really well. I'd have to say that one of the big pluses for Meego is the community. It took a long time to get the wifi problem sorted but there were people willing to help on IRQ and twitter. (Particular thanks here to Andy Bleaden @andybleaden for his assistance). However I needed to get VLC working before the young one goes away to grandma's house and this involved a whole new round of pain. We've settled on Ubuntu UNR as the best fit between usability and functionality at the moment. I'm not particularly keen on the Unity interface and we'll sure have another look at Meego in the future.
Ubuntu runs well but so far we've not found a solution for the non functioning brightness keyboard controls and the annoying trackpad which moves the cursor when bumped while typing. I'm sure there's a fix out there for that one somewhere though.

The Verdict
Its terrific and I want one. The screen is small but perfectly usable for web surfing on knocking up a script or two. While its no desktop replacement its perfect if you're on the road or want to have web access with you wherever you are. I've not used an iPad but can't see why you'd want an iPad when you could get one of these for so much more bang for your buck.