I was using a php sdk today where the config file is NOT a php file, but rather a file named .cfg…
The problem? You have to restrict access to this file with a .htaccess file to prevent someone from reading it. Whereas, if it were a php file, not only would you not have to prevent access to it, you also don’t have to write your own parser.
Lesson… Don’t use a cfg file, where a php config file will do.
Unless you’ve been out of touch for a long time, you’ve heard that Sun bought MySql, and was subsequently bought by Oracle. If you use java, you’ve noticed that Oracle hasn’t drug their feet in rebranding sun products as Oracle… java url’s are now download.oracle.com instead of download.sun.com.
MySQL appears to have escaped the re-branding at the moment. It will be interesting to see what Oracle does with it in the future… If they killed it, they would tick off half the development community in the world, making them less-likely to choose Oracle products in the future (let’s face it, there are LOTS of un-objective decision makers in the world). But they could put some spin on it, and use it to build their market share… Let’s wait and see…
I used to rely on the Firefox Plugin Tamper Data to get the nitty gritty deatails of http requests. Firebug has a feature that is similar as well (the net tab). But I find it buggy. Recently, a fellow developer introduced me to the HttpFox Firefox plug-in, and it is awesome!
I now use it all the time.
The only caveat, is only start it when you need it, and stop it when you are done. Leaving HttpFox running and capturing for long periods of time slows Firefox a lot.
Uniserver on Windows REQUIRES the .htaccess file to have the “Options +ExecCGI +FollowSymLinks” line in it… Or else you get a 403 forbidden on every page you try to access.
Check out this AWESOME free prototyping tool. Pencil Project. (It’s a Firefox Plugin / XUL Application)
It let’s you mock up fully functional websites without writing any html code. Then, you can export it as html, and use it as a starting point for a better mockup. Or export all the pages to png’s in one shot, and use those as a starting point in Adobe Illustrator, or your design tool of choice.
It’s great for useability testing. Mockup your ideas. Put them in front of customers / users, re-prototype, and continue until you get it as good as possible, and meeting your cash cow customers’ needs. THEN make it look good.
I found out about this site today, that hosts a sample .htaccess file that will block IP Addresses that are known spammer ip’s. Not email spammers, but webform spammers… (Very annoying!)
Troubleshooting… When you are troubleshooting something, divide and conquer… In a large system, choose a point in the middle of the system, and see if the problem exists there. If it does, move backwards half way to the start of the system, and test again… Continue….
This process allows you to find problems in large and complicated systems effeciently.
Good instrumentation in a large system makes this process even easier. A blackbox system, in which you cannot look inside is extremely difficult to troubleshoot. The same problem exists for systems that cannot be operated with it’s clothes off. For example, Computer monitors. I have tried to repair expensive computer monitors in the past with some success. There are lots of little controls inside the monitor that can be adjusted. You can also find bad solder joints by wiggling parts inside the monitor and see if it makes it start working. However, many monitors cannot be operated with the cover off. The same problem exists for code that cannot be debugged easily.
So… Next time you are trying to fix an annoying bug… Divide and conquer. If you don’t have good instrumentation, add it in! In php, and easy way to add instrumentation is by adding your own custom header with debug information.
If you are using nicEdit on content editable areas instead of the iFrame method, then you may have run across the FireFox bug that prevents you from changing the text alignment on the first line of a content editable element.
As a work around, change the nicCommand method in nicEdit.js (Line 610 or so), to the below. This code catches the error that firefox throws, inserts a temporary div immediately before the selection, repeats the call that failed (the bug only causes the alignment to fail when it is the very first element in the content editable), and then removes the temporary div.
nicCommand : function(cmd, args) {
if ((cmd == 'justifyright') || (cmd == 'justifyleft') || (cmd ==
'justifycenter') || (cmd == 'justifyfull')) {
try {
document.execCommand(cmd, false, null);
}
catch (e) {
//special case for Mozilla Bug #442186
if (e && e.result == 2147500037) {
//probably firefox bug 442186 - workaround
var range = window.getSelection().getRangeAt(0);
var dummy = document.createElement('div');
//To restore the range after collapsing for triple click bug...
var restoreSelection = false;
dummy.style.height="1px;";
//find node with contentEditable
//Triple Click selection Problem in mozilla, the selection contains the content editable div, which creates a problem for some reason, so we collapse the selection to the end, and then re-select everything...
if(range.startContainer.contentEditable == 'true'){
window.getSelection().collapseToEnd();
restoreSelection = true;
}
var ceNode = window.getSelection().getRangeAt(0).startContainer;
while (ceNode && ceNode.contentEditable != 'true')
ceNode = ceNode.parentNode;
if (!ceNode) throw 'Selected node is not editable!';
ceNode.insertBefore(dummy, ceNode.childNodes[0]);
document.execCommand(cmd, false, null);
dummy.parentNode.removeChild(dummy);
//RestoreSelection if we changed it...
if(restoreSelection){
window.getSelection().addRange(range);
}
} else if (console && console.log) console.log(e);
}
} else {
document.execCommand(cmd, false, args);
}
}