Friday, October 21, 2011

Sticky Footer & Variable Height - modern CSS

Copy & Pasted from Page was down for me, so salvaged this from Bing search cache (Google cache didn't have):

-- cut --

Step 3: All we have to do now is to put our CSS and HTML code together. Fortunately we can use the body element as .Frame, so there is no need for an extra div tag or so.

    <style type="text/css">
        html, body {
             height: 100%;
             margin: 0pt;
        .Frame {
             display: table;
             height: 100%;
             width: 100%;
        .Row {
             display: table-row;
        .Row.Expand {
             height: 100%;
<body class="Frame">
    <header class="Row"><h1>Catchy header</h1></header>
    <section class="Row Expand"><h2>Awesome content</h2></section>
    <footer class="Row"><h3>Sticky footer</h3></footer>

Note: Remember to include the html5shiv workaround in your page (and define appropriate CSS styles) if you want to use HTML5 tags in IE8 and below. Or simply use div tags instead of header, section and footer.

A word on older browsers

The code above will work even with older versions of Firefox, Opera and Safari, so there is nothing to worry about here, but unfortunately Internet Explorer 7 and below don’t know anything about display:table or display:table-row, so we go the way of graceful degradation here.

The first thing we have to to is, to prevent the margins of elements inside the row from being outside of it, by adding overflow:hidden to the .Row style.

That gives us quite acceptable results, but the footer will always be outside of the window due to the 100% height of the .Frame and the .Row. The solution is to set height:100% in a way that all Internet Explorer versions below 8 won’t recognize. I’m using the (valid) html>/**/body CSS hack to accomplish this, but you might also use conditional comments if you feel better that way. However, here is the fixed CSS:

.Frame {
    display: table;
    width: 100%;
html>/**/body .Frame {
    height: 100%;
.Row {
    display: table-row;
    overflow: hidden;
html>/**/body .Row.Expand {
    height: 100%;

I guess it shouldn’t be too complicated to create a sticky footer by adjusting the height of .Row.Expand with some little Javascript.

-- paste --

Tuesday, September 27, 2011

WP: Turn Off Comments / Ping Backs by Default from Pages

Turn Off Comments / Ping Backs by Default from Pages

Themes functions.php or yourplugin.php:

// This is valid hack as long as "wp-admin/includes/post.php"
// `get_default_post_to_edit()` keeps calling `apply_filter()` for 
// `default_content` *after* `comment_status` and `ping_status` setting.
function my_disable_pages_default_commenting($content, $post) {
    if ($post->post_type == 'page') {
        $post->comment_status = "closed";
        $post->ping_status = "closed";

    return $content;
add_filter('default_content', 'my_disable_pages_default_commenting', 1, 2);

Snippet above turns off the check boxes only from New Pages, any existing pages must be unchecked manually.

Friday, September 23, 2011

Duplicate All Pages (in-place) in Acrobat X

This is just a small JavaScript extension to Acrobat X that allowes to Duplicate all pages in-place there exists another version which used extractPages and I didn't like that behavior so I wrote own.

First elevate privileges of the JavaScript programs:
  1. Right click on document, and choose "Page Display Preferences"
  2. Choose "JavaScript" from the left.
  3. Check the "Enable menu items JavaScript execution privileges".
Secondly save following snippet as duplicate.js to the %appdata%\Adobe\Acrobat\10.0\JavaScripts folder:
        cExec: "duplicatePagesInPlace();",
        cParent: "Edit",
        cName: "Duplicate all pages (in-place)"

function duplicatePagesInPlace() {
    var doc = this,
        pages = this.numPages;
    for (var i = pages - 1; i >= 0; i--) {
            cPath: doc.path, 
            nStart : i, 
            nEnd : i,
            nPage : i

Now you should be able to access the "Duplicate all pages (in-place)" under "Edit" menu item. If you can't see the item remember to restart Acrobat.

Saturday, July 30, 2011

Windows 7 - Photo Viewer was really slow

Windows 7 Photo Viewer was acting really slow for loading images, this fixed it:

  1. Go to Color management (Desktop -> Screen Resolution -> Advanced Settings -> Color Management -> Color Management -> Advanced (tab) -> Change System Defaults)
  2. Remove all profiles from all screens, and add single profile per display. (I chose sRGB virtual device mode profile.)
  3. Check the colors in Photo Viewer if the colors are fine then you chose good profile.

That did the trick.

Saturday, January 22, 2011

Where Django & PyDev fails

Don't get me wrong, I like Python, PyDev and Django. But I simply hate the small problems like this:

I forget something simple, like what was the order of return tuple of get_or_create? Then I try to look the tip of the function, and what do I get? The useless **kwargs passing.

Same thing with the god damned exception handling. I don't think I've seen any official package that lists the exceptions given function may rise. All functions should have a good doc-strings that lists parameters, exceptions (including nested) and in case the return value is tuple or something non obvious the order of items in tuple.

Simply, it takes ages to open up the webpage, and browse to right place of docs. There exists a fix, but PyDev does not support it. It's the official objects.inv for Django (sphinx mapping file from keyword to URI).