About Reseting CSS Properties

written by admin 2762 days ago. Last update at 2013-04-02 16:29:26. Categories webdesign. Tags , .

Designing a layout using HTML/CSS is not a job for the faint hearted. Quit often there is a clash with built-in properties which are not consistent defined in all browsers. This led to the approach of using a style-sheet which resets CSS properties. The style-sheet populated by Eric Meyer, a rather well known CSS styling guru, is for example given here.

Eventually I would like to say that it did not work out for me. All too often I found myself trying to set the default values I have just discarded in my reset.css style-sheet. Ignoring inconsistencies for the moment, the I would like to state that usually all default properties are rather wisely chosen and contain exactly what you want when writing an article, a posting whatever.

Inconsistencies start to matter when designing a website. Then browser inconsistencies can have disastrous effects (like two divs are not side-by-side floated cause they don’t fit in the given width by perhaps just one pixel). However it’s just a small part of the website which needs precision rendering and not the whole website.

So, instead of setting the padding of all divs to be

div { padding: 1px 0; }  /* avoid margin collapsing */

I propose to reset only where it matters:

#header, [..], #footer, #header div, [..], #footer div, #content-main {
  padding: 1px 0; /* avoid margin collapsing */

Please notice that divs are reset in all grid elements except within #content-main (supposed to hold your page its informational content). Therein, default values are just fine.


Forward By Word!

written by admin 2822 days ago. Last update at 2013-04-02 16:29:26. Categories admin, bash. Tags , , .

I have to confess that I’m a notorious user of the command line. I do use the command line also on my MacBook Laptop where one of the first actions after having logged in is to open the so called terminal application (, kind of hidden in the Utilities folder). This terminal application is really a step forward compared to xterm or rxvt and is also looking marvelous good.

The hidden gotcha is speed. Where would speed matter you may asking? Well, after having typed in and executed some command, the next command is most often just a minor variation of the previous one. Instead of retyping almost everything again, I let readline’s previous-history function repeat the last (or an earlier) command, move the cursor char-by-char to the desired position where I dare to change something, do the change and eventually execute the command by pushing the RETURN key.

At this point I would like to add a not on the notion used in this small survey about to denote a particular key. Obviously if I mean the key “a” then it’s the small tile on your keyboard with that engraved letter “a”. “A” is bit more complicated cause it is a combination of two “tiles”, namely the “SHIFT” tile and the “a” tile. What you need to do to get the “A” is to hold down tile SHIFT, followed by “a” without releasing SHIFT. So how does the SHIFT key looks like on your keyboard? I have no clue. On my keyboard it’s a tile with a upword-pointing non-filled arrow character. Other keyboard keys of particular importance are the (carriage) RETURN key (originally to move the typewrite’s write position to the line’s beginning), the CONTROL key, the ESCAPE key and usually four navigation keys (usually right and left, up and down).

There must be some convention how to write down a sequence of keystrokes. The one readline uses and which is also being used in this survey is the following: \C means the control key and \e is the escape key. \M is the meta key. I don’t have one on my keyboard, so \e is taking over automatically. Furthermore there are the left and right navigation keys which I’m denoting with <- and ->. Notice that readline does not have a notation for this keys. Instead such a key is represented a key sequence starting with the escape key (\e).

This all works fine except that moving the cursor char-by-char is awfully slow, even in those days with a small super computer right in front of me. It would be really great if I could move forward/backward word-by-word as well. This is of course possible using readline. The function names to do so are forward-word and backword-word.

All fine and well except the default key bindings used for forward/backward word. The standard key binding is \M-f and \M-b. The idea is good. Use \C-f to move forward a char and just switch to the meta key to move forward a word instead. My problem is that I have to press key \e once, then release that key and the press the f key to get the desired effect. That’s much slower than pressing the \C key followed the f key while still holding the \C key. In fact is so much slower that I almost never used the forward move feature. But as I said, forward by char is anoyingly slow.

What I want to do is to assing forward-word with \C--> and backward-word with \C-<-, i.e. I would like to invoke forward-word by holding down the \C key followed by pressing the right arrow (and left arrow for moving backward). This would suite me quite well cause the standard action when pressing the right and left arrow is moving forward or backward a char and this are the keys I’m actually using when moving the cursor (for completness: the up and down arrow move forward and backward in the history).

At this point I had to dig into the documentation to be able to continue:

  1. How to configure readline?
  2. How force bash to re-read the configuration?
  3. How can I see the active bindings?
  4. How can I see the escape characters generated by a key?

The first question is easy. Add or change a (hidden) file named .inputrc right in your home folder. This file is taken into consideration if existing. You can change that setting an environment variable named INPUTRC if you are not happy with the name or the location. In any case, readline will also read the system wide configuration file /etc/inputrc if existing.

Having changed .inputrc, how do I make my terminal application (which runs bash as interactive shell) aware of any changes? You can start a new terminal application (tab or window) or you can type \C-x \C-r in your current one as cheap alternative.

Ok by now, but how can I check the current bindings? When running the bash, use bash’s builtin command bind. For example, you may want to run

% bind -P

to get a relation between readline functions and keys bound to that function. Or you may use bind -p to get a key : function mapping for each function (the output of bind -p would be a valid .inputrc file; it also shows unbound functions – quite useful actually).

Jolly good by now. Except that I have no clue what kind of character sequence is generated by pressing down the right or left arrow key or even what might be generated by additionally holding down the control key (\C). Here another useful readline function, named quoted-insert, comes to rescue. By default, this function gets invoked by \C-v and what it does is, that it inserts the next character you type right there at the cursor’s position.

So you are curious what might be generated by \C followed by holding down the right arrow (->) key? Go ahead and type \C-v \C--> in your terminal and the result on my terminal looks like

$ ^[[5C

Great, now we are almost there. The very last hurdle to overcome is to understand that ^[ is actually the escape key. You can verify this easily using the quoted-insert method explained previously. So what’s left is to add something like this to your local .inputrc and make readline reload that file:

# Make CONTROL - (left arrow) move cursor backward
# one word resp. forward one word
"\e[5D": backward-word
"\e[5C": forward-word

Happy hacking.


IRB and the missing idiom

written by admin 2829 days ago. Last update at 2013-04-02 16:29:26. Categories devel, ruby.

I have recently turned my eye on using Ruby for small and not so small programms. Honestly, Ruby is really exciting and should probably also been listed as one of those things that brings the wow! back on your computer (the other being Apple and Google). Then there’s this book about Ruby, the so called Pick-Axe, wetting my appetite.

The Pick-Axe writes also about irb, the interactive ruby interpreter. So what you can do with irb is to fire it up and hack away some ruby code to give it a try. When you eventually shutdown irb your typed code is gone of course. The book shows lots of such examples.

That’s all fine and good except that using irb this way is bit unrealistic. Actually what I really want to do is to load my ruby project in irb and call methods, create objects, inspect variables etc — without running my project of course. But this is exactly what happens when doing something like

% irb -r 'foobar.rb'

So how to tell irb not to execute my ruby code? Unfortunatly the Pick-Axe is rather silent on this. Here’s how to do it:

if __FILE__ == $0
  # executed if not in irb

I love my Mac!

written by admin 2837 days ago. Last update at 2013-04-02 16:29:26. Categories macosx.

This article is actually not about developing software. It’s all about that the wow!.. is back, at least once a while. It was again my Mac featuring MacOS X 10.5 aka Leopard making me happy. It started with my mobile device which, for unknown reasons, stops working when in a foreign country. Stops working in this context means that I can’t make any phone call nor send SMS. So this is pretty serious. I called my provider’s help desk. Not that I expected any help. It’s just about that I call it because its there or not having a bad conscious not having called them for help. After 12 days without any sign of live from my provider, I called them today for a status query ..

After that call I decided to go for a master reset of my good old T630 phone. Obviously such a master reset will kill any data on that device. So how to export them? On Windows XP I used FMA which worked reasonably well and is free software. Ok but now I’m using a Mac..

After I while of searching the Internet for a Mac based tool I had the glorious idea to just let my Mac connect to my via phone via Bluetooth and see what will happen. So I did and voila , after having established a connection, a tool started up out of the blue. It was iSync which comes packaged with Leopard. And from there I lifted off and saved my phone’s address book on my back. Basically it all happens in seconds. So there it was, the wow effect. This is really a marvellous piece of work, this computer and it’s software. I love it.

As you might know, light and shadow are close friends. I’m still not able to do my master reset cause I have no clue about my phone’s phone lock code….

Happy Hacking.



written by admin 2840 days ago. Last update at 2013-04-02 16:29:26. Categories admin, apache httpd. Tags .

mod_autoindex is a plugin for the the Apache web server. The plugin is responsible for presenting the contents of a folder if folder browsing has been enabled and if a default file, traditionally index.html, is not available.

So far so good except that the default presentation generated by mod_autoindex is rather boring. We want to have it a bit more spicy. Therefore mod_autoindex has a lot of applicable options which are crying to be used.

Apache’s webserver has got a reputation of being difficult to configure and mod_autoindex is actually a perfect example for this claim. I don’t judge the software here as such, in my opinion, it’s rather about the documentation. As a teaser, you might wonder what mod_autoindex generates by default? This is what get generated for a folder containg just a file and just a subfolder:

 <head><title>Index of /js</title></head>
<h1>Index of /js</h1>
<ul><li><a href="/"> Parent Directory</a></li>
<li><a href="file"> file</a></li>
<li><a href="folder"> folder</a></li>

Let’s go one step further and take how to apply index options as an example. Index options can be used on a server config level or within a directory tag. In other words, you may have an httpd.conf file looking partially like

IndexOptions XHTML
IndexOptions HTMLTable
<directory />
 IndexOptions HTMLTable

The overall question is: what do we get by this?. Obviously we try to enable XHTML and we try to enable the generation of a table instead of the unordered list (<ul>). But that’s not what we get. What we get is the html table rendered in plain HTML 3.2. How does this come?

It appears, and the documentation really needs to be more explicit on this, that index options are handled quite differently if they are encountered within a directory tag (<directory />) or on the top level. When processing the configuration, Apache first calculates the value on the server config level. This is simply done by accumulating all index options into a list. For example, if there is IndexOptions X and somewhere later a IndexOptions Y, then we end up in a list like {X, Y}.. This is probably what you expect.

The server config value calculated is then applied to the root directory (/). If no directory tags are present, this is then the value applied.

If a directory tag for path /foo/bar is present, the value is calculated in two steps. In step one, the value is inherited from directory /foo which in turn will get its value from /. In step two, index options found within the directory tag are applied in an incremental fashion.

Incremental index options are applied like this: if the options starts with a plus sign, the option’s value gets added to the list value. If it starts with a dash, the option’s value will be removed from the list. If neither plus not dash, the current list value is erased and the new list value will be the value of index option under investigation.

So, let’s have again a look at our configuration:

IndexOptions XHTML
IndexOptions HTMLTable
<directory />
 IndexOptions HTMLTable

The calculated index option valaue after having processed the server config level before digging into the directory tag is {XHTML, HTMLTable}. Then directory / is processed by inheriting {XHTML, HTMLTable} followed by applying incremental rules. Therefore the final value is cleared and replaced by {HTMLTable}.

Notice on the other hand that incremental options on top level do not work at all:

IndexOptions +XHTML
IndexOptions +HTMLTable

This has just no effect. Incremental options on top level are silently ignored.

In summary it’s mainly Apache’s documentation doing a bad job here:

  • The documentation does not state what we have to expect if no options are applied
  • It is not clear at all how options are processed. Lots of other weired behaviours could have been implemented.
  • It is rather bad to use the same identifier (IndexOptions) for a different behaviour. If so this should be clearly documented

I like to dwell in a bit on the last point. From a legacy point of view, older version of Apache supported non-incremental index options. Starting with Apache 1.3, incremental index options were added. So suddenly we can have index options that start with a plus character, or a dash or with extra character. Then someone decided that the absence of a character means erase. That conflicts of course with the legacy meaning where the absence of a character means actually +.

It would have been much better to define the absence of a character as use the default character and to use a third character for replacing. Such a character could have been =. Then we would end up in those rules, regardless whether on a server config level or within a directory:

  • If an index options starts with + then it’s value is added.
  • If an index options starts with - then it’s value is removed.
  • If an index options starts with = then it’s value replaces the calculated value so far
  • Otherwise: treat the option as if the value starts with +.

Mediawiki on MacPorts

written by admin 2851 days ago. Last update at 2013-04-02 16:29:26. Categories admin, macports. Tags , , , .

The installation of Mediawiki is not without pain, especially when using MacPorts on MacOS X. A repeating problem is the location of MySQL’s socket file. For unkown or rather questionable reasons, MacPorts moved that file from it’s default location in folder /tmp to


Even worse, the file’s name, usually mysql.sock, has now changed into mysqld.sock. So it comes to no surprise that applications like PHP, Mediawiki and oh-you-name-it simply choke. Except if you also install those via MacPorts. Then you may have a chance that it works.

Personnally however I don’t like this all-or-nothing approach. Ideally I would like to have a system where MacPorts lives in a friendly coexistence with tools not provided by MacPorts. Wouldn’t it be good if there were a kind of registry knowing about locations? Unfortunatly, such a registry beast is still missing on UNIX based platforms. As much as I like the UNIX approach, all those config file locations and dialects drives me crazy.

So how would Mediawiki know that my MySQL’s configuration file is burried deep in /opt/local/etc and that furthermore, MySQL got pached to use that fancy location mentioned above?

Well, it simply can’t figure it out.

Now, you may think that’s no problem then. We just tell Mediawiki where it is. That’s not going to work either as long as you are unwilling to wrestle with Mediawikis PHP code: joy-oh-joy, it’s just hardwired to /tmp/mysql.sock. Period. So, what you need to do is to ask good old ln -s for rescue:

% sudo ln -s /opt/local/var/run/mysql5/mysqld.sock /tmp/mysql.sock

This works eventually but it’s really ugly cause the problem with links is that after a while no one knows why this link was created in the first place.

Happy Hacking.

« Newer Posts