Author Archives: Oren

How can a parent DIV get the child DIV's width?

In the following code, I wanted the parent div to expand to the size of the child. But it doesn't work this way:

<div id="parent">
<div id="child" style="width: 500px">Child Text</div>
</div>

Instead, the parent takes 100% of the screen width and does not shrink to the width of the child. Quite a long googling revealed some interesting facts:

  • div is a 'block', so it always tries to take all available width. (unlike a span which is 'inline')
  • Using 'float: left' in the parent, makes it "shrink wrap" over the child, thus not trying to take all available width.
    adding 'clear: both' will prevent the float from causing the other blocks to join the same line.
  • If the parent is a <td>, then the "shrink wrap" effect takes place.. (Also with <div display="table-cell"> on firefox, but not in IE)

PXELinux: Different PXE config for each subnet

PXE boot might need different configuration for different subnets (i.e. server names/IPs are different).

PXELinux has a neat feature: in the pxelinux.cfg/ directory, one can put different configuration files for different machines or subnets, identified by the file name:

The configuration file names can be:

  1. Machine UUID
  2. MAC Address i.e. 00-11-22-33-44-55
  3. IP or prefix IP - hexadecimal i.e. :
    1. C0 for 192.0.0.0/255.0.0.0 subnet
    2. C0A8 for 192.168.0.0/255.255.0.0 subnet
  4. default: if nothing else matches, PXELinux will load the config named "default".

Ref: official PXE documentation.

More about the G33 Intel board/chipset and CentOS

In an older post I wrote about supporting the new e1000 in CentOS 5.

Apparently on machines with the same new Intel board, not only the Ethernet driver  (e1000) should be updated but also the sound driver (snd-hda-intel) and graphics driver (xorg i810 driver).

Lots of work, eh? Well - no! CentOS / RHEL 5.1 just contain them all.

I didn't test the 3D graphics driver though.

Setting a raw device in RedHat/CentOS 5 for Oracle RAC

Apparently the issue got changed since RedHat 4, which had /etc/sysconfig/rawdevices, /etc/init.d/raw & /usr/bin/raw.

This version introduces /etc/udev/rules.d/60-raw.rules & /bin/raw.

A. Doing it manually (example):

/bin/raw /dev/raw/raw1 /dev/sdb1

of course, it'll be forgotten after reboot. so:

B. Doing it the right way - udev (example):

  1. Add to /etc/udev/rules.d/60-raw.rules:
  2. ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"

  3. [Optional] to set permissions, create a new /etc/udev/rules.d/99-raw-perms.rules containing lines such as:
  4. KERNEL=="raw[1-2]", MODE="0640", GROUP="oinstall", OWNER="oracle"

The header of rules.d/60-raw.rules file mentions that this method of using raw devices is deprecated. But still, I think that's the only available way if one wants to use raw devices with Oracle RAC, Either for cluster issues (Voting+OCR) or simple Oracle data files.

C. Oracle RAC raw device permissions

You might ask: what permissions should I give the Oracle RAC disks? This is what I've found out with Roman, a DBA expert who came to help:

  • OCR Device(s): root:oinstall , mode 0640
  • Voting device(s): oracle:oinstall, mode 0660
    • CRS cannot run if user oracle can't access the device!
  • Other devices (i.e. data): I guess also oracle:oinstall mode 0660, because oracle user might need to access them.

Disclaimer: I'm not a DBA expert; I hope this helps. Don't blame me if it ruins important data; send comments if you think I'm wrong/right.

"ip" Linux command line trick (or: is ifconfig obsolete?)

We all know how to add a virtual IP using ifconfig command line:

ifconfig eth0:1 192.168.1.5 up

Apparently Linux' /sbin/ip tool provides an alternative:

ip addr add 192.168.1.5/24 dev eth0

This way we do not create a new interface at all: this is a secondary IP that belongs to eth0. Also, it's "hidden" from ifconfig (at least until someone fixes that..), which most people use. Cool, eh?

Apparently RedHat cluster uses this method for adding a Virtual IP to a machine, while Linux-ha (version 1 at least), Veritas cluster and Oracle RAC use the traditional, eth0:1-like addresses.

The /sbin/ip tool seems very powerful.. I should learn some more tricks =)

Cross-browser tab control keyboard shortcuts

The more keyboard shortcuts - the better. The amazing fact is that both Firefox and IE have very similar keyboard shortcuts for handling tabs:

Ctrl+T Create a new tab
Ctrl+W Close current tab
Ctrl+PgDn, Ctrl+PgUp
Ctrl+Tab, Ctrl+Shift+Tab
Go to next/previous tab
Ctrl+[0-9]
(In Linux: Alt+[0-9])
Go to tab #[0-9]

Got something else? 🙂

Session cookie preserving; other browser window/tabs

Many websites use session-cookies (PHP session installs such a cookie, for example). Session-cookies have expiry time of zero, and the browser usually deletes them after closing its window. This is very useful for a 'log-in' session, like in your bank account, gmail, etc.

So all browsers delete the cookie as you close them, but what happens when you open a new browser window or tab? Does it also respect this temporary, session cookie? If you're logged in to gmail from one window, can you open a new browser window with another gmail account?

The answer is not surprising: that depends on your browser.

Continue reading

'onmouseout' event of a container div

Today I wanted to catch a 'mouse-out' event in a div. Every time the mouse leaves the div, I want to call a function So.. there's the onmouseout event which, at first sight, does exactly what I needed.

<div id="parent" style="height: 500px; width: 500px;" onmouseout="alert('out!');">
<table id="child"><tr><td>child text</td></tr>
</div>

HOWEVER - if the div contains child elements (it usually does.. like above example), when mouse moves from the "bare naked" div directly to its child element, an 'onmouseout' event is called from the div, while the mouse is still inside the borders of the div. And the worst news is that it's not a bug! 🙂

So straight to the sad solution: onmouseleave event does exactly what I needed, but isn't standard and is IE-only (same goes for onmouseenter). As Rick summed it in the post which solved my issue today: "Bummer."

So bummer, but the good thing is that among the reads, I've found this must-read article which talks about the order browsers handle the events, and how to deal with it.