Aug 10 2009

Insert Google AdSense Ads between your WordPress Blog posts

According to Google AdSense Program Policies you are allowed to add up to three ad content units in a page. If you have over 10 posts in a page and you wish to insert Google ads between them, you may need to specify the position of each advertisement (for instance, the first is after the 3rd post, the second after the 7th post and the last one is after the 10th post) and make sure that the limit of 3 ad content units is not exceeded. In this short tutorial I will teach you how you can do that. The code can be applied in every page where posts are shown including the index, the archive, the tags and the search results.

I will work with the index.php file from WordPress Default Theme. The code from other themes is pretty much the same so you just need to pay attention to the details.

First, let’s setup the ads. We will use an array that will store the advertisements’ codes. Find the code:

<?php while (have_posts()) : the_post(); ?>

and replace it with:

<?php
/*
Key = Position of the Ad
Value = The AdSense Banner Code
*/
$advertisements = array('3' => '<!-- adsense ad code 1 here -->',
'6' => '<!-- adsense ad code 2 here -->',
'9' => '<!-- adsense ad code 3 here -->');

$i = 1;

while (have_posts()) : the_post();
?>

As you can see each banner code has a key assigned. For example, the second element has the key 6. We will use this value to show the banner after the 6th post on the page (in the case there are at least six results).

Now, find the line:

<?php endwhile; ?>

and change it with:

<?php
if(array_key_exists($i, $advertisements)) {
// you can add custom HTML code here
echo $advertisements[$i];
}
$i++;
endwhile;
?>

How it works?

As you can see I have declared the variable $i that auto increments inside the while statement. The $i number is incremented at the ending of each loop. Here we use array_key_exists() to see if there is any key equal with $i. For instance at the 9th loop the value of $i would be nine and will be verified if there is any key equal with 9 in the $advertisements array. If it is, the advertisement is shown.

Note: You can keep as many elements as you want in the array. You can add for instance additional banners beside the ones from Google AdSense.

To Change the ad location to beginning of the posts:

If you want to have the advertisements show up at the beginning of the posts you need to move the following code:

if(array_key_exists($i, $advertisements)) {
// you can add custom HTML code here
echo $advertisements[$i];
}

between while (have_posts()) : and the_post();

The final code should be:

while (have_posts()) :
if(array_key_exists($i, $advertisements)) {
// you can add custom HTML code here
echo $advertisements[$i];
}
$i++;
the_post();
endwhile;
Lastly:
If you would like to center your ads you can add your adsense banner code inside a stylish DIV like this

<div style="width: 470px; margin: 0 auto;"><!-- AdSense Code Here --></div>

If you are using a leaderboard then set a 730px width.


Aug 4 2009

Obama’s new poster

Obama-socialism Joker


Jul 30 2009

Join avi files in linux

Join avi files in linux

The easiest way is to use avimerge.

Merge, join two or more avi files
Prerequisites

For all this to work you need the transcode package. So install (or make sure that it is there)

yum install transcode

Instructions

1. Open up a terminal
2. Go to the directory where the files are (this is just to make things simpler)
3. Assuming that the file you want the result to be is named movie.avi, and you have two smaller files you want to merge (in order) named movie1.avi and movie2.avi, enter the following command:

avimerge -o movie.avi -i movie1.avi movie2.avi


Jul 26 2009

NYC

[Group 1]-IMG_2300_IMG_2355-56 images

[Group 1]-IMG_2239_IMG_2276-38 images

[Group 1]-IMG_5932_IMG_5944-13 images


Jul 8 2009

Some panoramas from Charleston SC

Here are two panoromics i stiched together from Charleston SC

This one is of the Bend in Church Street

Bend in Church Street

This one is of some of the houses on Rainbow Row
Rainbow Row Charleston SC


Jul 5 2009

Toxic Radioactive Drywall

The government thinks radioactive industrial waste from China is responsible for a recent sulfur stench that has plagued hundreds of Florida homes. Demand for Chinese drywall spiked during the housing boom, but federal regulators believe the drywall contained phosphogypsum, a banned waste byproduct that features prominently in Chinese construction. When used in drywall, the probable carcinogen can corrode “air conditioners, mirrors, electrical outlets and even jewelry.”

The health risk of phosphogypsum is uncertain, but industry specialists say they are troubled by its widespread use and the possibility it was exported, especially in light of recent incidents in which other Chinese imports such as pet food, toys and candy were found to be contaminated with toxic or unsafe substances.

“Considering the fact that phosphogypsum can cause corrosion, something should be done,” said Ding Dawu, a geoscientist and an authority on gypsum processing in China. “Right now,” he added, “there are no complaints [in China] because most people don’t know much about gypsum board and there are no standards against it.”

[...]

Huge phosphogypsum dump sites can be seen in all corners of China. Near the banks of the Yangtze River in central China’s Wuhan area, raw phosphogypsum is spread over 20 acres and packed 65 feet deep into the ground. The smell of sulfur permeates the air. Workers at the site said the material was given away to anyone willing to pay the transportation costs, a mere $1.75 per ton.

No one knows how much phosphogypsum board from China was shipped abroad. But in 2006, Chinese exports of drywall to the U.S. totaled a record 503 million pounds valued at more than $25 million, according to Chinese customs’ statistics. That’s enough for 32,000 homes.

The EPA, Customs, and the Department Commerce all say they aren’t required to test drywall, and the Consumer Product Safety Commission says they only ask Customs to inspect items for which there are mandatory testing requirements. So, as usual, it’s up to the Chinese quality protection agency to keep us safe.

Chinese drywall blamed for odors and corrosion in U.S. homes [The Los Angeles Times]


Jul 1 2009

Hardee’s New Ad: Our Food Tastes Better Than Someone’s Anus!


Jul 1 2009

Awesome woman driver at costco