Forgetting

May 21st, 2009

Auto-mounting partitions in Ubuntu

May 9th, 2009

I’m trying Ubuntu again, as I’m sick of Vista and Windows 7 doesn’t look much better (although I am dual-booting for games). It still just doesn’t seem suitable for a user with advanced Windows knowledge but only intermediate Linux experience. Some things just don’t work out of the box, which is fine except that finding the solution usually involves googling the answer rather than searching through the config menus or hitting F1.

Case in point is auto-mounting NTFS partitions. I know that Ubuntu automatically mounts the partitions in the Places menu when you select them, but I’ve set /var/www to be a symlink to a folder in /media/sda4 (an NTFS partition that I also use in Windows) which means that Apache fails until /media/sda4 is manually mounted. Ubuntu’s built-in help system isn’t any help, searching for ‘automount’ yields a page about Gnome Display Manager and some date format thingy.

Make Tech Easier - How To Auto-mount Your NTFS Partition In Ubuntu contains the correct instructions but basically you need the Storage Device Manager. Open a terminal:

sudo apt-get install pysdm

Once that’s installed, under System/Administration is the Storage Device Manager. It’s not the nicest app (the UI could use some work, like adding the type and partition size to the list of partitions) but it gets the job done and is much easier than editing .init files or whatever.

I’ll leave the Ubuntu vs Windows rant for another day… till then sticking to Ubuntu…

Wenhaming

April 15th, 2009

Wenhaming: to narrate in the style of David Wenham.

The blood ran thick as Carrie took her horrible revenge for Ben’s constant, inappropriate wenhaming.

jQuery UI Tabs ‘bug’

April 15th, 2009

I’m using jQuery UI’s Tabs for an internal project at work, and have just spent several hours trying to get AJAX tabs showing a Loading… message while the AJAX content is loading. In the documentation for the Tabs widget this doesn’t even work, although it describes the behavior as if it does.

The solution is to wrap the anchor text with an empty <span> tag, as in:

	<ul>
		<li><a href="#tabs-1">Nunc tincidunt</a></li>
		<li><a href="ajax/content1.html"><span>Ajax Tab 1</span></a></li>
		<li><a href="ajax/content2.html"><span>Ajax Tab 2</span></a></li>
	</ul>

CakePHP tip: setting the layout from a view

January 24th, 2009

This works in CakePHP 1.1.19.6305 (not tested in 1.2, but I can’t see why not). I needed to set the layout used for a static view (under /pages), so there was no controller, which is where all of the documentation says to set the layout. It turns out that the View class has a layout member which works in exactly the same way, so adding $this->layout = 'empty' works as you would expect (assuming you’re expecting the ‘empty.ctp’ layout, which I was). This would work for a view under a controller, although the recommended way would be via the controller in that case.

Tip: list all actively listening ports on a Windows machine

November 7th, 2008

Finding out what ports are open on a machine is something I often need to do, and I usually stuff around for ages trying to figure out whether a particular port is open. The fastest way I’ve (just) found is by opening a console and running netstat -a, or netstat -an to show IP and port numbers rather than machine and service names.

Now that I know that the port’s definitely open, I’ve just got to figure out why the service still isn’t working

ORDER BY items must appear in the select list if the statement contains a UNION operator

September 19th, 2008

Is a very annoying error message that you get when writing above average complexity SELECT statements. I’m not sure if it only applies to queries against SQL Server, but it can be very difficult to debug if you haven’t come across it before (or come across so many things in a day that they all blur into one big problem).

For me at least it happens like this:

  1. Ben writes a big meaty query, tests it, all ok
  2. Ben writes query #2, which has the same SELECTed columns as the first query, tests also, also ok
  3. Ben sticks a UNION ALL between the two queries, thus making Das Uberquery™ and securing his employment
  4. Ben executes said query and gets cryptic error message, spends rest of day tring to debug 300 lines of SQL, goes home with migraine.

It sounds like one of the queries has an ORDER BY clause but of course I’ve taken all of the ORDER BYs out when joining them, and I’m ordering the UNION as a whole!

The issue is that one or more of the big mutha queries that are being UNION ALLed together contain a subquery that contains a ORDER BY clause. Something like this:

SELECT t1.A, t2.B
FROM t1, (SELECT TOP 1 * FROM Foo ORDER BY Bar) t2
UNION ALL
SELECT t3.A, t3.B
FROM t3

It’s that ORDER BY Bar part that gives grief. I can’t see why it’s an issue, but this is what to look out for. Replace the subquery with a view or find some other way to do it without the ORDER BY clause.

lolcat

July 8th, 2008

humorous pictures
more cat pictures

External graphics in XSL:FO not sizing correctly

June 4th, 2008

I’m using Apache FOP to generate PDFs from XSL:FO, and an external graphic (think the <img> tag in HTML) kept being resized incorrectly. Another image (different size) was the correct size on the page. Turns out I was using height and width attributes in the fo:external-graphic element, when I should have been using content-height and content-width. Somehow the second image respected the height and width I wanted. Possibly this has something to do with the stored DPI of the images (since XSL:FO is a specification for printed documents), but in any case content-width and content-height is the way to go. Way to go, Ben :P

Added Subscribe to Comments plugin

May 3rd, 2008

Thanks to Jylan, I’ve just added the Subscribe to Comments plugin, so when you leave a comment you can subscribe to recieve new comments for the article via email. Groovy.

I’ve also upgraded to Wordpress 2.5.1. Also groovy.

Also, a big shout-out to the Australian labour movement for the 8 hour workday, and probably a few other things, including this long weekend. Damn the man. Save the Empire.