Bite My Code

the code with no tag

Make your Firefox better - 10 Useful Addons

without comments

Google Chrome is the hottest topic these days. It’s fast but Firefox is still my first choice since they have lots of extensions, add-ons to enrich the features. And you can’t really live without them.

  1. Firebug - the must have addon for developers, the famous debugging tool
  2. Clear Cache Button - a very simple add-on that give you an easy way to clear your cache
  3. Delicious Bookmarks - the best bookmark service to replace firefox’s bookmark feature, especially you’re using multiple computers
  4. Download Statusbar - just like the download bar of Google Chrome but this addon released for years.
  5. GooglePreview - this make your google search result better, it provides a thumbnail for each search result
  6. Fission - do you like safari progress bar? this addon turns your firefox address bar displaying the progress like the safari one, nice
  7. Linkification - turn all your text url clickable, simple but very useful
  8. Web Developer - another must have addon for developers
  9. Locationbar - another Google Chrome like feature but this one even better, puts emphasis on the domain and linkifies the URL
  10. Auto Dial - Google Chrome feature again, display your most visited website in the new tab
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Live
  • Reddit
  • YahooMyWeb

Written by alvin

September 5th, 2008 at 2:03 pm

Posted in Software

Tagged with , , ,

Simple Ajax based on Prototype Framework

without comments

Prototype is one of the most commonly used ajax framework in web2.0. Here is a very simple example to make a ajax page loading in the HTML.

First, you need to have the prototype framework, you can download here, or you can use the included one in the example zip file.

I wrapped the ajax page loading function in a javascript function, so we can reuse this function more easily, here is the javascript code:


function loadPage(pageURL, displayID, queryStr) {
var url = encodeURIComponent(pageURL);
var params = '';
if (queryStr != undefined)
params = queryStr;

new Ajax.Request(url, {
method: 'get', parameters: params,
onSuccess: function(transport) {

if(transport.responseText.length > 0){
document.getElementById(displayID).innerHTML=transport.responseText;
}}});
}

You need to pass 3 parameters for this function:

  1. pageURL - the page url which you want to load, without the HTML and BODY tag
  2. displayID - the div id which the result will be displayed
  3. queryStr - name and value pair for dynamic page, which is optional

And you need to define the display div in the HTML as follow:

<div id="display_body">
</div><br />

Now, you can simply use this javascript to load a page by ajax:

<a href="javascript:loadPage('hello-world.html', 'display_body')">Load Hello World Page</a>

And here is the example source in zip format:
Download Here

Feel free to give any comments for us, thanks.

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Live
  • Reddit
  • YahooMyWeb

Written by alvin

August 7th, 2008 at 12:24 pm

Posted in Web Development

Tagged with , , ,

6 must-have Wordpress plugins

with 2 comments

Wordpress blog is very popular nowaday, we use wordpress in this development blog. We would like to introduce some must-have plugin for wordpress which make our job easier.

Here is a list of plugins:

  1. All in One SEO pack - help you do all SEO for your blog, like generate all title and meta tag automatically for you.
  2. Google Analyticator - everyone use Google Analytics now, this plugin make us more easy to use it on your wordpress.
  3. Google XML Sitemaps - another great tool to help you generate sitemap which help search engine to better understand your site.
  4. Sociable - one plugin for all social bookmarking sites, enable user to submit your posts or pages to their favourite bookmark.
  5. Similar Posts - display similar posts in your sidebar, you need to have Post-Plugin Library installed
  6. wp-cache - cache your dynamic posts or pages, make wordpress more efficent in loading, you may try to use wp-super-cache

Please let me know if you have more plugin to introduce to others, thanks.

Enjoy your wordpress blog.

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Live
  • Reddit
  • YahooMyWeb

Written by alvin

August 4th, 2008 at 1:28 pm

Posted in Web Development

Tagged with ,

Get your Sign Up Referer by PHP

without comments

Thanks to Google Analytics that help us on website traffic tracking. But for some reason we still need to track some specific statistics, like the referer of the user when user do a specific action, for a example, sign up on your website.

By using session in PHP, we can easily get the referer no matter which page the user is coming. Here is the PHP source code:


session_start();

if (empty($_SESSION[_referer'])) {
	$host = parse_url($_SERVER['HTTP_REFERER'],PHP_URL_HOST);
	if (empty($host)) {
		$_SESSION['_referer'] = 'DIRECT';
	} else {
		$_SESSION['_referer'] = $host;
	}
}

$referer = $_SESSION['_referer'];

And we can store the referer in the database or other tracking suit if we need.

You can download the php file and simply include it in your php header.

Source Download

How to use:
1. Download the php source file and rename to .php extension
2. Include the php file in your php source or in your generic header file
3. Now you can just use the $referer to get the referer host information


include '/path/to/referer.php';

echo $referer;

Enjoy!

  • Digg
  • del.icio.us
  • Facebook
  • Google
  • Live
  • Reddit
  • YahooMyWeb

Written by alvin

August 1st, 2008 at 6:37 am

Posted in Web Development

Tagged with , , ,