Beginner’s Guide to OpenX Ad Server
I got an email from Packt Publishing to review a book that they will be releasing very soon (March 2010?). The book is about OpenX.
In all honesty, I have not even tried to use OpenX Ad Server yet. Still, I am interested in this book because I also serve ads on this blog; too bad though that the ads on the sides are not enough to pay for the hosting :P
I will have another update for this book once I have read it. I got a free ebook so I will have something to read on my 14-hour flight back home. :D
Here is the book in detail:
- Learn the essentials of online advertising from the advertiser and publisher points of view
- Install and utilize OpenX Ad Server effectively to make your business run faster
- Get to know the usage of all the campaign and banner types
- Manage ad campaigns and banners on multiple web sites from a centralized platform
- Display ads according to their importance and alter the under-performing ads easily and swiftly
- Learn the most effective way to work with web site ad zones
- Maximize your profits by selling your ad space on your blogs and web sites effectively
- Take full advantage of GeoTargeting for generating maximum revenue by showing ads according to visitor origin
- Utilize the channels to show relevant ads based on the content of web sites
- Integrate Google AdSense and Amazon ads with your web sites using OpenX
- Convert OpenX Ad Server into a multi-user ad management platform for advertisers, publishers, and ad agencies
- Track the success of any ad campaign, banner or web site zone using detailed statistics, and reports
WordPress: How to create a breadcrumb without using any plugins
A quick post for WordPress users.
Go to your functions.php file. If it doesn’t exist, then create it.
wp-content/themes/theme_name/functions.php
Then add this inside the functions.php file.
function the_breadcrumb($post_ancestors) { if (!is_home()) { echo '<a href="'; echo get_option('home'); echo '">'; echo 'Home'; echo "</a> > "; if (is_category() || is_single()) { the_category('title_li='); if (is_single()) { echo " > "; the_title(); } } elseif (is_page()) { foreach($post_ancestors AS $value) { echo "<a href='".get_permalink($value)."'>".get_the_title($value)."</a> > "; } echo the_title(); } } }
Then in your wp-content/themes/theme_name/index.php or anywhere in your template files, you can do this:
<?php global $post; ?> <div class="breadcrumbs"><?php the_breadcrumb(get_post_ancestors($post)); ?></div>
That should display something like this:
Home > A Sample Page > Sub for the Sample Page
* Most of the source code is from here Catswhocode.com. I edited it so that you can get the “parents” for the pages. Thanks to for the kick-start!
A CSV File and SQL Dump for all the zip codes in Philippines
I spent a few hours yesterday gathering all the zip codes for the Philippines. This is public data, so I am sharing it with everyone. If you use it, I’d appreciate it if you credit me (It is not required but it would be great if you can send some traffic to my site — I have been planning to get a Linode but I can’t afford one yet :P).
Here is a preview of the CSV file:
"id","country","major_area","zip_code","city" "1","PH","Abra","2800","Bangued" "2","PH","Abra","2801","Dolores" "3","PH","Abra","2802","Lagangilang" "4","PH","Abra","2803","Tayum" "5","PH","Abra","2804","Peñarrubia" "6","PH","Abra","2805","Bucay" "7","PH","Abra","2806","Pidigan" "8","PH","Abra","2807","Langiden" "9","PH","Abra","2808","San Quintin" "10","PH","Abra","2809","San Isidro" "11","PH","Abra","2810","Manabo" "12","PH","Abra","2811","Villaviciosa" "13","PH","Abra","2812","Pilar" "14","PH","Abra","2813","Luba" ... ... ... "462","PH","Cebu","6000","Cebu City" "463","PH","Cebu","6003","Compostela" "464","PH","Cebu","6001","Consolacion" "465","PH","Cebu","6017","Cordova" "466","PH","Cebu","6013","Daanbantayan" "467","PH","Cebu","6022","Dalaguete" "468","PH","Cebu","6004","Danao City" "469","PH","Cebu","6035","Dumanjug" "470","PH","Cebu","6028","Ginatilan" "471","PH","Cebu","6015","Lapu-Lapu City (Opon)" "472","PH","Cebu","6002","Liloan" "473","PH","Cebu","6016","Mactan Airport"
The MySQL Table is like this:
CREATE TABLE IF NOT EXISTS `zipcodes` ( `id` int(11) NOT NULL AUTO_INCREMENT, `country` char(2) NOT NULL, `major_area` varchar(300) NOT NULL, `zip_code` varchar(25) NOT NULL, `city` varchar(300) NOT NULL, PRIMARY KEY (`id`), KEY `major_area` (`major_area`), KEY `zip_code` (`zip_code`), KEY `city` (`city`) ) ENGINE=MyISAM
Updated: March 13, 2010 (2,270 zip codes)
Download the files below:
Corrections, suggestions, etc. just leave a comment below.
Enjoy!
CSS: Creating a horizontal menu/navigation bar
I always forget how to do this. Every time I forget, it takes me about 10minutes searching for the right one. So I am posting it here for my reference.
My HTML would look something like this:
<div id="navbar">
<ul>
<li class="first"><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Projects</a></li>
<li class="last"><a href="#">Contact</a></li>
</ul>
</div>And my CSS would look something like this:
#navbar { background-color: #d90000; } #navbar ul { margin: 0; padding: 0; float: left; } #navbar ul li { display: inline; list-style-type: none; padding-right: 20px; } #navbar ul li a{ float: left; text-decoration: none; color: white; padding: 10.5px 11px; } #navbar ul li a:visited { color: white; } #navbar ul li a:hover, #navbar ul li .current{ color: #fff; background-color:#bf0000; } #navbar .first { /*You can put stuff here for the first item in the navbar*/ } #navbar .last { /*You can put stuff here for the last item in the navbar*/ }
Comments or suggestions please ;-)
Zend Framework: How to use nested transactions with Zend_Db and MySQL
Steve Hollis first blog post about practical nested database transactions using Zend_Db. He writes really well and his blog is very readable. I love reading long text in Serif :D Thanks Steve!
His solution:
The Solution
Disclaimer: This solution is adapted from the extended Pdo_MySql adapter in Varien’s Magento e-commerce product. A similar approach is adopted by Bryce Lohr’s Nested Table Support for Zend_Db proposal. You should read Bill Karwin’s comments about that proposal and understand the limitations of this method before implementing it. That said, I still believe this is a useful and practical way of simulating nested transactions and I have used it a number of times.A simple solution to the problem is to keep track of the “depth” of the transaction, that is, how many times the beginTransaction() method has been called. That way, we can hold off committing the changes to the database until we are certain that all the save operations have completed successfully.
Since transactions apply to the whole database connection, the most logical place to manage this process is in the DB adapter class. To do this, we extend our adapter class like so:
App_Zend_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli { /** * Current Transaction Level * * @var int */ protected $_transactionLevel = 0; /** * Begin new DB transaction for connection * * @return App_Zend_Db_Adapter_Mysqli */ public function beginTransaction() { if ( $this->_transactionLevel === 0 ) { parent::beginTransaction(); } $this->_transactionLevel++; return $this; } /** * Commit DB transaction * * @return App_Zend_Db_Adapter_Mysqli */ public function commit() { if ( $this->_transactionLevel === 1 ) { parent::commit(); } $this->_transactionLevel--; return $this; } /** * Rollback DB transaction * * @return App_Zend_Db_Adapter_Mysqli */ public function rollback() { if ( $this->_transactionLevel === 1 ) { parent::rollback(); } $this->_transactionLevel--; return $this; } /** * Get adapter transaction level state. Return 0 if all transactions are complete * * @return int */ public function getTransactionLevel() { return $this->_transactionLevel; } }
Update your bootstrap to use the extended class et voila – a single START TRANSACTION and COMMIT or ROLLBACK is sent to MySQL, regardless of how many levels of nested pseudo-transactions have been created.
Please Note:
- It’s important that each child save() method re-throws the exception so that transaction depth is reduced by successive calls to rollBack(). The end result is that the originally called save() method then performs the actual rollback.
- All the tables used in the transaction must use a storage engine that supports transactions. For MySQL, this will most likely mean using InnoDB. To convert a MyISAM or other table type to InnoDB, use “ALTER TABLE table ENGINE = InnoDB”. It could take some time to rebuild the indexes on large tables. There are other considerations about the use of InnoDB – please consult the MySQL manual.
- If the tables used don’t support transactions, it’ll just fail silently. Bad times. I highly recommend using Firebug and Zend_Db_Profiler to monitor database queries during development (see http://framework.zend.com/manual/en/zend.db.profiler.html);
And of course, the source can be found here: http://www.stevehollis.com/2010/03/practical-nested-transactions-with-zend_db-and-mysql/

