Archive for April, 2008

Universal www-Canonicalization via htaccess

Posted on April 30, 2008 in Function by Jeff Starr

[ ~{*}~ ] During my previous rendezvous involving comprehensive canonicalization for WordPress, I offer my personally customized technique for ensuring consistently precise and accurate URL delivery. That particular method targets WordPress exclusively (although the logic could be manipulated for general use), and requires a bit of editing to adapt the code to each particular configuration. In this follow-up tutorial, I present a basic www-canonicalization technique that accomplishes the following:

  • requires or removes the www prefix for all URLs
  • absolutely no editing when requiring the www prefix
  • minimal amount of editing when removing the www prefix
  • minimal amount of code used to execute either technique

I have found this “universal” www-canonicalization technique extremely useful in its simplicity and elegance. Especially when requiring the www prefix, nothing could be easier: simply copy, paste, done — absolutely no hard-coding necessary!

Continue Reading

Toggle Element Visibility via JavaScript

Posted on April 29, 2008 in Function by Jeff Starr

Recently, while restoring the popular Jupiter! WordPress theme, which several readers use to “skin” the Perishable Press website, I found myself searching for a simple, effective JavaScript technique for toggling element visibility. Specifically, I needed to accomplish the following design goals:

  • Users should be able to toggle the visibility of any division containing post-meta information
  • The post-meta information should remain visible by default and when JavaScript is unavailable
  • The JavaScript should be as unobtrusive as possible, requiring minimal scripting in the markup

Here are a couple of screenshots demonstrating this repetitious toggling functionality as employed in the Jupiter! theme (click on either thumbnail for larger screenshot):

Continue Reading

Blacklist Candidate Number 2008-04-27

Posted on April 27, 2008 in Function by Jeff Starr

Welcome to the Perishable Press “Blacklist Candidate” series. In this post, we continue our new tradition of exposing, humiliating and banishing spammers, crackers and other worthless scumbags..

[ Photo: Bob Barker Snarls at Rod Roddy ] Since the implementation of my 2G Blacklist, I have enjoyed a significant decrease in the overall number and variety of site attacks. In fact, I had to time-travel back to March 1st just to find a candidate worthy of this month’s blacklist spotlight. I felt like Rod Roddy looking over the Price-is-Right audience to announce the next name only to discover a quiet, empty room. And then like Bob gets pissed that nobody showed up and begins to bark and snarl at Rod to go across the street to the clam store and find some damn contestants. Or, ..um, something like that. Needless to say, this month’s data isn’t as fresh as I would have liked it, but I think you’ll find the information fascinating nonetheless. So let’s get on with it then:

Blacklist Candidate number 2008-04-27, come on down! You’re the next clam-store loser to get blacklisted from the site!

Continue Reading

Top Ten Pink Floyd Songs for Audiophiles

Posted on April 23, 2008 in Audio by Jeff Starr

[ Photo: Pink Floyd ]

The music of Pink Floyd is an audiophile’s wet dream. It is at once diverse, complex, intricate, rhythmic, mysterious, and downright heavy. The vastly inspiring soundscapes created by Pink Floyd are perfect for late nights spent working on the computer. Given a nice pair of high-quality headphones, the following hand-picked collection of Pink Floyd songs is sure to elevate your listening experience to the next level.

Continue Reading

Obsessive CSS Code Formatting: Opening and Closing Brackets

Posted on April 22, 2008 in Presentation by Jeff Starr

Following my recent post on CSS code formatting, I was delightfully surprised to have received such insightful, enthusiastic feedback. Apparently, I am not the only person passionate about the subtle nuances involved with the formatting of CSS code. So, to continue the conversation, let’s explore several techniques for writing the opening and closing brackets of CSS declaration blocks.

Continue Reading

How to Block Proxy Servers via htaccess

Posted on April 20, 2008 in Function by Jeff Starr

Not too long ago, a reader going by the name of bjarbj78 asked about how to block proxy servers from accessing her website. Apparently, bjarbj78 had taken the time to compile a proxy blacklist of over 9,000 domains, only to discover afterwards that the formulated htaccess blacklisting strategy didn’t work as expected:

deny from proxydomain.com proxydomain2.com

Blacklisting proxy servers by blocking individual domains seems like a futile exercise. Although there are a good number of reliable, consistent proxy domains that could be blocked directly, the vast majority of such sites are constantly changing. It would take a team of professionals working around the clock just to keep up with them all.

As explained in my reply to bjarbj78’s comment, requiring Apache to process over 9,000 htaccess entries for every request could prove disastrous:

Continue Reading

The Pros and Cons of Blogging

Posted on April 16, 2008 in Blogging by August Klotz.x, III

Among my friends, family, coworkers, and other social acquaintances, there are not many “bloggers.” In fact, there aren’t any. Two or three of my old friends have websites that are updated once or twice per year, but none are actively blogging and sharing their ideas with the online community. Many of my “non-blogging” peeps simply don’t “get it.” To them, the whole idea of consistently updating a website with new material seems like a big waste of time. In fact, on several occasions, I have been confronted with some serious questions and criticisms about the whole “blogging thing.” In this article, I take the time to respond to a few of these complaints and questions, which ultimately expose some of the pros and cons of blogging.

Continue Reading

Drop-Dead Easy Random Images via PHP

Posted on April 16, 2008 in Function by Jeff Starr

Recently, while restoring my collection of Perishable Press themes, I needed a fast, effective way to randomize a series of images. After playing around with several likely candidates, I finally devised the following drop-dead easy technique:

<img src="http://domain.tld/path/random/image_<?php $random = rand(1,n); echo $random; ?>.png" alt="[ Random Image ]" height="50" width="50" />

This single line of code facilitates the random display of n number of images (image_1.png, image_2.png, image_3.png, etc.) located in the target directory (http://domain.tld/path/random/). For those of you that understand how this works, great! That’s pretty much the entire purpose of this article. However, for those that would appreciate some further explanation, let’s examine this technique in a little more detail (you have been warned!)..

Step 1: Prepare your images

Prepare any number of images of the same file type (e.g., .png, .jpg, .gif, etc.) and name them numerically. You can name your images just about anything you like, so long as the only difference between each name is a single numerical digit. Further, ensure that the numerical digits begin with zero and proceed in order to the total number of images in the set. For example, assuming you have three .png images, any of the following name sequences is perfectly acceptable:

Continue Reading

Pure CSS: Better Image Preloading without JavaScript

Posted on April 15, 2008 in Presentation by Jeff Starr

After reading my previous article on preloading images without JavaScript 1, Nanda pointed out that adding extra markup to preload images is not the best approach, especially where Web Standards are concerned. Mobile devices, for example, may experience problems when dealing with the following preloading technique:

/* ADD THIS TO CSS */
div#preloaded-images {
   position: absolute;
   overflow: hidden;
   left: -9999px; 
   top: -9999px;
   height: 1px;
   width: 1px;
}

<!-- ADD THIS TO XHTML -->
<div id="preloaded-images">
   <img src="http://perishablepress.com/image-01.png" width="1" height="1" alt="Image 01" />
   <img src="http://perishablepress.com/image-02.png" width="1" height="1" alt="Image 02" />
   <img src="http://perishablepress.com/image-03.png" width="1" height="1" alt="Image 03" />
</div>

Thus, as Nanda suggests, it is better to preload images using only CSS. Using the CSS background property, we can preload images via existing <div>s, <span>s, or other elements in the (X)HTML markup.

Let’s say you have three images (e.g., image_01.png, image_02.png, and image_03.png) that you would like to preload using this method. First, examine your markup for three identifiable <div>s (or other elements) that may be used as CSS hooks for the preloaded images. For example, looking at the source code of the current page, I would choose the following three divisions:

Continue Reading

How to Edit the Firefox Custom Dictionary

Posted on April 13, 2008 in Technology by Jeff Starr

Oooops! Didn’t really mean to add that particular word to the Firefox custom dictionary. Better remove it now before it causes problems later on..

As one who takes full advantage of the custom dictionary in Firefox, I occasionally find myself adding nonexistent or misspelled words to the dictionary by accident. Not wanting to deal with a false negative down the road, I always take the time to stop what I’m doing, locate the custom dictionary, and remove the erroneous term. Finally getting sick of trying to remember the esoteric location in which Firefox stores the personal dictionary, I decided to make a few notes and post the information here for easy access when it happens again (and it will happen again;).

Continue Reading

Perishable Press Comment Policy

Posted on April 8, 2008 in Perishable by Jeff Starr

Before you comment here at Perishable Press, please take a moment to review the official comment policy. Here is a simplified overview of the complete policy:

Comments are open to everyone. Name and email are required. Email kept private, never shared. Website URL optional. The form accepts basic XHTML. Line and paragraph breaks automatic. Please wrap each segment or line of code in <code> tags (no <pre> tags). I reserve the right to edit/delete any comment. Spam will be deleted. Pointless and otherwise lame comments may be deleted. Please stay on topic and comment intelligently.

Official Comment Policy

First, everyone has something to say, including people who disagree with your opinion. One of the purposes of this site is to provide an open forum where everyone is entitled to express their ideas. The goal is to encourage new ways of thinking by listening to the thoughts of others. If your goal is merely to argue and rant about some particular issue, please unload yourself somewhere else. If, on the other hand, you are genuinely interested in exploring the topic at hand with openness and honesty, then by all means, get involved. We are all looking forward to hearing your opinions and learning from your ideas.

As for the fine print, there are a few additional points, encompassing several technical and administrative aspects of the commenting process. First of all, use your real name or nickname, not a site name or business name. Using a site name or business name is a good way to get your link or comment removed. Technically, commentators must provide a valid email address. All email addresses will be kept completely private and never will be shared with anyone. Each comment author may provide an optional website link, which will be served with the author’s name. If you do not provide a website link, your author name will be displayed in text only. When leaving a comment, basic XHTML (e.g., <em>, <strong>, <a>, etc.) may be used to format the text. Line breaks and paragraph tags are automatic. Please wrap code examples in <code> tags. Also, please note that certain comments are moderated; if your comment does not appear after several days, or if you wish to comment privately, contact me.

Continue Reading

Three Unsolved WordPress Mysteries

Posted on April 8, 2008 in WordPress by Jeff Starr

After several years of using WordPress, I have at least three unanswered questions:

  • What’s up with the WordPress PHP Memory Error?
  • Why do certain phrases trigger “Forbidden” errors when saving or publishing posts?
  • What happened to the Plugin Pages in the WordPress Codex?

Let’s have a look at each one of these baffling mysteries..

Continue Reading

Obsessive CSS Code Formatting: Patterns and Trends

Posted on April 7, 2008 in Presentation by Jeff Starr

Call me strange, but I format each of my CSS rules according to the following pattern:

div#example element {
	margin: 5px 15px 5px 0;
	border: 1px solid #444;
	line-height: 1.5em;
	text-align: center;
	background: #222;
	font-size: 10px;
	display: block;
	padding: 5px;
	color: #888;
	float: left;
	}
div#another div.example element {
	border: 1px solid #444;
	margin: 7px 0 17px 0;
	letter-spacing: 1px;
	font-weight: bold;
	background: #222;
	font-size: 1.1em;
	cursor: pointer;
	display: block;
	padding: 3px;
	width: 308px;
	color: #888;
	clear: left;
	float: left;
	}
div#another div.example element {
	text-indent: -9999px;
	overflow: hidden;
	position: fixed;
	display: block;
	z-index: 9999;
	padding: 0px;
	margin: 0px;
	bottom: 0px;
	right: 0px;
	}

Continue Reading

Perishable Press Theme Renovations Complete

Posted on April 6, 2008 in Perishable by Jeff Starr

Finally, after many grueling weeks of relentless determination and tedious repetition, I am pleased to announce the return of the entire collection of Perishable Press themes. Enabling users to change the appearance and functionality of the site, the fifteen unique themes were dismantled several months ago for the ongoing Perishable Press site renovation. Since then, links referring to the removed themes had been redirected to a temporary “Labs” subdomain (labs.perishablepress.com), which featured various installations of WordPress populated with “lorem ipsum” filler text. Although this was suitable as a temporary fix for those interested in exploring the different themes, full theme renovation and restoration remained an ongoing task that finally (finally!) reached its conclusion late last week.

Each and every theme has been painstakingly evaluated, optimized, improved, and tested. During the process, many structural, organizational, and presentational improvements were made. Each theme now operates independently, requiring no files (images, scripts, etc.) beyond those contained within the theme directory itself. Further, each theme has been integrated into a sitewide error-logging process whereby all errors (PHP, 404, htaccess, etc.) are logged in a centralized location and appended with plenty of theme-specific information. Thus, if someone begins to experience issues with one of these newly restored themes, I will be the first to know. This is important as people begin to use the themes under different circumstances (operating systems, user agents, extensions, etc.). I tested as much as possible to ensure universal functionality, but must admit a significant reliance and dependence on Web Standards throughout the restoration process. Thus, if something breaks on Internet Explorer, I won’t be surprised ;) So, without further ado, here is a summary of each newly renovated theme — feel free to check ‘em out!

Continue Reading