Archive for the ‘Software’ Category.

Apparatus 0.4

A new version of Apparatus is available. Previously I wrote about several new features that would be included in this version, however rather than further postpone a release, I’ve decided to hold off on those features until the next version. Version 0.4 incorporates a new theme, the latest version of tab override (which should resolve any browser compatibility issues), and various improvements and modifications.

Easy PHP Search with Opera

If you use Opera you’re probably aware that it supports shortcuts in the address bar that allow you to run a search on various search engines and websites. For example, if I type g tinsology in the address bar, you’ll get the Google search results for the keyword tinsology. You can do similar things with yahoo, amazon, ask and other sites that come preconfigured in Opera.

Personally, I find myself frequently using this shortcut to Google PHP documentation. For example if I’m looking up documentation for the implode function, I’ll type g PHP implode. More often than not the first result is what I’m looking for and it is just a matter of waiting for the search results to load, clicking the first result, and waiting for the php.net page to load.

Ideally, however, I would want to be able to go directly from typing my search in the address bar to the php.net results page. It just so happens that Opera allows you to do this by adding a custom search engine. What we want to do is to be able to type p [my search] in the address bar. To begin we need to open the Search Preferences pane:

  • In Opera click Tools -> Preferences... or press Ctrl+F12
  • In the resulting window select the Search tab.
  • Click the Add... button.

In the add window there are three fields we are interested in: Name, Keyword, and Address (if you don’t see the address field click the details button). Name is just the name of this search shortcut; I named it PHP, but it doesn’t really matter what you name it. Keyword is the keyword you type in the address bar before your search query. For a Google search it is g. I chose p, but once again you can choose anything you’d like. Also, the keyword doesn’t have to be a single letter, for instance you could use php. The address field tells Opera what to do with your search query. Without explaining too much I’ll just say that the value we want to use is: http://us2.php.net/manual-lookup.php?pattern=%s. The %s token will be replaced by our search query. For instance typing p implode will cause Opera to open http://us2.php.net/manual-lookup.php?pattern=implode

That’s it; leave all of the remaining field blank. You can now use Opera’s address bar to instantly search the PHP documentation. You can use similar methods for running searches on other sites, the hardest part is finding the correct search URL (its even harder if the search query cannot be URL encoded, that’s when the Use Post option comes in handy).

Opera: A developer’s browser

My previous entry will suggest to the reader (and by suggest I mean scream aloud) that I am not fond of IE. In addition to this I mention that I use Opera as my primary browser. Typically for windows users, if you are not using IE you are using Firefox. Opera is a less popular browser, but I think much more useful for developers.

Out of the box Opera has several features that have made my life easier many times. One of them is fairly simple: if you want to validate a page, all you have to do is right click and click validate.

Another feature allows you to dynamically update the source code of a site. All of the popular browser allow you to view a page’s source, but Opera allows you to view that source, edit it, and have the changes applied to the currently open page. This if very useful for making adjustments to a layout, or on occasion, making a broke page work. For example, I was trying to register on a site using a captcha. Normally this isn’t a problem, but in this case the text field only allowed 4 characters, while the image contained 5. All I had to do to work around this was view the source, and change the size attribute to 5. This is the only case I can think of off the top of my head, but there are others.

This is just the tip of the iceberg. Opera’s developer console lets you view the DOM structure of a site and view cookies. If a site is hard coded to only work in IE or firefox, Opera can identify itself as either of those. If you want to open a page in another browser all you need to do right click select open with and choose any installed browser. The list keeps going.

If you haven’t given Opera a try you should definetly do so.

Internet Explorer No Longer Essential

I haven’t used IE as my primary browser for a long time. I switched from IE to Opera several years ago. Until recently, however, I’ve always had Internet Explorer installed. This is because there always seemed to be some website that either insisted on users using IE, or was coded in such a way that it only worked in IE. It seems counter-intuitive to me that the browser that is the least standards complient should be the one that everyone codes there website to work with, even at the expense of all of the other browsers, but that was the reality of the industry for a long time. Only now do I believe that that era is almost over; it is now possible to uninstall IE permanently.

The actually came to this conclusion by accident. A few months ago, my cable provider forced me to reactivate my Internet connection. This was altogether a very clumsy and inconvenient process. It consisted of me entering some personal information along with an account number and then waiting for their system to recognize my modem. Not only did this take an incredibly large amount of time, but I also had to complete the entire process in IE6. When I say IE6 I really mean IE6… their software downgraded IE7 without asking. Around an hour an a half later when the process was complete I found that this extremely (really I can’t stress this enough… Cox Communications I hope you read this) poorly written software had crippled IE. It crashed the moment I opened it.

Not wanting to deal with the additional stress of fixing this problem, having just spent a considerable amount of time dealing with my cable company, I happily went about my business, using Opera as my primary browser as always. A few days ago I clicked the IE icon by mistake and was reminded that it was still crippled. After a few months I had not yet needed to open IE even once. This came as a surprise to me as in the past I had occasionally needed to use IE to do things like accessing my bank account and watching certain videos.

So what is the blame for this development. Part of it, I think, is that developers have been (finally) focusing more on cross-browser support. Another part is the browsers themselves; Opera has a feature to identify itself as other browsers, which i nice for circumventing sites that are hardcoded to only allow FireFox or IE. Regardless of what is responsible, I think this is a step in the right direction.

Understanding the 64-bit Movement

A few years ago AMD released the Athlon 64 processor. Though this processor was not the first 64-bit processor, it was the first aimed toward general consumers. Chances are, if your computer was manufactured in the last few years, you have a 64-bit compatible processor. You may be wondering what the difference is and what this means to you. If you’ve looked into the issue in the past, you’ve probably determined that the most significant differences is that in order to have more than 4GB of RAM, you need a 64-bit processor. The reasons for this and its implications may not be so clear, so I’ll do my best to clear things up.

32-bit Vs. 64-bit

Even if you are aware of what it means to have a 64-bit processor, you may not understand what makes a 64-bit processor 64-bit. Do fully understand this you need to understand the inner workings of a processor. A comprehensive explanation of this is beyond the scope of this article, and most likely beyond my ability to explain. I can, however, point out the basics.

As you are probably aware, computers have multiple levels of memory. Most people are aware of the two largest (in terms of storage) types of memory: hard disk and RAM. You may also be aware of a third type Cache. There is, however, a fourth level; Registers. The size and access time of these different types of memory decrease in the order I mentioned them. A hard disk can typically hold many gigabytes of data, RAM can hold a few gigabytes, cache can hold a few megabytes, and registers and hold only a few bytes. In the context of the difference between 64-bit and 32-bit systems, the level of memory we are most interested in are the registers.

Your processor has several registers. These registers hold only a small amount of data. This is where the difference between a 64-bit processor and a 32-bit processors comes into play. On a 32-bit machine, a register can hold 4 bytes of data. A byte consists of 8-bits, 4 bytes is therefore equal to 32-bits. As you might have guessed already, a register on a 64-bit processor can hold 8 bytes of data, which translates to 64-bits. This is the only necessary physical difference between a 32-bit and 62-bit system.

Memory

So what are the implications of this? As I mentioned earlier, the maximum amount of RAM you can have on a 32-bit system is 4 gigabytes. To understand why this is you need to further understand how data is stored, and how the processor accesses that data.

Your processor cannot read data directly from the hard disk, RAM, or cache. All of the data must flow down into the registers before the processor can do anything with it. This puts certain limitations on your data. All data in your machine is represented in binary, a bit is one binary digit. So if a register can hold 32 bits of data, it can hold a binary number 32 digits long. 32 digits might seem like an incomprehensibly large number, and if it were in decimal it would be, but in binary the largest number that can be represented with 32 digits is around 4 billion (2 to the 32nd power minus 1).

As I mentioned before, the processor does not work directly on data in RAM. In order for your processor to read this data it must first bring it into a register. So how does the machine know how to find this data? It has an address. Every byte in your RAM has a numeric address. In order for the process to fetch data from this address, the address must be stored in a register. As I mentioned before the largest value that can be stored in a 32-bit register is around 4 billion. Since every byte in RAM has an address, there is an upper limit of around 4 billion on the number of bytes that can be stored. There are roughly a billion bytes in a gigabyte, so in a 32-bit system the maximum amount of memory you can have is 4 gigabytes.

By now you probably understand why you need a 64-bit machine to have more than 4 gigabytes of memory. In a 64-bit machine you can have 2 to the 64th power number of memory addresses (as opposed to 2 to the 32nd bytes which equals 4 gigabytes). If you’re good at math you’ve probably figured out that this is equal to 2 to the 3nd squared, or roughly 4 billion squared. 16 billion billion bytes in computer terms is 16 exabytes. To understand how much data that is, consider your own computer. If you have 4 gigabytes of memory in your computer, you would need 4 billion of them to store that much data. Currently there aren’t even 4 billion personal computers in existence, and not all that do exist have 4 gigabytes of memory.

Other Implications

Memory addresses obviously aren’t the only things stored in registers. If you are a programmer most likely you know that the largest unsigned integer is around 4 billion. This is because an int is stored in 32-bits of memory. This fact might not change as a result of a move to 64-bit systems; there might not be a practical reason for increasing the size of an int. Other data types, such as float, require more than 32-bits of data. Moving to a 64-bit system means an entire float can be placed in a register.

Not everything about moving to 64-bit is good, however. In order to enjoy the benefits of a 64-bit system, you need a 64-bit operating system. The programs you are running also need to be 64-bit compatible. If you are a programmer you might be relieved to hear that in most cases porting a program to 64-bit is a matter of compiling your existing code with a 64-bit compiler. Its not always quite as simple as that, however, and identical code compiled on different compilers may experience different issues.

In addition to this doubling the size of memory addresses means that twice the data is now moving down the pipe to and from registers. This factor also involves the operating system. Most 64-bit processors are 32-bit backward compatible, meaning that you can install a 32-bit operating system on it and not notice the difference. You will notice the difference, however, by installing a 64-bit operating system on a low end machine. I experienced this first hand by installing XP 64-bit on an AMD Turion machine from 2006. Though the Turion machine was a 64-bit, it didn’t handle the impact of a 64-bit operating system on memory bandwidth.

Should I migrate to 64-bit?

Virtually any personal computer you buy today supports 64-bit. Does that mean you should go out and buy a 64-bit operating system? Not necessarily. There is no real benefit to using a 64-bit operating system unless you need a machine with more memory. Eventually the standard amount of memory on a mid-grade machine will surpass 4 gigabytes and in fact that day is coming soon. Unless you desperately need to upgrade your current machine, you may want to wait until you purchase your next machine to consider going 64-bit. With Windows 7 around the corner, the time to buy a new system might be coming close. If your current system or the one you are considering purchasing is a low-end machine you may want to stick with 32-bit. Just as the transition from 16-bit to 32-bit was, the transition from 32 to 64 is inevitable. If you are a person who likes to buy one machine and upgrade it over the years then 64-bit is the way to go. If you periodically purchase a new machine there is no real advantage to 64-bit unless you want more memory.

Kontera for a Month

Roughly a month ago I started serving Kontera, in-text, ads. Based on a month of use here are my impressions of the platform:

Ad Relevance

I found that the ads were relevant only to the term selected for the link, meaning that the ad served was based on the word or phrase in the link. This being the case, often times the ads were irrelevant to the overall content. For example, if I wrote a post about login systems, or otherwise mentioned login systems. the word system could be selected as a link to an ad about air conditioning systems.

Revenue Generated

Before I go into detail, let me mention that I do not generate a lot of ad revenue, nor do I expect to. If I break even on the domain costs and hosting fees I’m happy.

I did generate some revenue, and I imagine on a site with more traffic that revenue could easily be significant. What money I did make, however, was far less than was I make on my AdSense ads. I also found that in spite of the fact that the kontera ads are in-text and the Google ads are outside of the main text, the AdSense ads received more clicks. If I had to guess as to why this is, I would say it is because visitors to this site are well aware of what those ads are and for the most part arn’t interested. I imagine the relevance of the ads that I discussed above also plays a factor in this.

Intrusiveness and Conclusion

I personally don’t find in-text ads to be overly intrusive. After some thought, however, I decided that having users mistakenly click what they think to be relevant links and instead be served an ad is not worth the amount of revenue generated. I found that the ‘traditional’ banner ads were more effective and relevant.

The Artificial Nature of Website Value Estimators

It is common knowledge that web site value estimators are horribly inaccurate. If you don’t intend to use their results to market your website however, it is still fun to see what value they assign to your site. Most likely we’ve all taken one of these estimators for a test drive. Today I did just that, using this domain and I discovered that this site is worth 1,714 USD. I highly doubt, however, that I can go and find someone willing to pay that much for this site, not that I would do such a thing, nor am I claiming that this site doesn’t have worth.

One reason I doubt this is for the simple fact that this site was designed by me, its full of my writing, and every aspect of it is designed to suit my purpose. Even the domain name is derived from my last name. There is another reason, however. Two days ago, using the same estimator and the same domain it spit out a much different number: 78. Did my website suddenly explode over the last two days? The answer is yes and no. A short time after I used the estimator I released two wordpress plugins back to back. This resulted in a large spike in traffic. This spike, however, will wear off in a few days. Though I will likely see an increased level of traffic from what it was before this happened, it won’t be as high as it was on release day.

So what does this mean? The estimator most likely picked up on the elevated amount of traffic over the last few days and judged the value of this site based on that (and other factors of course). Never mind that maybe only a dozen people will read this article, and never mind that only two days ago the estimate was two orders of magnitude lower, I can now turn around and sell this site for a thousand bucks.

Before you get too excited about the value one of these things assigns to your website you should remember that they employee a discrete algorithm. This algorithm obviously cannot determine the value of the content of your website. In the real world, the content of your website plays a much larger role in determining its value. While it is important to take other factors into account, leaving out the content factor makes any estimate worthless.

Seamless WordPress bbPress Integration

If you’ve ever installed bbPress you know that it supports several different levels of integration with an existing WordPress blog. By default you can integrate cookies, users, and even have access to WordPress functions. After all of this, however, the user will still experience two independent applications. Most likely the themes you are using were not made with each other in mind. This doesn’t have to be the case, and if you’re willing to get your hands dirty you can get your bbPress installation to look and feel as if it is entirely a part of WordPress. Here is an example of what this looks like: Example.

To begin, you will need to install (or modify) bbPress with full WordPress integration. This means cookie, database, and functional integration (add require_once(‘path/to/wp-blog-header.php’); to your bb-config.php for functional integration). I did this with WordPress 2.7.1 and bbPress 1.0 alpha, however, if you prefer to use the stable version of bbPress, you can find information on how to do this Here.

Once everything is installed its time to get your hands dirty. To go further we’re going to have to make a few changes to the code. Locate your theme directory. I used the default Kakumei theme. Keep in mind that a large portion of your bbPress theme is going to be stripped out (header, footer, sidebar) so don’t spend to much time selecting a theme. After you locate the directory of your current theme, you’ll need to do a search and replace through every .php file in your theme. There are several files so I suggest you use a program to do this for you; Notepad++ allows you to search and replace across multiple files.

You’ll need to do two searches:

Find:

bb_get_header();

Replace with:

global $is_bb; $is_bb = true; get_header();

get_header(); will cause bbPress to use WordPress’ header as opposed to its own. I added the additional code global $is_bb; $is_bb = true; you’ll see why later. You’ll need to do the same thing for the footer as well.

Find:

bb_get_footer();

Replace with:

get_footer();

Now that that’s done, upload the files and take a look at your forum. You should see the body of your forum embedded inside your wordpress theme. You should also notice that your forum looks pretty terrible. Don’t worry we’ll fix this in the next step.

What we need to do next is tell your wordpress theme to use your bbPress stylesheet if we are viewing the forum. This is where that additional code I added comes in. In your WordPress theme’s header file add the following lines before the first stylesheet is linked (ie before the first <link rel=”stylesheet”…):

<?php global $is_bb; if($is_bb) : ?>
	<link rel="stylesheet" href="[path to bbPress theme stylesheet]" type="text/css" media="screen" />
	//add additional stylesheets if needed
<?php endif; ?>

Make sure to replace [path to bbPress theme stylesheet] with the path to your current bbPress theme’s stylesheet.

If you look at your forum now, you’ll probably see a terrible mess. This is because your WordPress style sheets and your bbPress style sheets conflict. If you didn’t use the default theme you’re on your own for altering your bbPress stylesheet. Make sure you remove any elements that are directly conflicting with those in your WordPress theme (ie header, sidebar, footer elements). You’ll also want to look out for any position, and float attributes. You may also need to remove the width attribute for your forum body.

If you did use the default theme or the blue version of the default theme, you can use the stylesheets that I’ve already altered. I don’t promise that they are bug free, but they’re working well for me so far.

Kakumei
Kakumei Blue

Make sure to rename them to style.css.

Now that you’ve altered your stylesheet, everything should look good. You arn’t done yet, however. Most likely all of your bbPress navigation (ie login, admin panel, logout) buttons are gone. If you correctly integrated WordPress cookies login and logout shouldn’t be a problem. To replace any links that were lost, code them directly into your WordPress theme, using the $is_bb variable to only display them on the forum.

Good Luck!

Update:

There is an issue with slashes being added to edited posts in bbpress. I think this is being caused by both wordpress and bbpress escaping content and then only bbpress unescaping it. In any case this is how I fixed it (its a bit of a hack) in bbpress 1.0.2:

  • You’ll need to edit the file bb-includes/functions.bb-template.php (I think in earlier versions its called template-functions.php).
  • Locate the function definition get_post_text. In bbpress 1.0.2 it looks like this:
    function get_post_text( $post_id = 0 ) {
    	$bb_post = bb_get_post( get_post_id( $post_id ) );
    	return apply_filters( 'get_post_text', $bb_post->post_text, $bb_post->post_id );
    }
    
  • Change it to:
    function get_post_text( $post_id = 0 ) {
    	$bb_post = bb_get_post( get_post_id( $post_id ) );
    	return stripslashes(apply_filters( 'get_post_text', $bb_post->post_text, $bb_post->post_id ));
    }
    

I’ve also heard of an alternative solution. All you need to do is comment out the following line in wp-settings.php:

$_POST   = add_magic_quotes($_POST  );

In wordpress 2.9.2 it is on line 632. I personally have not tried this solution and I'm a little weary of it; it might have some unexpected side effects (namely POST data not being escaped, possibly exposing you to SQL injections).

If anyone has a solution that does not involve editing core files I would be very interested in hearing about it.

Feedback

After the release of SimpleMail I immediately experienced a problem that I imagine is shared by many developers: lack of feedback. Though I greatly appreciate all of the comments, suggestions, and bug reports (especially the bug reports) I know that for every one person that experienced a problem and reported it, five people experienced a problem, uninstalled the plugin and never thought about it again.

I found myself constantly worried about the bug reports I was not receiving, and in fact there were bugs that had existed since the original version that went unreported until recently. This was a learning experience of course and I have since taken steps to ensure that any application I release in the future is more robust. In addition to this I think that having experienced all of this I am must more likely to report issues I am having with any piece of software. I strongly encourage anyone reading this to do the same.

As I mentioned this was a learning experience, so I’ll offer some tips to developers so they don’t make the same mistakes I did:

  • Test your applications in multiple environments
  • Maintain portability in your code
    • Read the documentation for whatever feature, function or library you are using to ensure that it will work on whatever platform you expect it to
    • Don’t use language features that are not necessarily enabled or available to all users (ie PHP short tags)
  • Make providing feedback easy
    • Add a link, button, or form to your application that either directs the user somewhere where they can provide feedback or allows them to send feedback from the application itself

WordPress Plugins: Using Subversion

This article is meant to supplement WordPress’ Using Subversion Guide. Whenever I mention the guide I am referring to this.

So you’ve written a WordPress plugin and its now time to upload it to the WordPress plugin repository. Your first step will be requesting that your plugin be hosted on WordPress’ Plugin Directory. Sometime later your request will be accepted (provided it doesn’t drop all of the tables in the database or something like that) and you’ll be given access to the Subversion Repository.

If this is your first time making a WordPress plugin you might have no clue what subversion is, much less how to use it. WordPress provides some good Documentation on this subject, but I think there are a few things they left out that could be useful to someone using doing this for the first time.

Reading through WordPress’ Using Subversion guide will probably give you a pretty good idea of what subversion is, but by the time they get to actually using subversion you might be a little lost. I’ll pick up at the point I think it begins to get a little fuzzy:

Task 1: Starting from scratch with your brand new plugin repository

This section begins with a short overview of what you will be doing:

  1. Check out the blank repository.
  2. Add your files to the trunk/ directory of your local copy of the repository.
  3. Check in those files back to the central repository.

Then they toss a blob of text at you.

# Create a local directory on your machine to house
# a copy of the repository.

$ mkdir my-local-dir

# Check out the repository

$ svn co http://svn.wp-plugins.org/your-plugin-name my-local-dir
> A	my-local-dir/trunk
> A	my-local-dir/branches
> A	my-local-dir/tags
> Checked out revision 11325.

# As you can see, subversion has added ( "A" for "add" )
# all of the directories from the central repository to
# your local copy.

# Copy the plugin files to the local copy.
# Put everything in the trunk/ directory for now.

$ cd my-local-dir/
my-local-dir/$ cp ~/my-plugin.php trunk/my-plugin.php
my-local-dir/$ cp ~/readme.txt trunk/readme.txt

# Let subversion know you want to add those new files
# back into the central repository.

my-local-dir/$ svn add trunk/*
> A	trunk/my-plugin.php
> A	trunk/readme.txt

# Now check in the changes back to the central repository.
# Give a message to the check in.

my-local-dir/$ svn ci -m 'Adding first version of my plugin'
> Adding	trunk/my-plugin.php
> Adding	trunk/readme.txt
> Transmitting file data .
> Committed revision 11326.

# All done!

There are a few things you should know about the commands above. To begin, these commands should be entered on a unix shell. If you are familiar with unix you already know that text following the # symbol are comments and the text following the > symbol are the shell’s response to the commands. The commands themselves are not preceded by any symbol.

Another thing you should know is that the writers assume that you already have subversion (svn) installed. If you don’t like the idea of using a command line to access and modify the repository, there are a lot of GUI programs out there. You can find a listing of third party clients on the Subversion Website From this point on, however, I (and the writers of the guide I am referring to) will assume you have access to a unix command line with subversion installed.

If you are a windows user and don’t have access to a unix shell, I suggest using cygwin. SVN is part of the cygwin package, but you must explicitly specify that it be downloaded and installed. Read the cygwin documentation for more information. To test whether or not SVN is installed, type svn help in the shell.

Now that you have access to UNIX with SVN installed you should have no trouble running the commands in the guide.

Task 2: Editing a file that is already in the repository

Once you’ve uploaded your initial version, you will almost certainly need to make changes to those files sometime in the future. The guide is pretty clear on how to do this, so I will just provide a brief summary of the commands you will use for this.

svn stat shows you a list of files that differ from those in the repository.

svn ci -m "my message" updates the files in the repository with your local copies. It does not automatically add new files or remove old files. If you have added a new file that did not exist before you will have to use the svn add command to manually add this file. Likewise you will have to remove a file manually with the svn remove command. Documentation on any command can be obtained by using the svn help [command] command, where [command] is replaced by whatever command (ie add, remove, stat) you need documentation on.

Notice that the first command issued before updating any files is cd my-local-dir. It is very important that you are in you plugin directory when using any of these commands.

Task 3: “Tagging” a new version

Tagging refers to assigning a version to your plugin. Whenever you create a new version of your plugin you will need to tag that version. As the guide mentions, you do this by using the svn cp. It is important that you use the svn cp and not the normal cp command to do this. svn cp just doesn’t copy the files, it also adds the files as you would using the add command.

It is important to note that the command svn cp trunk tags/0.1 assumes that the folder 0.1 does not exist in the tags folder. You won’t get the desired result if it already exists.

As the guide mentions, it is important that the readme.txt file in your trunk folder is updated with the proper stable tag BEFORE copying the files.

Some Important Notes

Do not add, remove, move, or copy files with the normal commands (or through a GUI). To do these things you must use the svn [command] (ie svn add, svn move).

Stick to one application for managing your repository. It is not a good idea to use one program to add and remove files and then another to attempt to update the repository.

You can use whatever editor you want to modify your files. The example in the guide is nano trunk/my-plugin.php, but you don’t have to do everything from command line. Personally I use notepad++ to make changes to my files, just refrain from doing anything other than editing from your GUI or third party app.