sabato 19 aprile 2008

Slackware 12.0 and Mouse Wheels

After installing Slackware we can find that mouse wheel is not working especially if we have an old mouse or an unidentified one.
It could be of help to make our Slackware believe that we have a generic mouse ad force the Xorg to use the ExplorerPS2 protocol.
Let's open the xorg.conf file in /etc/X11/xorg.conf and change some parameters (obviously with an editor using su or root account).
Find out the following line (in most cases):
Section "InputDevice" Identifier "Mouse0"
Probably we can see that automatically Slacky has configured our mouse as PS2:
Option "Protocol" "Ps/2"
so change this line it in this way:
Option "Protocol" "ExplorerPs/2"
Then search for the following line
Option "Device" "/dev/mouse"
and change its content in
Option "Device" "/dev/input/mice"
Then save all the changes and just press CTRL+ALT+Del for applying the new settings.
The mouse wheel is now working!

mercoledì 9 aprile 2008

Naked Day

Styles are disabled to celebrate the CSS Naked day!
Further information can be found at http://naked.dustindiaz.com/

venerdì 7 marzo 2008

How to customize favicon in Firefox bookmark toolbar

Often when we add a page to the Bookmark Toolbar we cannot see any Icon because the page has no favicon.
Some other times we'd like to change a favicon just because we don't like the original.

We can do it, someway :)

We can take advantage of DOM structure of a document to force the page using every favicon we want and the add it to our Bookmark Toolbar.

First of all we havo to keep in mind that Firefox cannot allow to use a local saved favicon, so we have to use an online existing one.
We can create our favicon and then publish it on our preferred host.
To create a favicon from every image we want we can use a free online service just like the one from GraphicsGuru.
When we have our favicon published on the Internet we can take note of its link.

Then we can use Firebug to force adding the page a TAG.

Just enter in the Firebug console and type:
URI="http://www.myHostSpace.*/MyFavicon.ico"
favicon=document.createElement("link");
favicon.setAttribute("rel","shortcut icon");
favicon.setAttribute("type","icon/x-image");
favicon.setAttribute("href",URI);
document.getElementsByTagName("head")[0].appendChild(favicon);
where the variable URI contains the link to the favicon.

Then press RUN button and... voilà!!!
The page has now its beautiful favicon.

We can now add it to our Bookmark ToolBar!

getElementsByClassName for multiple class elements

I found a lot of javascript function able to retrieve a collection of elements having the same class attribute, but I did't find any that can be used with multiple-class elements so I write my own function


function getElementsByClassName(className){
var collection= new Array();
var all=document.all||document.getElementsByTagName("*");
for(var i=0; i<all.length; i++){
if((all[i].className!="") && (all[i].className!=null) && (all[i].className.indexOf(" ")>-1)){
splitted=(all[i].className.split(/\s/));/*this split the names in the class attribute*/
for (j=0;j<splitted.length;j++){
if (splitted[j]==className) {collection.push(all[i]);}
}
}
if (all[i].className==className) {collection.push(all[i]);}
}
return collection;
}