The title pretty much says it all. It’s 2 of the most useful AdSense ads tips for bloggers in my opinion. Obtrusive ads have the unnecessary effect of driving away readers after they have found what they needed. Unless you have amazingly great content, the chance of them becoming a loyal reader is rather low when you have ads splashing into their faces – this is not something you want to do to your subscribed readers. On the other hand, you’d want to maximize your AdSense earnings by putting up ads on as many posts as possible.

Ad Injection (WP plugin)

This tiny little plugin, Ad Injection, gets it all. Very useful plugin for you to insert AdSense ads in your blog posts AND set a specific age threshold for the posts to display ads, so freshly published articles won’t have ads to drive your subscribers away. See detailed introduction here: Ad Injection for WordPress.

Just install it from the inventory (upload or install from within your WP administrator panel) and activate it. Go to Settings > Ad Injection > “Random ad (inserted randomly between paragraphs)” and insert your AdSense code there. Depending on how aggressive you are, you can use a variety of ad formats from Google. I used a 468×15 links banner on Health Not. Check out the screenshot below:

insert ads in wordpress posts

By default, Ad Injection inserts a maximum of 2 instances of the Random ad per post. This way, the ads are well blended in the content. What works a few years back with the 336 square ad format on top of the content is gradually dying out in CTR thus click revenues. You should try something new such as this.

Another useful option of the plugin is to set “Only show normal ads on pages older than xx (days) – only for single posts and pages”. This would prove very useful if you want a good balance between ad performance / earnings and user experiences. Only displaying ads on older posts are a pretty good idea for creating a good first impression to those who stumble upon your site.

{ Comments on this entry are closed }

Sometimes you would want to check if a string is an acronym or an abbreviation by testing if it only contains capitalized letters from A to Z and nothing else. There are 2 ways to accomplish this simple task in PHP.

ctype_upper()

Use the native ctype_upper() function and you will know if the provided string contains only uppercase letters:

if (ctype_upper($string)) {
	echo $string.' is all uppercase letters.';
} else {
	echo $string.' is not all uppercase letters.';
}

The Ctype functions would turn out to be very handy when you want to test a string against different character types – digits, alphabetic, alpha-numeric, lowercase letters, uppercase letter, and even punctuations, etc. See the full list here: http://www.php.net/manual/en/ref.ctype.php

strtoupper()

Use the strtoupper() function to transform the string into all uppercase characters that’s capitalized letters, and then compare the transformed string against the original one to see if they are identical. If they are, then you are pretty sure the original string was also a string consisting of ONLY capital letters.

if (strtoupper($string) == $string) {
	echo $string.' is all uppercase letters.';
}

Check if A String Consists of Only Lowercase Letters

The same goes true if you want to do the test other way around. Just use ctype_lower() and strtolower() instead.

{ Comments on this entry are closed }

Customize WordPress Post Editor CSS Styles

by Yang Yang on January 19, 2012

Do you know you can actually change the CSS styles of the entire editing area / editor where you create the post content in WordPress? It doesn’t have to be the default styles and since version 3.0, people can freely style the TinyMCE rich text editor shipped with WordPress however they want to by a few simple changes to the theme files.

Step 1

Open the functions.php file in your theme folder (create it if it doesn’t exist) and add this line anywhere in the PHP tags <?php … ?>:

add_editor_style();

Step 2

Create a css file named editor-style.css and put it in the theme root, namely the same folder where functions.php is in. To start with, you may want to copy the CSS styles from that of the Twenty Eleven theme into yours.

Now you can freely change those styles (such as rich text font, size or color, etc.) to have your own customized WordPress editor styles. The default editor styles coming with Twenty Eleven are very nice that make me long to write. So I’m now using them for my editor in the current theme, Thesis. You should too, if you find it more inspiring than the default styles.

{ Comments on this entry are closed }

Add Wildcard DNS Subdomain *.example.com in cPanel

by Yang Yang on January 16, 2012

Lots of people ask this question and most of them probably made the matter complicated by editing the DNS Zone from WHM in the DNS Functions. But they actually should just do it in cPanel which is A LOT easier.

Just log in your cPanel which manages the domain that you want to add support for wildcard (*) subdomains. Go to:

Domains > Subdomains

And enter asterisk * in the Subdomain and choose the domain you need it added to.

Click “Create”.

adding subdomain wildcard in cpanel

That’s it. Now you can access your domain from any random subdomain and it will automatically use the A record of the main domain as their own.

{ Comments on this entry are closed }

ffmpeg delphi vclThis post is dedicated to one of my friends, Coolie (not his real name but he preferred to be called that way among friends), a father and self-entrepreneur who created the outstanding Delphi VCL component for FFmpeg that makes it extremely easy to develop audio and video applications for Windows.

For those who are not Windows desktop developers, FFmpeg is the ONE video and audio applications library across all major platforms that is able to encode, decode, edit, convert and stream audio and video. It is widely adopted as the standard library for multi-media applications development. Chances are, what you currently have for media player in your operating system uses FFmpeg to do all the underlying work.

The problem with FFmpeg is that it’s only got a command line interface. You would definitely find it fascinating if you are a Linux guru, but not GUI users. Developers must create another layer of interface to accommodate end users, another layer of abstraction for FFmpeg, and that’s exactly where Coolie’s talent comes in, who heroically produced the Delphi VCL for FFmpeg and the ActiveX OCX Controls for FFmpeg. Problem solved for people who want to make video and audio applications in Windows but daunted by the command-line FFmpeg.

Simply ground-breaking work he has made, Coolie graduated from Tsinghua university, the China counterpart of MIT or Princeton – approximately 100,000 high school students each year compete for just 1 admission to Tsinghua. Think about that.

Feel free to bug him if you are interested in developing a multi-media application yourself – it’s not so hard as it may seem because many contemporary languages and platforms are made to be used by absolute programming beginners, such as VB.NET.

{ Comments on this entry are closed }

google feedburner - free email subscription serviceI’ve been with Aweber for nearly 2 years and they are good. But I eventually decided that newsletter is not my type of thing – there are people who are making big bucks by building and maintaining a high profile email list, but I’m just not one of them. So I left Aweber and switched all my subscription forms to Feedburner email subscription.

It’s actually pretty good. On top of everything, it’s free and A LOT easier to set up. It’s got anti-spam captcha which Aweber lacks – I contacted Aweber support approximately 1 year ago about this feature and up until now, they still haven’t deployed it. The problem with a popular blog is that there are many spam bots waiting to fill every form on the pages. As a result, my list was filled with fake non-human emails which bloated my number of subscribers, thus monthly fees.

It sucks, though Aweber excels in many other regards such as demographic statistics and CTR, etc. If you’ve got a blog and just want to deliver your fresh posts to the inbox of your readers, namely blog subscription, Feedburner is perfect for you. If you want a little more as what an autoresponder does, Feedburner can somewhat help you in this as well, albeit limited in functionality.

Use Feedburner for Email Subscription

Just sign in your Google account and navigate to http://feedburner.google.com and you can start creating your feed right away. In addition to adding a Feedburner custom feed address to your blog, you can also get a email subscription form by “Type your blog or feed address here” and then click “Next”.

It’s all guided and easy to finish. After you have done, go to “Publicize” –> “Email Subscriptions” and click “Activate”, you would then be presented by a HTML code block which is the your blog subscription form that you should put at a prominent place on your blog. Readers can then enter their email addresses to sign up with your newsletter (not newsletter actually, but blog posts notifications). Recommended places to install the email subscription form include: 1) end of the post, 2) top of sidebar, etc.

Use Feedburner as Autoresponder

After you have created your feed at Feedburner, click the feed, and go to “Publicize” –> “Email Subscriptions” –> “Communication Preferences” and there’s a “Confirmation Email Body” that you are free to edit to include any messages or links you would like to show to the subscriber (yet-to-be), such as a thank-you line and the download URL of a ebook you’ve created. After you have made the changes, click “Save” to save them.

Now if anyone subscribes through the Feedburner email subscription form on your blog or website, he or she’d first receive a confirmation message from Feedburner containing things you added just now. It’s exactly like an autoresponder, and it’s free.

{ Comments on this entry are closed }

Review of uCertify Zend PHP-5 Exam PrepKit

by Yang Yang on January 12, 2012

Recently uCertify approached me and asked me to do blogging on about Zend PHP-5 exam PrepKit. Since this is an interesting topic to me and as I would get a free simulator, I agreed. uCertify produces the preparation kits for many different IT Certifications including Microsoft, Oracle, Cisco, CompTIA, Adobe, etc. The uCertify PrepEngine looks like this:

Zend PHP5 Exam PrepKit

Features of the PrepKit:

  • A nice looking user interface with good usability, especially regarding the minor details. For example, it is possible to click the answer itself and not only the checkbox next to it.
  • It has an optional study mode for every kind of test. When enabled it displays the wrong answers immediately rather than evaluating the answers only after the test is over. This provides a harmonic way of learning and measuring one’s progress.
  • It automatically shuffles the order of the answer options thereby preventing me from remembering the position of the correct answer among various options.
  • The explanation to the answers is of good quality and includes chart, diagrams, tables, snippets wherever required.
  • Huge amount of study material are included in the kit! It is not only a simulator but a full preparation kit.

In general it is a nice product that can be helpful for one to prepare for an exam (they have various prepkit available at uCertify). However I do not want anybody to get an impression that I think this is the only resource that one could use to prepare and pass an exam. This product and all other products available out there (books, prep kits, study guides) are just another resource for learning and practicing that one might consider to use when preparing for an exam.

It’s a very nice kit for diversified learners who want to learn things in all different ways. It’s also a breeze to create your own tests and quizzes. Give it a try and you are gonna like it!

{ Comments on this entry are closed }

Premium Magento Theme – Avalanche (Review)

by Yang Yang on December 30, 2011

Avalanche 15% Off Promo: Click here to get 15% discount off, then enter code KAVOIR in the box to claim the 15% discount off the Avalanche theme.

avalanche - premium magento themeAfter digging into Magento for a few months and trying to start my own tangible business (I only deal with digital goods as of now), I failed in finding the perfect theme for my store. What I had in mind was a Magento theme much like Thesis for WordPress, the sort of theme that’s simplistic yet powerful, finely crafted and omnipotent (not just for a specific niche). Seemed most of the themes I could find were a bit too frivolous for me, until I found Jake and his Avalanche, premium Magento theme.

Jake was one of a few Magento experts who are true masters of the eCommerce platform. I first discovered Avalanche with awe and thought, that was it – that was exactly what I wanted. With a few improvements it’d be the perfect theme for my store. I contacted Jake immediately with some of my ideas and he got back to me and greatly appreciated my feedback. He adopted and implemented my suggestions the next day. Those were some great ideas such as a mega / exploded menu option for the top navigation. It used to be 3 options, now there are 4 – it’s all yours to choose from in the Avalanche configuration panel.

I bought the Developer License for $399 that night. It was a remarkable experience. We exchanged quite some emails about how to make the theme better. Not every vendor takes customer suggestions so seriously, let alone a customer-yet-to-be; and it’s not every day you find a developer who so vigorously and wholeheartedly keeps refining his product.

The installation was a breeze. Had some minor problems as I was not quite experienced with Magento yet and emailed Jake for help and he got back to me within 1 hour. Every time. That’s the kind of support lacking in the official Magento Go team.

The Avalanche theme has lots of backend options that you can tweak to customize the look and general texts of your store. Cloud Zoom in place. Breadcrumbs are enhanced. Colors, typography, banners, featured products, AJAX quick views, cutting edge CSS3 features and many more.

As of now, I’m very much impressed in all regards, though I’d say it’s more of a theme for digital niches such as technology and electric products. The black and white theme may not suit every customer base (may not yield the best conversion rates in some niches). You need to tweak them a bit, unless Jake can come up with an overall color themes switcher in future updates. For now, we are stuck with color switchers just for borders, links, and action buttons – they are actually pretty nice with gradients, you should try it!

There could be more improvements and I’m sure Jake’s already started working on the next version. By far, I think he’s making the best premium Magento themes.

My 4.9/5 for Avalanche Magento theme.

Avalanche 15% Off Promo: Click here to get 15% discount off, then enter code KAVOIR in the box to claim the 15% discount off the Avalanche theme.

{ Comments on this entry are closed }

PHP: Get Mime Type of a File (and Encoding)

by Yang Yang on December 25, 2011

While you can somewhat rely on the name extension of a file to determine the mime type, it may not always be accurate. For example, .jpg and .jpeg files are very probably image/jpeg files and .png files are very probably image/png files, but there’s always an exception because file extensions can be faked. To accurately find the mime type of a specific file in PHP, you should use the Fileinfo extension.

Find out if the extension is enabled with the code outlined in the beginning part of the resize image in PHP post.

With the php_fileinfo extension enabled in php.ini, this is the function I come up with:

$finfo = new finfo(FILEINFO_MIME); // return mime type
if ($finfo) {
	$file_name = "/absolute/path/to/some.jpg"; /* Must use absolute path */
	$file_info = $finfo->file($file_name);
	$mime_type = substr($file_info, 0, strpos($file_info, ';'));
	echo $mime_type;
}

Which will get you this:

image/jpeg

The reason it gets complicated in the echo line is that the standard output of FILEINFO_MIME information output by the file() function of the $finfo object is something like this:

image/jpeg; charset=binary

Therefore, you have to literally get everything before the semi-colon to get the mime type information.

If it was a CSS file, the output of the $finfo->file() method would be like this:

text/plain; charset=utf-8

Cool, huh! Winking smile

{ Comments on this entry are closed }

Redirect 404 Error to Home Page

by Yang Yang on December 25, 2011

Other than making your 404 error page user friendly, you can redirect it to your index pages such as the homepage, sitemap, or search page, to make it useful for the users. Instead of relying on them to correct the error themselves, you offer the new orientation.

How to redirect a 404 error page to the home page?

There are essentially 3 ways to do this depending on the technology your site is built on.

The .htaccess and HTML solution

This works across all sites that are served by the Apache web server with .htaccess enabled. Add this line in the .htaccess file in the root directory of your domain:

ErrorDocument 404 /404.html

And in 404.html, add a meta tag in the HTML head section:

<meta http-equiv="Refresh" content="1; URL=http://www.example.com/">

So when there’s an 404 Not Found error the user would be first redirected to /404.html and in turn, he or she would be redirected to the homepage http://www.example.com/ (or whatever you change it to) by the meta Refresh actions.

The PHP solution

If you are using PHP to code your site, chances are you know this solution. You can always use the previous solution (The .htaccess and HTML solution) to redirect 404 error page to your home page on a PHP site, but you can also try the pure PHP approach instead.

Whenever a user types in a URL request that you do not recognize, render this:

header("HTTP/1.1 404 Not Found");
header("Location: /");
exit();

Which would redirect the user who has hit a 404 error to the homepage / or any other page URL you specify there.

The WordPress solution

If you are using WordPress for your site, make a 404.php file in your theme directory with the following content:

<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".get_bloginfo('url'));
exit();

WordPress would automatically use 404.php as the default 404 Not Found error page and when a user hits that page, he or she would then be taken to the home page your WordPress blog.

{ Comments on this entry are closed }