JSON with Padding = JSONP
With JSONP, you can avoid the "Access is Denied" problem when loading a remote AJAX request. jQuery 1.2.x now supports JSONP, you can use that or this simple code snippet. In this example, let's assume you're on a page with a remote javascript loaded, now you only want this remote script to reload, not the whole page.
And the result of getJSON.php:
Labels: ajax, code, javascript
Reloading partial page content with JavaScript
If you need to reload a partial content (not the whole page) with JavaScript, you can easily use AJAX (jQuery is the simplest). But if the content is also from another website (eg: some API), then you can use JSONP (JSON with Padding) to get around the security protection of AJAX requests.
And in the server-side javascript.php, you would return:
Labels: javascript
Javascript table grid sort
PHP5 Class for Yahoo Term Extractor API
Given a content string, this class uses Yahoo Term Extraction API to generate a list of keywords/phrases that you can use for things like META tags or other SEO objectives.
Labels: code
Fix php_browscap.ini for PHP
This class parses, fixes and prepares php_browscap.ini into browscap.ini for PHP. It also detects if the latest version needed to download.
Labels: code
Simple & fast spider detection
Developers can use the browscap.ini to detect if the User-Agent is a search engine or data collection spider or not. However, that file is rather large and will be expensive on resources. If you need a faster, simpler (albeit less accurate) method, this class can be useful.
Labels: code
fastcgi load balancing with lighttpd
Lighttpd, fast-cgi & PHP can do quite a wonderful setup that can handle significant load. You can have many layers of load balancing & fail-over. Here is a three-layer approach. A dedicated load balancer directs many web servers. Each web server (lighttpd) delegates the processing of dynamic to multiple application servers (fast-cgi).
Configurations
Check out the lighttpd config for mod_fastcgi. In this case, we want only load-balance a single controller PHP file that is called heavily. We also let the webserver be the appserver itself for the moment and become a dedicated one if it becomes overloaded. All other regular PHP requests are served by the localhost (webserver). Add this into your lighttpd.conf: To start the fast-cgi processes on the application servers:Parse stats from PowerDNS webserver
PowerDNS has a webserver that reports running stats. This code converts the HTML output (which has quite a few syntactic HTML errors) to semi-XML