Auto margin shifts my page content to the left

I found myself wasting about 2 hours of my time trying to understand why only one of my pages moved about 16px to the left when switching back and forth between the different page. My problem is that I was using a template and that everything on the two pages were exactly the same. Here is an example of what I mean.

Using the famous divide-and-conquer problem solving method (ha ha!), I started to remove some text to find out the culprit paragraph, and realized that the problem was only present when I had a lot of content on the page. After a few google searches, I found a thread on sitepoint’s site that explains exactly my problem (titled: Web Page Wiggle Issue and Margin Auto Wiggles & The Vertical Scrollbar). The problem lies in the use of “auto” for centering pages, much like in the very popular “body {margin: 0 auto; width: 960px;}”. This causes the page to wiggle (move to the left) between pages where the vertical scrollbar is needed (longer content) and where it doesn’t appear (firefox adds the scrollbar as needed, whereas IE always keeps it!). From the website, I found two fixes for the problem:

You can easily fix this, using CSS, by adding this one line in your stylesheet:

html {overflow-y: scroll;}

Another fix, if you are using JQuery, is the following:

$(function(){
    $('<div/>').css({
        position: 'absolute',
        top: 0,
        width: '1px',
        height: ($(window).height() + 1).toString() + 'px'
    }).appendTo('body');
});

Emulating the Recycling Bin in bash

I just ran into a problem where I accidentally erased a file that was very important and could not recover from it (it was a monstrous statistical model that takes about 5 hours to re-train…). I decided I had enough of this and needed a way to be able to recover from those silly mistakes (apparently not making them in the first place just wasn’t an option…) I wondered if anybody ever run into this problem, and what was their personal solution? Here is what I found and tested today (it works pretty well).

I know that there are processes that backs up your whole $HOME on a regular schedule, I forget the name of this process, but that’s not exactly what I need. I always liked the idea of a “recycling bin” from the GUI Operating Systems like Windows (or KDE) and decided that that’s exactly what I needed. I found the next best thing on the internet (See John’s Bash Tools for his original post).

I simply put this in my .bashrc and now can use “junk” instead of “rm”… It’s a pretty neat little trick actually. I then can use “empty_junk” every now and then to keep the size of my home reasonable. I could even add “empty_junk” in my .bashrc so that it gets emptied everytime I log on (I won’t because I often log onto twice at the same time and would create problems…).

##############################
# Emulating a reclycling bin #
##############################
# This function creates a directory called .junk
# and creates directories labeled by the date
# inside of this directory. Then, when a file is
# "junk"ed, it is actually just moved to this
# directory. The command line accepts as many
# files as you would care to junk, and can even
# work on entire directories. Be careful, since it
# is really just a wrapped "mv" command, you may
# overwrite your junked files if they both have
# the same name and end up in the root directory.
 
function junk () {
    TODAY=$(date +%d-%m-%y)
    if [ ! -e $HOME/.junk/$TODAY ]
    then
        mkdir -p $HOME/.junk/$TODAY
    fi
 
    for x in $@
    do
        mv $x $HOME/.junk/$TODAY
    done
}
 
# A very simple function to empty the trash.
# I set -Ri so that it recurses but prompts you.
 
function empty_junk () {
    rm -Ri $HOME/.junk/*
}
© Copyright Bonuel Photography - Theme by Pexeto