Archive for February, 2004

iPod on Linux

Wednesday, February 18th, 2004

One of my bosses handed my an iPod with about 15GB of music on it, so I brought it home and started working on getting it mounted on my machine.

I was hoping it was going to be as simple as mounting my camera (just plug it into a USB port, and KDE takes care of the rest).

I had an AIC-5800 firewire card lying around (Adaptec), so restarted the computer, and stuck that in.

Mandrake’s “harddrake” recognised it as an “unknown” card, but knew that it used the aic7xxx module. That was the first sign of trouble…

I connected the iPod to the card, and waited for the magic. Nothing happened.

After scouring the net for hours (I’ve been sitting here four hours trying to do this), and following lots of instructions, I’ve managed a big fat zero percent of success.

I’ll keep trying… I think it might be the firewire card, so will concentrate on that for the next four hours.

Friendly URLs

Wednesday, February 18th, 2004

If you have a CMS that has unfriendly URLs such as “/?id=6785″, or similar, you could use this little tip.

Add a .htaccess to trap 404s (missing pages). chmod it to 644. In it, place this: “ErrorDocument 404 /404.php”

Now, for the interesting part. The following script assumes your table is called ‘pages’, your database connection script is held in ‘.htDB.php’, and stuff. Read it to figure out more.

<?
$contact='kverens@contactjuggling.org';
include('.htDB.php');
$r=preg_replace('/^\//','',$_SERVER['REQUEST_URI']);
$r=preg_replace('/\?.*/','',$r);
$r=addslashes(urldecode($r));
$q=mysql_query('select id from pages where name="'.$r.'"');
if(!mysql_num_rows($q)||ereg('/',$r)){
 mail($contact,'[yoursitename.test] missing page',
  $_SERVER['HTTP_HOST'].' '.$_SERVER['REQUEST_URI']."\nfrom: ".$_SERVER['HTTP_REFERER']);
 header('Location: /');
 exit;
}
header('Status: 200 OK');
$r=mysql_fetch_array($q);
$id=$r['id'];
include('index.php');
?>

Note that this grabs the page’s ‘id’ from teh table. If you use a different scheme, then obviously, you’ll need to amend this.

erd

Tuesday, February 17th, 2004

After spending a fruitless few hours searching for an Open Source program which can draw out the relationships between various tables in a database, I’ve found nothing useful to me.

The one program which looked perfect for the task, Rekall, crashed when I tried to create a database with it. This was after hours and hours of compiling…

The one I’ve been pushed towards by most people is Dia, but that’s too general, and has too high a learning curve for the time which I can spend at it.

I’m thinking I might have to write one for future work. A pity I’m a web developer, and not a GUI developer. I have the wrong skillset.

kite dangers

Monday, February 16th, 2004

Terrible news. I heard about this earlier today and was in shock. Mostly at the young 18 month old girl who had her throat cut by some stray string (in a different news article about the same event – can’t find the URL). I couldn’t help but imagine how I would react if that happened to my son in front of me. I was in shock just thinking about it.

Jareth actually had a narrow getaway today. I had placed him down on a couch to sleep, and a guitar which was standing at the other end of the couch fell on him. The head of the guitar hit the side of his head, and he now has a nasty lump and a small cut. Luckily, it was a graze, and did not do any permanent damage. It took me a few minutes to convince myself that he was fine.

daily prophet popups

Saturday, February 14th, 2004

quote from alt.html today:

Yep, my first thought was “how do you use a radio button on paper”?
[...]
My second thought was that in J.K. Rowling’s world, parchment with form controls and dynamic display is probably rather commonplace. This led to the third thought, which was to wonder if the _Daily Prophet_ and the _Quibbler_ have pop-up ads, and whether there are spells to block them. Which led to the fourth thought, which was to wonder if such publications ever tell their readers that they need to “upgrade” their wands in order to read them; “This scroll requires an Ollivander’s wand, but you don’t have one.”

gay marriages become legal in the US

Friday, February 13th, 2004

Maybe the US isn’t so stuck up after all. “Dozens of same-sex couples marry in SF

My favourite quote:

“This is a couple that’s been together 14 years,” Katz said moments later. “They’re one of the most extraordinary couples I know.”
Yet they couldn’t get married, she said.
“And then you see someone like Britney Spears, someone who takes it with so little respect,” Katz added, referring to the pop singer’s recent short-lived Las Vegas marriage.

Nice to see the merkins treating same-sex couples in a non-biblical, human way.

eircom sucks

Wednesday, February 11th, 2004

I get online using an ADSL line provided by Eircom.net. I use a Netopia Cayman 3341 as a router for my home network, and as a newbie to the world of in-depth networking, I’m completely lost.

I bought a block of for IP addresses from the same company (I think a block of four is called a /27 block?).

My problem is that every time there’s a power shortage, a machine crash, or even someone sneezes, my router resets and is given another IP address.

That plays havoc with my DNS. I try to run an IRC server, and use it as a test server for some new projects.

Every time my IP resets, I have to change the A record of my domain, and wait 8 hours for Eircom’s domain servers to update.

What’s bloody frustrating about this is that I have the technology! I own the IP block I want to link to my router!

At first glance, the Eircom.net support page is pretty complete.

When I dig a little deeper, though, suddenly everything’s fucked. I don’t use Windows or Mac, and the router is OS agnostic anyway.

My question is – how do I set up my router to have a static IP address? Even calling Eircom.net’s help line doesn’t help – they readily admit that they don’t know!

Futurama header

Tuesday, February 10th, 2004

I got this from Simon Willison‘s blog, and had a good chuckle.

lynx -mime_header http://slashdot.org/ | head -n 6 | tail -1

accessible hierarchical menus

Tuesday, February 10th, 2004

Using a hybrid of Mike Hall‘s hierarchical menus, I’ve come up with a rather nifty method to accessify them.

The problem was that each submenu was held in a layer of it’s own, with no visual clue to what the relationship was between each layer and it’s companions. This was a problem especially for non-coding web designers – it should not be necessary that a web designer have to learn JavaScript in order to create a funky menu. Also, any menu created should have it’s meaning, use, and relationships clear to even a non-JavaScript browser.

So, the method I’ve come up with is to create the menu using a tree of unordered lists, such as this:

I then add the below line at the head of the document, and add class="magicmenutop" or class="magicmenuleft" to the root <ul>:

<script type="text/javascript" src="magicmenu.js"></script>

That script searches for the <ul> containing the magicmenu (left|right) class, and does some cool stuff to it.

The menu traverses the tree, replacing each level of the tree with a layer, in the manner that Mike Hall’s script understands.

A difficulty arose when I wrote the traversal algorithm. I decided to use a depth-first recursive method, as it was simplest, but quickly realised something I had only been peripherally aware of – JavaScript’s variable scopes suck! Essentially, a variable created in a JavaScript is global, so a recursive instance of the same function will destroy any copies of itself.

That was, of course, very vexing.

The solution was to create an external array holding the variables. The index of the array was pretty handy – the index of the layer that the algorithm was writing to at the time.

Another difficulty arose when it was pointed out to me that the script fscked up in Opera and IE. I can’t test IE yet (don’t have it at home), but downloaded Opera and worked on that.

It turns out that Opera does not understand the document.styleSheets collection, and all efforts to dynamically create document-wide styles failed. (the styles I’m talking about are the all-important positioning directives – I don’t mess with colours – leave that to the designers)

I ended up having to write the styles directly into each layer and link as I wrote it.

Long story short – I’m happy with it, and think it will make a formidibale tool. Must contact Mike and mention it to him.

bloated javascript calls

Monday, February 9th, 2004

It really irks me when someone goes to the effort of creating a backwards-compatible whatever (menu, style thing, etc), yet bloats the HTML with javascript calls which will mean nothing to the non-javascript browsers.

For example, this month, ALA has an article on a JavaScript-based photo-gallery method, which is admittedly quite cool.

Now, at first glance, the idea is great – You simply create an unordered list of photo links, and dynamically load the image (overloading the ‘click’ method). Unfortunately, the method used introduces bloat that will slow down non-JavaScript browsers.

From the simple line <a href="images/bananas.jpg" title="A bunch of bananas on a table">some bananas</a>, we add code, creating <a onclick="return showPic(this)" href="images/bananas.jpg" title="A bunch of bananas on a table">some bananas</a>. Ideally, the use of JavaScript should introduce as minimal as possible a change to the page’s source.

How to solve it?

Simple – We know that the gallery images are all contained in a <ul>. So, in the external JavaScript which handles the gallery functions, we add an initialisation function which searches the document for <ul> elements that are given the class “gallery”. All links within that are then dynamically amended to include the event code onclick="return showPic(this)".

My philosophy with JavaScript is that it should affect the source code of the document as little as possible, leaving a very clean, easily readable source, free of clutter.

cars

Tuesday, February 3rd, 2004

Had my first driving lesson today. It was interesting trying to figure out what I was nervous about – I can skate, bike, and rollerblade, so what’s the big deal?

Turns out, what I’m nervous of is teacher patience. I’m a slow but steady learner. The key problem, though, is “slow” – while I learn, and learn steadily, I am always aware that I have little patience in others when I am trying to teach them – so why should a teacher have patience in me?

Anyway – it went off without too many problems. Stalled once or twice until it was explained to me a bit more about how the engine and car fit together.

I must find out how exactly a clutch works – the description didn’t seem to gel with me – I need a good physical understanding of it to be confidant that I won’t break anything.

accessible tabs

Sunday, February 1st, 2004

Like the new look? I’m using a method I developed a while back with collapsible lists to break the blog stories apart into tabs.

A simple example is here.

I won’t insult your intelligence by describing how to use it. It should be obvious from the source.