Archive for May, 2009
IE6 PNG Glitch Summary
by z3n on May.30, 2009, under Notes
Despite all those javascript, css, htc, etc. fixes for correctly displaying a png on IE6 (alpha image hack) there’s a couple of issues that never go away:
- You can’t have a custom position on the PNG background (check this post about alternate background positions if you’re not familiar with it);
- You can’t have it tiling, it always will be streched to the size of the element (scale) or will be shown on it’s regular size;
- If it’s on a background of a DIV links, forms and text will not work right;
- On slower machines it will lag the site;
Apache server-status speed unaccuracy
by z3n on May.30, 2009, under Notes
I’ve noticed that apache’s server-status’ speed value is wrong, apache does not take in consideration if the file was all sent or if the download has finished to calculate this, not even the speed itself only the size of the request.
I’m uploading a file from my machine to another using apache running on my machine, however, my connection is slow and eventually the download stops, i can upload at around 64k/s, and yet, apache thinks i’m sending at 12.3mb/s, not sure if this is because the file is being resumed or because apache isen’t really monitoring this kind of activity.
I also noticed that apache does count the cached files on those sums, so, even if the user has the file already and don’t actually downloads off the server (just send a header to confirm if it matches with the local) apache will count this as a full download. As stated on a server i redirected to another.
Little Firefox Glitch
by z3n on May.30, 2009, under Coding, Tips & Hints
Problem:
Having a fixed background may be a problem on firefox if you just declare it like this:
body { background:url(file.ext) fixed; }
Solution:
body { background:url(file.ext) fixed #color; }
How to format a disk on linux
by z3n on May.25, 2009, under Linux Happyness
Problem:
So you got that old ass windows disk and want to get rid of windows at once or you just want to format a disk on ext3 since it’s so much better than ntfs/fart32
Solution:
I must say that i wasn’t expecting anything easy as format c: , but this was so much more fun.
First you need to umount the disk you want to format, for me it was a issue, i’m using samba (smb) to share the disk, so i had to stop smb service before umounting it. Make sure you do that first, if you don’t you will fall into funny errors.
Then you need to create new parttitions or remove the old ones using fdisk, if you are familiar with old DOS and windows fdisk CLI this shouldn’t be a problem.
fdisk commands are easy:
p – lists the partittion tables
n – creates a new partittion
d – deletes an partittion
w – write changes (if you don’t write changes before quitting nothing will be changed)
t – file system type
in order you should d all the partittions you don’t want and n a primary or secondary one, depending on your case.
After that you need to choose a file system with t, i like the 8e which is linux LVM, you can also try 83 the default linux one.
Then you do w and quit.
You might see some warnings/notices about kernel only seeing the right partittions after reboot, that’s right, no need to worry.
Now that you created the partittions you need to format the disk with mkfs -t <format> /path/to/dev , format could be a bunch of things, i like ext3.
As recommended by many of the sources i saw, you should do a disk check, it’s importaint, specially when you have an old ass disk that could be broken by windows or time usage.
fsck -f -y /path/to/dev
this will fix and answer yes to all questions.
You should reboot your system in order to kernel regonize the new partittions, however, in my case the partittions i did were the same size just different file system, from fart32 to ext3, for me it worked fine without rebooting.
Sources:
eHow (Warning: spammy site)
Javascript to get the whole document width and height
by z3n on May.25, 2009, under Coding, Tips & Hints
Problem:
How to get document’s height and width, not only the view area or the window size, but the whole thing including the scrolling.
Solution:
There are some variants of this solution, because some browsers take this proprieties in a different way, however, here’s a little function i wrote able to return the right dimensions no matter what:
with (document.documentElement) {
var h=Math.max(clientHeight,scrollHeight);
var w=Math.max(clientWidth,scrollWidth);
}
there’s also the inner values, but they only work on certain browsers, this would be able to get the numbers you need on IE6+ , FF and mostly of the decent browsers, if you must have working on every browser check quirksmode. This will also return the highest value, meaning that if the page itself won’t fill client’s width/height, it will get the biggest value, perfect when you need to do a full page div or something like that.
Sources:
(13) Permission denied: /.htaccess pcfg_openfile: unable to check htaccess file
by z3n on May.25, 2009, under Tips & Hints
Problem:
All pages are 403 (fobidden), no matter what.
Solution:
There’s nothing wrong with apache, the file permissions are wrong, make sure that the folders that apache is trying to access are at least 755 (chmod 755), including the /home/ ones.
Simple AJAX/xmlhttp query issue
by z3n on May.20, 2009, under Coding, Tips & Hints
Problem:
You like jQuery, however, doing simple tasks get impossible since jQuery is too massive, even packed it’s over 50kb. The alternate, script.taculo.us, is even bigger!
Solution:
Doing a simple ajax or xmlhttp request, is nothing out of this world, actually, it’s pretty easy, you just need to watch it if you do more than one on the same page, or when a error happen you might want to have a handler.
Based on quirks mode example i wrote this little function, it’s able to do a rudimentar queue and return plain text from a remote server, it’s also compatible with IE.
-
_lD=function(url){
-
if(p==1){
-
setTimeout("_lD('"+url+"')",250);
-
}else{
-
p=1;
-
x=null;
-
if(window.XMLHttpRequest){
-
x=new XMLHttpRequest();
-
}else if(window.ActiveXObject){
-
x=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
if(x!=null){
-
x.onreadystatechange=function(){
-
var r="";
-
if(x.readyState==4){
-
if(x.status==200){
-
r=x.responseText;
-
-
// manipulate your result here
-
-
p=0;
-
}
-
}
-
}
-
x.open("GET",url,true);
-
x.send(null);
-
}
-
}
-
}
Packed, this function is less than 500 bytes, much better than the 58kb of jQuery, heheh
Alternate method for background images
by z3n on May.20, 2009, under Tips & Hints
Problem:
When you need to build up a page with lots of little images , like the borders, gradients, different backgrounds , slideshows etc. All into the same page.
You probably will have lots of images on the same page, specially if you cut them to save much bytes as you can, however, you might fall into a different issue:
Too many images will make the load slow as well, since browser will open only 2 connections at same time with the server (every connection takes a while to actually start downloading something since it needs to go thuru all the hops and reach the server etc etc), meaning that all that nice optmization you did worth nothing since you got lots of images.
No good!
Solution:
I’ve seen this only one time at fleXcroll script, and many times on old games textures.
The technique used on both is the same, although might not ring a bell for you it’s pretty simple to use, a little complicated to add on css, but will do the work.

picmap png file zoomed
This is a zoomed version of a picmap (I don’t really know a formal name for this that’s how i will call it) png I did, you can see it got transparency and stuff.
The different colors and green lines are just to highlight the different images i merged here, they will be used all in background at the css, meaning that i can have the position easily set.
As you can see on the bottom there’s 2 huge blocks, this is for the horizontal repeat, since i can’t define a fixed area on the image for the browser to pick as pattern for repeat-x (for example) I need to do this. You may think that it would be a waste, since usually, you can do a 1px width image for this type of thing, however, when you merge pictures toguether you’re not only saving the connection delay time, but for some image formats you have a header on the file or a color index that, when merged, became smaller than the separated files.
In the original 2,65kb png, I managed to merge 17 different pictures, that separated were 4,79kb, and yet you can see that there still some space left to add more things if i wanted to.
The css for the top circle (which is actually 4 corners) would look like this:
.bB,.bC,.bD,.bE{height:9px;width:9px;font-size:1px;}
.bB{background:url(img/b.png) 0px 0px;}
.bC{background:url(img/b.png) -9px 0px;}
.bD{background:url(img/b.png) -9px -9px;}
.bE{background:url(img/b.png) 0px -9px;}
Note that all the positions are negative.
Depending on the usage of your picmap you might want to have repeat-y’s for example, so you need to rethink the layout in order to take maximum of it.
For me, i only have repeat-x backgrounds, so I broke it in different formats, gif, png and jpg, doing that I could take the best of each.
fsck on a partittion in use?
by z3n on May.13, 2009, under Linux Happyness
Problem:
You need to run fsck, however, the partittion in question is in use and you can umount it cuz it’s the same partittion of the critical linux files are.
Solution:
You need to boot into single-user mode, I’m using GRUB so that’s how you do:
GRUB will wait 3 seconds before booting, press enter and edit the linux entry (e) you will see a line that theres a kernel on it, edit this one (e) and in the end, put single
press b to boot and done, linux will boot on a minimal resource mode, wich will allow you to umount anything, then finally run the fsck.
Related commands:
umount -f /dev/… (to forcefully umount a device)
fsck -pyvf /dev/… (to check a device, fix, yes to all queries, verbose mode and force even on clean devices)
Sources:
non-responsive smbd
by z3n on May.12, 2009, under Linux Happyness
Problem:
I have this shares between my linux and windows machine, they use samba. Eventually, eg. when i’m listening to music, it stop working for a while, i see a cpu peak on top then when it drops song resumes playing.
Solution:
It looks like some other process is taking the whole cpu (not a big deal since this machine is old and slow) but like on windows (argh) you can control process priorities on linux, a simple renice did the work.
for running processes:
renice <priority value> -p <pid>
for new processes:
nice -n <priority value> <command>
Sources: