13 Sep

pot, kettle?

A quick read through this shows that Microsoft is yet again trying to pull some FUD woll over our eyes, by claiming that programs written for one distribution will have to be “tweaked slightly” to work on another.

Hello? Pot? Kettle?

I am certain that some programs written for some distributions of Windows cannot work on others, no matter how much “tweaking” is done.

In fact, I remember an old acquaintance of mine who had bought a computer with NT4 installed (wanted a “stable” operating system), and went out and bought Win98 a week later because he couldn’t play his Windows games on it.

With Linux, it’s never that serious. If something doesn’t “work” in your distribution, then download the source and compile it! What could be simpler?

I’ve never come across something that would work in one distribution and not another, so I don’t know exactly where they got their information from…

13 Sep

gardenbot – thoughts

As some people may know, I am a firm believer in robotic gardening – the idea that we could someday get food straight to the table with no human intervention or work at all is somehow relaxing to me. I look forward to the day when I own my own home, and have an army of robot gardens to create my dinners for me. Bliss.

Anyway – I’ve been thinking about how to go about this for a very long time, and some methods of getting started come to mind.

The first, and most obvious method, was a grid of rails, where my robots would travel around the various plots balanced on rails. The rails, in turn, would be on top of small 3 foot brick walls, which would be built into the ground. The walls would serve as plot separators, and also ballast for the rails. There would be one robot – a sort of swiss-army gardener – which could manage everything that needed doing.

A problem with this method was the sheer amount of work involved in digging the trenches, building the walls, and laying the rails. Also, if the robots are balanced on rails on both sides of the plot, then there is the added difficulty that plants grow, so the robot must be able to raise itself up or down to avoid trampling plants it’s travelling over.

The next method was to have a small army of miniature robots, each with a certain minium intelligence – knowledge of its own spatial coordinates, knowledge of what it is looking at, and so forth.

Again, extremely difficult. While that is the ideal solution, as far as I’m concerned, it’s just not feasible for the next few years – maybe after I’ve finished the first working gardenbot I’ll look at that again.

The third version is the one I currently like. It’s kind of like the first version, except there is no grid – just a load of parallel rails. In the image, you can see that there is one pair of rails perpendicular to the others. The well-drawn circles are robots, and this set of rails is how those robots get onto the rail pair that they need to be in.

This current idea has a load of specialised robots. The swiss-army version, while a great sci-fi idea, is just inefficient. As I plan on using energy as ecologically as possible in this project, lugging around a load of equipment that will not be needed on any one particular job is just wrong.

To combat the growing plants problem, the rails in this case are hung from a scaffold about 8 feet or so above the ground. The robots hang from the rails, raising themselves up or down as needed.

To reduce the amount of weight in the robots, transport will be powered externally. Each robot will be individually immobile, but easy to push around. Each pair of rails will have a pulley system built in which will allow it to move a robot along the line to where it’s needed.

It’ll be fun!

04 Sep

hierarchical select lists

click here for an example

I was working on a large project for the services company in the food industry. It had an interesting problem, where the user must be able to quickly select a single ingredient or recipe out of potentially thousands.

The standard solutions did not fit what I needed, so I came up with an idea: arrange the ingredients in a large select list, which was hierarchical in nature.

<select>
 <optgroup label="general">
  <optgroup label="a to c">
   <option>abalone</option>
   <option>bran</option>
   <option>corn</option>
  </optgroup>
  <optgroup label="d to f">
   <option>dogmeat</option>
...

Unfortunately, the w3c specs do not allow nested optgroups.

The solution, then, was to somehow automatically decide how to partition a large list into sub-lists.

One thought I had was to separate the items by letter and following letters:

aba...
  aback
  abaft
  abandon...
    abandon
    abandoned
    abandoning
    abandonment
    abandons
  abase

This is potentially a very bad solution. If, for example, there were enough ingredients that all 26 letters were available, and the 26th letter had a load of sub-lists, then the entire screen could be covered in this list!

After a while, it became clear that the solution was to ignore the letters, and simply decide on a maximum number of items per sub-list. This would naturally break itself into a number of sub-lists.

When I had initially started on this, it was around last September or so. I ran a search first to see if anyone else had done this (easier to build on someone’s example, sometimes, than to build it all from scratch), but there was nothing like this.

So, I started coding.

All of my javascripts are coded the same way – first, you build your interface as if it’s intended for a non-javascript browser, then you run your script over that code, modifying it as needed. So, I wanted a long drop-down to be available if the end-user did not have javascript enabled.

I gave up on this temporarily, shortly into the project – translating directly from an existing select list to a hierarchical menu style is very confusing!

After a few months, I went back to the code, and started again.

Before trying anything, I ran another search. This time, I came up with this – almost exactly what I was planning!

A quick look at the source showed me that this method required that the browser have javascript enabled. This was a slight disappointment, but not a problem.

Now, instead of translating from a select list to a hierarchical select menu, I just needed to translate from a select list to the data format that Levik’s code used.

I also needed to improve the code so that I could have multiple copies on the same page.

the most difficult part of writing this code was the recursive aspect of it. Javascript’s variable scoping is pitiful, so recursion of any type was a bloody nightmare, but I could not think of any way to do this that did not involve recursion.

Anyway, I persevered, and it’s now done.

I call it hierselect.

example

To use this, simply download the script, create a select list with optgroups for the top-level categorisation, and link to the script. That simple!

03 Sep

multiselect

NOTE: This post is now obsolete. Please click here to find the most recent mention of the script.

Donncha pointed this out to me. It’s an improvement over the standard multi-line select box in that you don’t need to know the magic key combination for selecting a second item without losing the first.

I didn’t like that it adds to the bulk of the source code, though! So, here is an improvement.

As usual, I’ve left the source as simple as possible. The javascript checks the document for any select lists that have multi-line support, and converts them to a checkbox list instead.

To use, simply copy the javascript to your site, link to it in your document, then make a multi-line select box as you normally would.

NOTE: Your multi-line select box’s name must end in ‘[]’. While this is against some rules for HTML, it is, AFAIK the only way to make a multi-select work in any case.

update: Michel pointed out that the code only works on the first select box found. I’ve updated the code to fix this. Thanks, Michel!

update (2004-10-07): Thanks to Shaun Walbridge for spotting an intermittent NULL problem. Code has been updated to reflect that.

update (2004-11-04): Thanks to Jeff Hansen for requesting that the script support the HTML disabled attribute. It now does.

skyinsight.net – an example of the tool being used for selection from a large list.

update (2004-12-02): Thanks to Bruno Henry of UPS France for pointing out that the script does not initialise pre-selected items correctly in IE. This was because of this bug here. The script has been corrected to reflect this.

update (2004-12-16): Thanks to Cameron for his interesting method of defining whether a select box is multiple or not. It has been incorporated.