Notes
jQuery + XML + IE = xmlDOM issue … or no??
by z3n on Aug.29, 2009, under Coding, Notes
Problem:
In the middle of the developing of a very complex script i figured out that IE was simply ignoring the xml documents i sent to it by ajax. Searching the web i’ve found this $.xmlDOM jQuery extension that is supposed to fix the IE issue with xmls. Although the extesion was clear and other people claims it work, it didn’t worked for me, how lucky is that?
Solution:
This took a while to solve, and i will skip all the boring process. Turns out that i didn’t needed the $.xmlDOM extension at all, the issue was on the xml. I’m developing this script in a language that has accents, i need to use `á` like html entities in order to avoid malfuncioning with data transport, so this little ampersand was breaking IE.
How nice is that?
.htaccess 401 note
by z3n on Aug.20, 2009, under Notes
401 redirects must be within the same domain without the full url:
ErrorDocument 401 /error_page.ext <– right
ErrorDocument 401 http://www.example.com/error_page.ext <– wrong, EVEN if your domain is the same that it’s being redirect to.
overflow reloaded
by z3n on Aug.19, 2009, under Notes
I’ve been using those crappy generic themes for a while, so today i decided to do a ripoff on pixeled and do my own theme.
Nothing so much amazing, just black and simple, the way i like to read in the dark.
Keep it simple, stupid jQuery experience
by z3n on Aug.14, 2009, under Coding, Notes
As much as I like jQuery I must admit that it’s far away from simplifying things. Although it might be a great idea using it on 100% jQuery scripts, it’s a real bad idea using it to refurbish an old script.
Today I’ve spent over 2 hours implement jQuery on a old script I have, and I felt into so many issues that it didn’t worth at all.
My script was simple, I had a huge variable list that could be edited by a form, script loops through the variables building a form with input fields for each variable. I will not get into specific details because it’s boring, but I needed to allow the user to add a new variable inside an array, so i thought that jQuery would help a lot since i only would need to dynamic add a new input field as needed then post everything back to script to save the file.
First I spent an hour figuring out that jQuery was ruining the text by converting the whole thing into UTF-8, loosing all the accents, eventually I found out about contentType encoding ajax variable:
contentType:"application/json; charset=utf-8"
which could be changed to the charset i wanted.
It was useless, jQuery still posting into the wrong charset, there’s some other tweks on this, but they are also useless.
I was able to fix the accent issue with this php statement:
mb_convert_encoding(urldecode($variable),”ISO-8859-1″,”auto”);
This is much more obscure though, but I was familiar with it since i coded in japanese charsets which are a pain to convert.
After having this cleared, and searching a lot of useless blogs and postings, turns out that jQuery was using the hard coded form names to post the data, which could be overlapped by an dynamic added field, I did a script to change the name of the hard coded inputs, something like this:
$(“#field_id”).attr(’name’,’new_name’);
Theorically, it worked, but when I did:
$(“#form”).serialize();
jQuery used the dynamic fields with the ordinary hard coded ignoring the attr changes.
Now I had to add a handler to dynamic convert and read all the inputs and do my own serialize in order to TRY to make it work…and that’s because i didn’t tested it on IE yet.
So that’s when I quit using jQuery for this script and do something plain and simple, which took me about 20 minutes and 0 searches.
It looks like that if I had used DOM elements for the whole form, all elements generated by jQuery itself, not hard coded, i would have less trouble with the form, although, the charset issues still.
Super Fun Sources:
jQuery Ajax Documentation (completly useless since contentType explanation has 2 lines)
MySQL procedure related functions
by z3n on Aug.05, 2009, under Notes
Since i keep forgetting this I will post as reminder:
show procedure status;
Lists procedures stored on current database.
show create procedure database.procedure_name;
Shows the source of the stored procedure.
grant execute on procedure database.procedure_name to username;
Grants execute privileges to the specific procedure and user.
Those are somehow obscure functions on mysql documentation, I think that they are still improving the procedures usability.
Linux Nice/Renice Note
by z3n on Jul.16, 2009, under Linux Happyness, Notes
It’s odd, but I though that the higher the nice number was higher was the priority of a process, turns out that I was wrong, it’s the inverse.
Example: Priority 20 is the default lowest priority, while 0 is the normal priority. There’s also negative values to force a higher priority.
Besides the priority values, I haven’t found anything about cpu affinity, however, I didn’t tried hard, since the machine I’m running linux is single core anyway.
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.
32-bit Windows and 4gb+ RAM thoughts
by z3n on Feb.09, 2009, under Notes
I’ve been reading some articles about this, and figured out that despite the useless speculations all over the place there is no way to make windows regonize more than 3.25gb or 3.5gb, due PCI and other devices memory allocation 32-bit windows is unable to make the whole 4gb avaliable for the programs.
The explanation is a bit complicated, but resuming 32-bit systems can’t handle more than 4gb total memory and because of the other devices on your computer you might not even be able to reach the full 4gb, so depending on your video card and other stuff that got built-in memory you will get your total ram deducted from it.
Although 64-bit OS might sound like a great solution for you being able to use the whole ram you got (if you got 4gb+) it might be a real pain, since not all programs got a 64-bit version.
Apart from that, i saw some comments about twecking the windows boot.ini in order to gain more memory or to allocate a maximum ammount to kernel:
/3GB switch will make kernel have a maximum of 1gb memory while other programs will have 3gb (theorically) — for me this switch is a total crap, it slowed the system, according to microsoft windows take a half of the ram as limit for kernel, so if you have 4gb it will take 2gb as maximum of kernel memory.
/pae switch this will enable access to extended memory, this works only on intel machines with specific chipsets, check microsoft site for more info. This will NOT fix the 4gb issue on windows 32-bit only on 64-bit.
URLEncode
by z3n on Feb.04, 2009, under Notes
“The superglobals $_GET and $_REQUEST are already decoded. Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results.”
Assuming that you can’t detect if the $var comes from a superglobal you would fall into this issue so:
Wrong:
$x=@gzuncompress(base64_decode(urldecode($var)));
Right:
if (strpos($var,”%”) !== false) { $var=urldecode($var); }
$x=@gzuncompress(base64_decode($var))