yes, php will always return strings with mysql_fetch and mysql_fetch_assoc, which is sometimes good, sometimes not so good (right now I’m dumping results with json_encode to a java/velocity page where it sucks big time). What to do? Use mysql_num_fields on results resource, store the set in a private array and use a fetch_assoc proxy with type juggling on the required fields…
Posts Tagged ‘notetoself’
Php fetch from mysql and string
Wednesday, July 23rd, 2008Dom access speed
Thursday, July 3rd, 2008I have the very strange feeling that “for some reason” we are really raping the browser… Today I had to optimize a special control which consists of a table and a couple of mouseover effects (crosshair-like hiliting, different styles, active/inactive/disabled cells, tooltip with a special shape and transparency). While I managed to squeeze out some speed from this monster, the surroundning dom is way too messy; so, what can one do (without an iframe isolator) in order to achieve speed with hovers and special effects?
- forget css query selectors (the project had access to prototype 1.5 and a custom built framework which recycled it’s query core from jQuery); use getElementById IF you REALLY need it
- cache dom elements if you leave the whole area “intact” (full innerHTML rewrite in the veins of Trimpath will leave you with dissociated dom nodes and you’ll loose the gain with reassociating those)
- as a golden rule, if you need a static value multiple times, store it in a variable, but don’t fetch it all the time from the dom (my collague have found a clientWidth access in our pager which alone took up more time than the whole recalculation of the paging process)
- say good bye to javascript regexp operations, especially matches; use substr, much faster – just don’t overdo it (you know, joining and friends)
- stay away from setTimeout magic; with so many hovers zero mode delays will make no difference in IE, low values will give you a headache, high values will result in “trail lags”
- use onmouseenter/leave for ie and proper events for the rest of the world: use the parent container, deal with bubbling (stop events if/wherever neccessary) and do a clean work
- rely on css hovers wherever possible, do NOT script unless it’s neccessary (like for ie6)
- if it’s only one css value (like bgcolor) then do it from script, instead of changing the classname somewhere high above, because the render trigger will eat up time; also note, that while one big css class change sounds like faster than a couple of smaller changes, it depends on the browser’s rendering engine!
- use css tiles carefully; if something can be done with an inverted image and a bgcolor change, than stay away from tiles; what you gain on caching (well, by not dealing with it), you will lose on performance
That’s all for today :) I know this is not fun, but remember, “speed is not a problem until it is a problem“.
Criticism and workflows, note to self
Wednesday, January 30th, 2008Offtopic sidenote: I’m really trying to shut my big mouth up and stop criticizing the internal workflows, processes and code quality at my workplace. Because
- it seems to be unfruitful (conflicts, spreading pessimism, badmouthing etc.)
- it is totally futile (neither do I have the authority to make changes happen nor do we have the resources to incorporate the changes needed)
- it might be possible that the solutions I propose are useless and/or inadequate; it can be just me who thinks otherwise or am blinded by self confidence, hubris, frustration etc.
- producing flawed code and running into the same mistakes again and again are parts of the effort to overcome the barriers of human nature; the mere knowledge of how broken this world is, is part of the scheme that tries to fix it. Though these barriers are impossible to overcome, trying hard means we might forget the fact that the barriers are impossible to overcome. I think I’ll buy a pet oroborus tomorrow.
Being a pioneer? Thanks, but no thanks.
Wednesday, October 17th, 2007I will not be loved for this, but hey, never ever. Am not into that shit, sry. Go with the herd, learn from the best, use proven, well built technology. In the age of Internet, social networks and great thinkers one can join a team, increase value, but I don’t believe in doing magic from the ground up. Now move along, nothing else here.