lightdruid.com

Coffee & programming

UI & Interfaces

Another example of the case to show how ugly interface could be if it is designed by developer.



Full version

jQuery – center element on the screen even if window has been resized

It seems that one of the most popular questions asked is “How to center element in the middle of the page” either using pure CSS or Javascript. Google it and you will find tons of answers.

Here is my implementation of jQuery utility function which puts the element in the center of page. The only one difference from the solution provided here is that my version of function does take care of the situation when browser window is resized.

jQuery.fn.liveCenter = function () {
    var that = this;
    var $w = $(window);

    function centerHelper(elem) {
        elem.css("position", "absolute");
        elem.css("top", ( $w.height() - elem.height() )
            / 2 + $w.scrollTop() + "px");
        elem.css("left", ( $w.width() - elem.width() )
            / 2 + $w.scrollLeft() + "px");
        return elem;
    }

    $w.resize(function() {
        centerHelper(that);
    });

    centerHelper(that);
}

And here is how it looks like live at jsFiddle.

gcc 4.6 build error on fedora 13 x64

Tried to build new fresh gcc 4.6 on fedora 13 x64 and faced build problem. Using following configure switches:

 

./configureĀ  –enable-languages=c,c++,objc,obj-c++,go –disable-dssiĀ  –enable-shared –enable-threads=posix –enable-checking=release –with-system-zlib

GCC cannot build it with error message complaining about missing gnu/stubs-32.h:

In file included from /usr/include/features.h:385:0,
from /usr/include/stdio.h:28,
from ../../.././libgcc/../gcc/tsystem.h:87,
from ../../.././libgcc/../gcc/libgcc2.c:29:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.

The problem should be resolved after you will install glibc-devel:

sudo yum -y install glibc-devel

and adding

–disable-multilib

to configure, so that you configure command line will look like this:

./configureĀ  … –disable-multilib

New blog

Finally I’ve decided to move into VPS instead of shared web hosting. It looks great, totally new experience.