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.

Thursday, 30 December 2010

2011 New Year's Bucket List

Last year I got excited and said I'd try to blog once a week to make sure I stayed on track. But as you can tell from the listings here, I didn't make it very far. Aside from the controversial post about Linux there really hasn't been too much action at least in the last 6 months anyway. Just like everyone else I'm really busy and finding the time to learn and experiment can be difficult. However with so many cool new and not so new technologies to play with, how can I not dabble. So with that in mind, in no particular order here's my bucket list for 2011:

  • HTML5 (looks so cool!!)
  • Python (my youngest daughter aged 12 is inspiring me here)
  • Grails
  • JQuery
  • Vim (I did say cool not so new technologies)
  • Scala
  • Android
In 2010, messed about with Linux as an OS (and found it fantastic), with Grails and JavaFX in the language space but didn't get to apply either to anything very substantial. Time management is a massive issue for me so I'll need to be pretty organised and set some specific goals. I've got a couple of projects in mind to apply some of this stuff to, so follow along and we'll see what we can learn.
If you've got a suggestion for a cool technology let me know.

Wednesday, 14 July 2010

Lazy, stupid or insane?

There's never enough time to do all the things I know I should. Life is constant juggle to get stuff done. Work is the perfect example.. ridiculous deadlines tend to overtake the development process and (sometimes) code you're less than proud of gets out. So you'd think I'd learn when working on my own side projects.. right?

Currently myself and another a likeminded dude are working on a grails based football (that's Australian football in case you're wondering) tipping application. The idea had been kicking around (bad pun intended) for a while. We were feed up with the main AFL site which is based on flash. It does the job but each year they provided 'enhancements' which are unnecessary or just don't give us what we want. Anyway enough complaining, we'll build our own. We've given ourselves a very generous timeline to get this done so that it will be close to perfect at release.

Herein lies the problem. Grails makes it so easy to get from "hey let's do this" to "wow look what I just made" that all my good intentions to do the right thing are forgotten. I've read enough material by learned people (like this and this) to know that I should be writing tests for my stuff. Preferably before or during development. However after being distracted by a couple of other side projects, I went back to the tipping project today only to find that the last great feature I'd implemented had busted some core functionality that had been working on early in the project. Lazy, stupid or insane... take your pick.

So now that I've learned my lesson I'm off to install the grails cobertura plug in and see if I can get that percentage up and avoid future problems.

As a side note what do people think is reasonable test coverage? 70%, 80%, (gulp) 100% ??

Monday, 7 June 2010

Version Control

Up until recently I've basically worked on my side projects on my own. I only ever needed version control to keep track of my own changes. Although I use CVS at work (don't laugh some of us have to use ClearCase) I decided to use something different. GIT was my weapon of choice. Fast cheap branching.. too easy right? Ok so its (mostly) command line.. there's no drama with that. Most of what I'm doing is as simple as git branch, git merge, git status.. nothing too drastic at all.

Recently I've started working with another bloke who, like me, is used to using Eclipse with CVS at work. I pushed (no pun intended) Git as I've had good experiences so far and didn't want to go setting up a CVS or Subversion repo on a separate machine. To be honest as much as I wanted this to work for us, we struggled. Making small changes then waiting while he pushed those to master and then I pulled them down only to find a bunch of clashes became tedious quickly. We've argued about what system to use:
CVS? Subversion? Mercurial? Continue with Git?

In the end we've decided to give Mercurial a try. It gives a chance to continue with the distributed mindset but importantly there is good tooling support in Netbeans. (I know there's a plugin for git but I couldn't get it to work on my machine). So far the extra tool support has been positive. We've moved our project to BitBucket from GitHub (higher storage limit for the free account too) and we're able to work collaboratively even in the free account.

In the process of making this post I've had a couple of tweets reminding me that there is git support in Netbeans (and Eclipse). I had been using Netbeans 6.9 RC2 on 64 bit Linux and couldn't get the plugin to work. All good with mercurial so far.

Version Control is something some people get passionate about. I'm not proposing one is better than another just that for us this time Mercurial has been a better experience. As we get more used to the distributed aspect I guess we'll be better able to adapt to GIT. But if Mercurial is doing the job why change?