Start Services Using a Batch File

If you use your person computer as a testing server you probably have several services running in the background (a web server, database, caching service, etc). Individually these services tend to have a small footprint. If you’re running enough of them however, they can start to impact your machine’s performance. If you have them set to auto start they can also increase your startup time. Ideally you would want to start them when you need them and stop them when you’re done with them, but that can be a hassle for multiple services. A simple solution is to create a batch file to start all of your services, and another one to stop them.

Follow these steps to create your batch file:
Continue reading

Google is translating my code!

Recently I added the ‘Google Translate’ widget to my sidebar. After some testing I noticed something problematic: All of the code snippets in my posts were also being translated. Unfortunately the PHP interpreter does not speak Spanish (it’s not that kind of interpreter apparently). Fortunately there is a simple solution. The content of any HTML element with the class ‘notranslate’ will not be translated; all you have to do is add the class ‘notranslate’ to the element containing your code.

If you’re using a plugin to format and display your code this may not be so simple. Currently I’m using SyntaxHighlighter Evolved which has a convenient field in the settings page for adding addition classes to the ‘pre’ element used to display code. If this isn’t the case for you you’ll have to do some digging in the plugin code. Alternatively you could use javascript to add the class to a particular element. This way you won’t have to make any modifications to core plugin files, which will be overwritten if you decide to update.

Here is a 100% untested example (using jQuery):

$("pre").addClass("notranslate");

The above code should prevent any content within a ‘pre’ element from being translated by Google.

Opera 11 Beta

Opera 11 Beta is out ( http://www.opera.com/browser/next/ ).

There are a lot of new features and improvements, but one in particular has blown my mind. Tabs are now stackable! Within minutes I became so dependent upon this feature that I’ve migrated completely to the new version in spite of it still being in beta.

In addition to this Opera now supports extensions. Technically Opera has supported extensions for a long time through userJS, but the new system seems to be a big improvement. I’m definitely considering creating a Tab Override extension for Opera.

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. To 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.