Friday, April 23, 2010

And the word for today is "rort"

When I migrated from England to Australia, language wasn't a great barrier. However there are few words that Australians have added to the language which I'd never heard before, and "rort" is one of them.

Basically it means cheating. Sometimes by breaking the rules, sometimes by bending them and sometimes just doing something that was never even covered by rules. If someone thinks it is unfair, they'll describe it as a rort. Jake on AppsLab recently posted about someone rorting FourSquare.

The rort in the news down here is about Salary Caps. Salary Caps are in place in the National Rugby League (NRL), Aussie Rules Football and A-League Soccer competitions (and probably other places too).

The idea is to stop someone with deep pockets taking control of a club, shelling out big dollars for the best players and continually winning the competition. This is supposed to reduce the pressure on clubs with less financial resources. Needless to say, someone rorted the system. Actually, it is quite likely that several clubs have rorted or are currently rorting the system.

The Melbourne Storm one got caught big-time (with both sets of books), and the ruling body has withdrawn the premiership titles it 'won' over the past few years. Then it removed all the competition points it has won this season. Then it said that, even if it wins every remaining match of the season, it still won't get a single point and won't get into the Finals, so they might as well give up and stay home. If they had a sand-castle, then someone probably would have been sent to kick it down and jump on top of it. They don't have the concept of relegation here, and besides the club is already based in Melbourne which is as about close as you can get. That's a joke folks. It counts as "Sydney/Melbourne" rivalry. And of course, we can be assured that the punishment was appropriate to the crime and there's no hint of vengenance over the fact that this is the only NRL club in Melbourne, with half a dozen in Sydney, and they've made the last four Grand Finals, with three minor premierships and two premierships (plus victory over Leeds in the World Club Challenge).

When you get conflicting aims, you are going to get rorts. The salary cap rules were put there to promote an even playing field, but the aim for the individual teams is to win, to put the balance in their favour.

Some systems are just obvious targets for rorts. A long time ago I worked for a firm that developed software for another company. It got paid more for support than development, on the grounds that support was less planned and might have peaks and troughs in demand, possibly out of hours. But when you are going to pay a supplier more for fixing problems AFTER delivery than BEFORE... Well you can see the temptation.

Wednesday, April 21, 2010

Is it a GUI ? is it a CLI ? No, it's Emacs

There is a place of shadow, a place between the dark lands of the command-line interface, and the shining brightness of the GUI. In the days of yore, many dwelled in the shadow lands, but almost all have been attracted to the lights of SQL Developer, the gleam of  TOAD or the glitter of PL/SQL Developer.
 
Okay, enough with the melodrama. There are still many people who use SQL*Plus as a regular interface to Oracle. Some from choice. Others are constrained by the lack of a fancy-pants X-Windows interface on their server, or by the limits of SSH. [Yes, I know you can tunnel X-windows over SSH, but how well that works depends on the network bandwidth.] If you're never in the position of being 'stuck' with SQL*Plus, you can stop reading now.
 
In the shadows, there is something between SQL*Plus and a GUI. I'm not talking the replacements like pysql, or the handy rlwrap. I'm talking about the venerable enemy of vi, the emacs editor and it's sql-oracle mode.
 
When I first moved to Oracle from Ingres, I was a tad frustrated by the SQL*Plus command line. Ingres' isql was leaps and bounds beyond it from the point of view of interactive use. I was in a terminal-based VAX environment (no pretty beige PCs back then) and VAX had a beautiful editor called EVE. Using EVE I managed to hodge-podge an environment where the editor spawned a sqlplus sub-process and I could feed commands from the editor to sqlplus and get the results back in that editor. Yep, a command history and a results history and I could move horizontally across wide results sets still with their columns without any of that ugly wrapping.
 
EMACS has that all built in with a special mode called sql-oracle.



In the first screen shot, you see a Putty session from my Windows EeePC to my database server (actually just an Ubuntu VM running on the same machine, with XE installed). I've started up emacs on the server session from the command line. Emacs isn't part of the default Ubuntu install, but it should be available in most linux repositories or for other *nx systems. It's available for Windows too, but if you've got Windows then you're not restricted to this semi-GUI.
 
From emacs, type Esc then X (the Emacs "Meta" command sequence) and then enter sql-oracle. You get prompted for the username, password and database and then, Ta Da, you have sqlplus in the editor. You can set up some of this as defaults in the .emacs initialization file.
 
That gives you the nasty split screen in image 2. Ctrl-X followed by 1 will resolve that. Next you want to turn off the word-wrap with Esc, X then the command toggle-truncate.


The third screen shot shows a small query. I've set my SQL*Plus linesize to a large value. It buggers up DESC unfortunately, but you can't have everything. I can then query a table and see it all properly laid out. I can use ALT-arrow to move forward/back by words to navigate around the result set (or just arrow keys to move column by column)..
 
For single line SQLs, you can just navigate back up to the line and hit return to re-execute it. For multi-line SQLs, you need to get familiar with killing and yanking (cut and paste in emacs) rectangles, or user Ctrl-J at the end of lines rather than return. [It's called sql-accumulate-and-indent. No-one said emacs was friendly.]
 
You can find more on Emacs (and the various sql modes for different databases) on the EmacsWiki.