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: , ,

0 comments

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:

0 comments

Javascript table grid sort

0 comments

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:

1 comments

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:

0 comments

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:

0 comments

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:

0 comments

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 Output

Labels:

0 comments

RPM for eAccelerator 0.9.5

This is the RPM for eAccelerator 0.9.5 for PHP 5.1.6 including source RPM, you can rebuild it by running "rpmbuild --rebuild file.rpm" php-eaccelerator-5.1.6_0.9.5-1.centos4.src.rpm php-eaccelerator-5.1.6_0.9.5-1.centos4.i386.rpm

1 comments

PHP - Customize str_rot13 function

If you find str_rot13 is limited, this is a more customized string rotation function. It allows you to specify how many characters to shift (positive for moving forward, negative for moving backward) and which characters to shift.

0 comments

MySQL - Shell script to optimize all tables

Usage: mysql_tables.sh --optimize MyDatabaseABC

3 comments

Parsing Verisign .COM/.NET zone files

If you have access to the zone files from Verisign (COM/NET/EDU) and want to extract the list of domains from these zone file. This is a one-line extraction command in Linux: The command:
grep '^[a-zA-Z0-9-]\+ NS .*' edu.zone|sed 's/NS .*//'|uniq
The output will be something like this: Timing test (DB as of April 09, 2006, tested on Dual Opteron 244, 4G RAM)
DOT EDU (edu.zone, 7,645 domains)
real    0m0.143s
user    0m0.240s
sys     0m0.010s

DOT NET (net.zone, 7,338,096 domains)
real    3m33.223s
user    4m29.380s
sys     0m3.130s

DOT COM (com.zone, 50,495,462 domains)
real    24m47.369s
user    32m51.330s
sys     0m25.420s
If divide the one-liner command into 3 separate ones, performance decreases
# time grep '^[a-zA-Z0-9]\+ NS .*' net.zone > net.grep
real    2m27.388s
user    2m21.480s
sys     0m2.400s

# time sed 's/NS .*//' net.grep > net.sed
real    1m46.816s
user    1m0.270s
sys     0m1.380s

# time uniq net.sed > net.uniq
real    1m13.276s
user    1m4.180s
sys     0m0.570s

0 comments

Alexa Traffic Rank PHP5 Class

This PHP5 class utilizes the web service provided by Alexa/Amazon to get the traffic information about the site. You'll need to sign up for an account at Alexa to get the pair (access key and secret key). The first 10,000 queries per month are free. Sample Usage:

1 comments

Google PageRank PHP5 Class

This PHP5 class computes the Google PR for any URL. Source code is available online and this is the PHP5 version, can be plugged into any application/software.

1 comments

Welcome to AdSpeed.org

AdSpeed.org is an extension of AdSpeed, our popular commercial ad serving solution. We plan to use this site to share our technical and business knowledge about the online advertising industry. We benefit from open-source software every day and we would like to give something back. All the source code contributed on this site are free to the public. It's a way to say Thank You to the developers. We also host a variety of open-source mirrors.

0 comments