Thursday, April 30, 2009

What's wrong with HTML and CSS??

W3C says:

Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.

But style sheets are not capable of reasonable layout. Not only is the design of CSS layout overly complex and obtuse, but the specification is so poorly designed and written that no two browsers are consistent in their implementation of it - not even two subsequent versions from the same vendor!!

What makes this even more bizzare is that before designing CSS there was a working model: HTML tables. It would have been easy, and sufficient for most purposes, to provide in CSS the layout capabilities already present in tables. This need not have precluded other layout options, but at least there would then have been one reasonably sane and reasonably well understood (i.e. amenable to consistent implementation) means of laying out pages with CSS.

As it is, I will continue using tables for the foreseeable future.

Wednesday, April 29, 2009

It's hard to be helpful

It struck me again this morning how difficult it is to be helpful.

Comments and suggestions may be taken as criticism, particularly if they relate to someones core beliefs, values, passions or achievements. And criticism, perceived or actual, often elicits defensive reactions that inhibit further communication and learning.

As a result, it can be difficult to get someone to think about and understand a new or different idea and more so to get them to accept that it is valid or has merit.

I quite like the quote in this post. on PerlMonks. If I understand correctly, this is a quote from Tagakure. I will have to read this to see if it is the true source and if it is generally of the same quality as the quoted passage.

There are recent translations of Tagakure available from Amazon and elsewhere. There is also this version, which purports to be a copy in the public domain. I Don't see it on Guttenburg or Internet Archive, which makes me wonder if it is actually in the public domain. The Wikipedia article also has a link to an on-line copy, though I don't see any statement about copyright there.

Wednesday, April 22, 2009

Perl Objects

Perl Objects

What is an object in Perl?

An object is a reference to an item (anything that can be referenced by a reference) that has been blessed.

An object is created by first creating a reference and then using the bless function to bless the referenced item with a package name.

For example:

$reference = {};  # here a reference to a hash but it could be to anything

bless $reference, "Some::Package::name";

The bless function requires a reference as an argument but it modifies the referenced item rather than the reference itself. It sets a flag in the referenced item that indicates that the item is an object and it records the package name as an attribute of the item. With this done, any reference to the item can be used with the arrow operator (a.k.a. dereference operator) for method invocation.

It is the facility of method invocation that makes objects different from other variables.

Method invocation is a means of calling a subroutine. It differs from regular subroutine invocation in two respects:

  1. the package name with which the referenced item was blessed is passed as the first argument to the subroutine, followed by any explicit arguments; and
  2. a runtime lookup of the method name is performed to determine the subroutine to be called.

For example:

$ref->method($arg1, $arg2);

$ref->Package::method($arg1,$arg2);

The method name may be unqualified or qualified with a package name. If it is unqualified, lookup of the subroutine begins in the package with which the referenced item was blessed. If the method name is fully qualified, lookup begins in the specified package, regardless of the package with which the referenced item was blessed.

If the package has a subroutine with the same name as the method name then this subroutine is called.

If the package does not have a subroutine with the same name as the method name then lookup is repeated in each package in the list (@ISA, 'UNIVERSAL'). The @ISA array is a package global and 'UNIVERSAL' is a package that is part of the Perl core distribution which defines several basic methods. As each package may have its own @ISA array, a depth first search of these arrays is performed.

If no matching subroutine is found after this search then the search is repeated but searching for AUTOLOAD rather than the named method and if an AUTOLOAD subroutine is found then it is invoked for the method.

These mechanisms are simple, but the ramifications and possibilities are not.

Because methods are resolved to subroutines at runtime (a.k.a. dynamically), interesting things can be done. Sometimes these are interesting in the sense of wonderful, amazing, powerful and good, but sometimes they are interesting in the sense of the curse: may you live in interesting times. 

Wednesday, April 15, 2009

perl system on windows

On Windows systems, if the first argument to "system" is a number or integer and not a string it is taken to be the mode of the spawn call that creates the process to run the command which, in this case, is specified by the second argument to system. Allowed values are P_WAIT or P_NOWAIT as defined in process.h. These are usually 0 (synchronous execution - calling process waits until the spawned process terminates) and 1 (asynchronous execution - calling process continues to execute concurrently with the spawned process) respectively. Other values are not supported by perl and will result in system returning an error (-1) without running the command. The default is synchronous execution (P_WAIT).

Friday, February 27, 2009

Devel::Peek

Consider:

$ perl -MDevel::Peek -e 'my $x; Dump($x);'
SV = NULL(0x0) at 0x9c90cdc
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY)
$ perl -MDevel::Peek -e 'my $x = 10; Dump($x);'
SV = IV(0x8a5a9b0) at 0x8a3ecdc
  REFCNT = 1
  FLAGS = (PADBUSY,PADMY,IOK,pIOK)
  IV = 10
[ian@alula ~]$ perl -MDevel::Peek -e 'my $x = 10; Dump(\$x);'
SV = RV(0x809d158) at 0x8074c28
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x8074cdc
  SV = IV(0x80909b0) at 0x8074cdc
  REFCNT = 2
  FLAGS = (PADBUSY,PADMY,IOK,pIOK)
  IV = 10

What are all the addresses?

perldoc Devel::Peek doesn't say.

Every value has data stored in a structure 'struct sv'. Dump reports the address where this structure is located in memory as "at 0xXXXXXXXX". For example, in

SV = IV(0x8a5a9b0) at 0x8a3ecdc

The 'struct sv' for this SV is located at 0x8a3ecdc.

Most values (all but NULL values) also have data stored in a second, type specific structure. The 'struct sv' includes a pointer to this secondary structure. Dump reports the address where this secondary structure is located in memory in parentheses after the type of the value. For example, in

SV = IV(0x8a5a9b0) at 0x8a3ecdc

The type of the value is IV (which determines the type of the secondary structure) and the secondary structure is located at 0x8a5a9b0.

Tuesday, December 23, 2008

TWiki TinyMCE and Opera

Today I installed TWiki 4.2.4, which includes TinyMCE editor.
But in Opera 9.61 I only get the traditional editor - no TinyMCE in sight.
Tried accessing from Firefox and it worked fine.

So, I downloaded TinyMCE from http://tinymce.moxiecode.com/index.php, put it on my internal website and ran the examples from Opera - no problems - TinyMCE works fine in Opera.

Looked at the source code for the edit pages in Opera and Firefox and the TinyMCE content is only there in Firefox. TWiki must be deciding I can't run TinyMCE for some reason and providing different content to Opera than it provides to Firefox.

It turns out that in January 2008, Opera was added to a short list of browsers that are not compatible with the TinyCME plugin of TWiki.See http://develop.twiki.org/~twiki4/cgi-bin/view/Bugs/Item5116 for details. It seems TinyMCE in Opera corrupts data.

The TWiki TinyMCEPlugin is using version 2.1.2, but the current release is 3.2.1.1. This may have something to do with the problems with Opera. There are indications on the TinyMCEPlugin development page that upgrading is not trivial.

Monday, July 2, 2007

Apache 2.2 / mod_auth_kerb on FC6

There is a bug in krb5-libs-1.5-21.1.i386.rpm, the latest available for FC6 from http://download.fedora.redhat.com/pub/fedora/linux/core/updates/6/i386/, which affects mod_auth_kerb.

The bug manifests in the error log as:

[Sun Jul 01 06:37:54 2007] [error] [client 1.2.3.4] gss_accept_sec_context() failed: Unspecified GSS failure. Minor code may provide more information (Cannot allocate memory)

MIT has already fixed the bug (about the same time krb5-libs-1.5-21.1.i386.rpm was released), but I don't see a more recent rpm available for FC6.

The bug is in lib/gssapi/krb5/indicate_mechs.c. The if() has the condition negated, which is wrong. The function should be as follows:



OM_uint32
krb5_gss_indicate_mechs(minor_status, mech_set)
OM_uint32 *minor_status;
gss_OID_set *mech_set;
{
*minor_status = 0;

if (gssint_copy_oid_set(minor_status, gss_mech_set_krb5_both, mech_set)) {
*mech_set = GSS_C_NO_OID_SET;
*minor_status = ENOMEM;
return(GSS_S_FAILURE);
}

return(GSS_S_COMPLETE);
}
"./gssapi/krb5/indicate_mechs.c" line 44 of 44 --100%-- col 1




More here
I fixed it by installing the source RPM krb5-1.5-21.1.src.rpm, editing indicate_mechs.c, rebuilding the RPMs and installing them.

For those no more familiar with doing such things than I was, the following suggestions may help:

rpm -i krb5-1.5-21.1.src.rpm
cd /usr/src/redhat/SPECS
rpmbuild -bb krb5.spec
Check and confirm that the RPMS were built successfully
cd /usr/src/redhat/BUILD/krb5-1.5/src/lib/gssapi/krb5
vi indicate_mechs.c
Change the if() to read as above (i.e. remove the '!')
cd /usr/src/redhat/SPECS
rpmbuild -bc --short-circuit krb5.spec
cd /usr/src/redhat/RPMS
rpm -U --force krb5*

It would be better to make a patch and change the version number of the RPM, but I don't know enough to do that.

After this change, mod_auth_kerb worked fine!!

Labels