January 20, 2010

Retrieve Title, Description and Thumbnail of a YouTube Video Using AJAX

The YouTube Data API allows an application to interact with YouTube and perform a variety of operations; such as searching for videos, retrieve video information and upload a video on behalf of a user. The API also provides programmatic access to the video and user information stored on YouTube. Majority of data access operations are read-only and therefore do not require the YouTube API developer key.

The API is based on the Google Data Protocol which means that the data can be retrieved in ATOM/JSON format. The following example demonstrates how we can retrieve video information of a YouTube video using the YouTube Data API, JSON and AJAX.

December 4, 2009

Determine Blogger Page Type From JavaScript Using Template Codes

You can check the Blogger page type (index, item or archive) from JavaScript by adding this template code to the head section of your Blogger template:

November 21, 2009

Installing PHP 5 on IIS 5.1/IIS 6.0 with FastCGI

Rumor has it that a PHP+FastCGI installation provides a significant performance boost compared to a regular PHP+CGI installation. Some claim that it is even better than a PHP+ISAPI installation as it allows PHP to run just the way it is supposed to be without the inherent performance penalty associated with CGI. However the installation process turned out to be too much time consuming. I have therefore decided to document the process for those who have yet to install PHP.

October 24, 2009

Box with Round Corners Using CSS and Images - Part 2

This is another technique for creating round corners using CSS and images. This technique uses nine nested DIVs and images that are positioned and tiled using CSS background-position and background-repeat properties. It does not use any absolute positioning, margin positioning or hacks. As usual, I will first outline the features and limitations of the technique:

Pros

  • Clean and tidy, table-less HTML markup
  • Hack-less CSS
  • Fluid width layout, adaptable to fixed width layouts as well
  • No JavaScript required
  • Known to work in most standards compliant browsers
  • CSS markup is independent of the images size
  • Can actually be used to create CSS fancy borders and frames (see examples below)

Cons

  • Requires nine images, nine is too many!
  • Requires nine nested DIVs, harder to manage
  • Transparent images do not work well
  • May not work all that well in IE7 and earlier versions

October 17, 2009

VBScript Ceil and Floor Functions

VBScript does not have native Ceiling and Floor functions. In order to use these function in your financial or mathematical applications, you will have to write your own VBScript implementation. By definition:

The ceiling and floor functions map a real number to the next largest or next smallest integer. More precisely, ceiling(x) is the smallest integer not less than x and floor(x) is the largest integer not greater than x.

So here is the VBScript implementation of these two functions:

October 12, 2009

YouTube JavaScript Player with Playlist

I have received appreciable feedback on my previous articles about embedding single and multiple YouTube videos in webpages. Based on that, I have created another example for embedding multiple YouTube videos with some enhancements:

  • JavaScript driven playlist
    • The video playlist is easier to configure and handle
  • Next video is played automatically when current video ends
  • Next video is played automatically if current video fails to play

October 6, 2009

PHP Rounded Corner Graphics Generator Script

The following PHP code sample uses GD library functions to dynamically generate rounded corner graphics. This PHP script allows you to specify corner radius, corner color and background color and generates the graphics in GIF format. Use this script to dynamically generate rounded corners that blend nicely into your HTML/CSS design.

August 18, 2009

Selecting Random Records from a Table

How do you go about selecting a set of N random records from a database? You can always write code for this purpose but that code will be complicated, long and slow-performer. You can instead write a query and let the database handle all the logic for you.

July 26, 2009

Adding Street View Support to Google Maps

Google Maps API version 2.104 introduces new classes that allow you to integrate Google Street View into your Google Maps. Google Street View provides 360° horizontal and 290° vertical panoramic views for various streets around the world.

The following demo shows how you can use the Google Maps API to integrate a Street View Panorama along with your Google Map. This demo uses the following classes from the Google Maps API:

  • GMap2
  • GStreetviewClient
  • GStreetviewPanorama

July 23, 2009

How to Get Feeds For Specific Labels in Blogger

Blogger generates feeds for various items on your blog including posts and comments. Not many people know that these feeds can accept certain filters. The labels filter is one of them.

You might want to publish feeds for specific labels for various purposes. As an example, Aspin.com allows coders to submit RSS file of asp related resources into their database. You can label ASP specific posts from your blog as "asp" and publish its feed. You can label php related posts as "php" and publish its RSS to another resource. You may also want to publish specific feeds for targeted audience. Labels are the suitable method to group your posts by topic. These topics can then have their individual feeds. Your visitors can subscribe to feeds of their choice. All you have to do is to publish appropriate feed URLs on a suitable location.

Here is how you can get post feeds for specific labels.