Need to Backup a WordPress Blog?

Posted on October 26th, 2011 in PHP, Webmastering by Russ

I found a neat plugin – WordPress Backup to Dropbox. It dumps your database to your /wp-content directory and then copies the entire directory tree to your dropbox.com account.

It’s also neat because it uses oauth; it doesn’t store any usernames or passwords, it just requires that you go over to the dropbox site and authorize it. Then you can set a day and time for your site to be backed up and how frequently you want it. There’s even an option to start it now.

Since your web host probably kills off long running scripts, this backup plugin monitors the status and if it appears to go away, it’ll try to restart the process. It’s pretty slick.

Getting First Page Search Results with WordPress

Posted on April 12th, 2011 in Search Engines by Russ

I saw this in Craigslist today:

(snip)
I am increasingly asked to design WordPress websites, and asked to make them so they are easily findable on the first pages of a major search engine like Google, Yahoo, Bing, etc. In fact, just today, I got an inquiry on this very matter. The client wants me to redesign their existing website using WordPress, so I can show them how to update and maintain it, AND they want people to be able to find the website on the first pages of a major search engine. …Two weeks ago, was the last inquiry I got on this very matter, so there is potential for work on 1 or 2 websites a month, if I can resolve this, potentially. …I would love to partner with a mentor webmaster who could either take on that end of the websites or could instruct me. I’m open, and would like to resolve this ASAP. …HELP ME!!!!
(some more snipped)

I’m not a SEO guy; I’m a web programmer (among other things) with some ideas about SEO.

I didn’t send them an email offering my elite services as a SEO guy to help them get first page results. I started off by pointing out that the first thing they needed to decide was the keywords they wanted to rank for– and that “camera lenses” would be a lot harder to rank for than “used canon lenses in Portland.” So the first step would be to define some better keywords.

And for on page SEO, frankly, you could do worse than WordPress- that is, with some SEO plugins, good choices of keywords, pretty URLs, you know, all that stuff a good webmaster would set up for you.

However, you also need to look at the kinds of content you have, the quantity and quality of links to your site and even the responsiveness of your web server.

In a handful of nutshells, you need quality posts that are over 300 words long, using but not overusing your keywords. They should be the kinds of posts that people who search for what you’re offering are looking for, helpful or interesting, or whatever.

You need “some” links. You can’t have an exact number because it’s not an exact science. If they’re all from hack blogs, you might need thousands of them. If they’re from solid domains with some personal accountability, you might need hundreds. But don’t run out and buy them all in one bunch, you want them to be gradually built up.

And starting last year, Google started factoring in the response time of your server; a more responsive server gets better results. Pages loading in a couple of seconds get better results than pages that take a minute to load.

However, keep in mind that none of these are really solid rules; they are differently weighted tests that you could consider as you go through a SEO offering. To add to that, Google (and probably Yahoo and Bing, but they’re less well publicized) changes its ranking algorithmic about once a year. So you might find that your carefully tweaked and optimized WordPress site sits at number seven for three months and suddenly slides to thirty three, and there were no changes.

What I try to tell people (but I believe most people don’t hear me) is that the search engines are trying to help people find stuff. They’re not “screwing the webmasters” or “being completely obtuse” or even “gaming the systems.” Search engines want to be used to find stuff. So make your stuff easy to find and worth finding, let the search engines do their dances, and just do your best in terms of making quality stuff.

All that being said, if you need a good Search Engine guy, talk to my friend Chris Bigler. I’ll post his email or something when I have it (should be Real Soon Now).

Your Mobile Code

Posted on April 7th, 2011 in mobile websites by Russ

Hand crafting your site’s HTML for the best mobile experience can be a real pain in the neck.

Mobile Moxie’s Page Code Grader can help lighten that burden. It’s pretty straightforward to use; put in your site’s URL and pick a user-agent, and then their script will get the site and run a bunch of checks on it. They have a bunch of different UserAgents paired with the page layout images so you can get a rough idea of how your inspected page would look on that device.

Like most tests on the web, however, you should take this test as a guide and not as a rule. When I ran this test on a mobile site, I was surprised to get dinged for the use of tables (this particular site doesn’t use tables) and dinged for style tags (this particular site might have style tags, but I don’t think so). And I’m not sure how to get a 1 pixel border without specifying the border width in pixels.

However, there were some good things it caught; it steered me toward the use of handheld.css (as opposed to the style.css file I normally use; apparently the name is important) and it reminded me to use relative measures rather than the absolutes I had previously (I had a line height of 24 pixels, and changed it to 2em). It correctly found that my images are nice and small. It liked my text-buttons (as opposed to some unwieldy image buttons).

Overall, I give this tool a B. It’s in my list of tests to run, but it’s not the last one I’d use.

If you’re having a problem with your image sizes, give Dink a try: Dink does resizing of images for mobile devices, on the fly, so you don’t have to. And it has drupal and ruby on rails plugins.

Rails form skipping auth token from a specific form

Posted on April 4th, 2011 in Ruby on Rails by Russ

This might have been solved more elegantly or more securely. But it’s here if you want a place to start.

I have a client using Rails, and they want to log into their site from another site (another domain). The problem is that RoR uses “authentication tokens” for any POST, PUT or DELETE HTTP requests; so any form that does a POST action requires this code. It’s supposed to be a non-predictable code that the server can assign and check for on the return, to make sure the session’s valid. The login form is a POST form. Thus, the site needed an authentication token. Or it needed to ignore that for this other domain.

The solution I came up with was to use a ’skip_before_filter’ in the sessions_controller.rb file. It looks like this:

skip_before_filter :verify_authenticity_token, :if => Proc.new {|c| c.request.referer =~ /otherdomain/ }

It’s not elegant and could be thwarted by the referrer looking like “http://example.com?attack_vector=otherdomain” but I think by the time someone is hand crafting referer strings or setting up forms, there will be other issues to deal with (firewalls, password strength, et cetera).

…one interaction is the whole experience

Posted on April 16th, 2010 in PHP by Russ

… Seth Godin (http://sethgodin.typepad.com/seths_blog/2010/04/when-a-stranger-reads-your-blog.html) said it here; Every interaction might be the whole experience that someone gets with you. The implication is that every lunch you serve should be the best. Every blog post you write should be the best. Every piece of code you codify should be the best (cough). And that you should remember that each person that sees your output (or experiences you) is forming an opinion of you from that one piece.

But what he doesn’t mention is that it goes both ways. Give other people the benefit of the doubt, because just this one lunch, this one blog post, this one piece of code may not be representative of the whole body of that person’s work. Maybe they’ve got bad allergies and need the drugs to kick in. Maybe they stayed up all night with a sick kid. I say “do your best work, but don’t expect others to do theirs.”

It’s funny, I find myself swimming upstream against Seth Godin on this topic. Is quality fractal? (he says yes, I said no). And now this.

Pipe to PHP Script from Evolution

Posted on April 4th, 2010 in PHP, system admin, system administration by Russ

Here’s a quick example of how to pipe a message to a PHP script from Evolution (the gnome-tastic email client).

First, write a script, using very clear paths. And use php://stdin to capture the input stream:


#!/usr/bin/php -q
< ?php
include_once( dirname(__FILE__).'/includeme.php' );
$input='';
$fh=fopen( 'php://stdin', 'r' );
while( ! feof( $fh ) ) {
$input .= fread( $fh, 4096);
}
fclose( $fh );

Do whatever you need to with the $input variable. I had subscribed to a newsletter, and was using PHP to parse out the interesting bits of the newsletter (everything between the h1, h2 and h3 tags, so I knew if I needed to read it), and remail that to a more-frequently checked email address.

You can test your file with a shell command of "cat (testfile) | $somescript.php "

When it's perfect, then go to your evolution program and use the "message filters" to "pipe a message to a program." And pipe it to this one (including of course the explicit paths).

The things to take away here are the php://stdin slurp, and the fact that you have to use explicit paths (and you'll have a dickens of a time tracking down any errors).

Hope that helps ya!

Just a quick snippet

Posted on February 10th, 2010 in PHP by Russ

if (typeof console == ‘undefined’) { var console = { log : function() {}, debug: function() {} }; }

Is Quality Fractal?

Posted on February 5th, 2010 in PHP, Webmastering by Russ

When Des Traynor says “Quality is Fractal he means that by examining one piece of a whole, one can pass a judgement on the whole. In his example of a steak, it doesn’t matter if the steak is terrific, if the gravy is served cold or the waiter is ugly and smells of cigarettes.

I’m not convinced. And this could be because I’m working on my overall consistency. I think this idea requires a consistency that may not be present in the end product. For instance, I might write a glorious function for part of a website but put it together with the rest of the framework and my implementation is less than glorious. You could examine the function and make a judgment that the whole is terrific — but the whole is flawed and weak.

I won’t argue that if one piece is great and another is not so great, that the lower “average” between the two drags the overall quality down. That’s true too; I think that inconsistency is a flaw in a product. ( That’s why I’m working on it myself. ) That’s not what I’m saying; what I’m saying is that it’s hard to judge the whole effectively when there’s different levels of greatness.

jQuery Animated Backgrounds for Nifty Effects

Posted on February 4th, 2010 in HTML, Javascript by Russ

I’m fascinated with the css sprites idea; that with a hole in one piece of paper, you can place it over another piece of paper to create different effects depending on what’s showing through the paper. It’s kind of an optical illusion.

Snook.Ca has some great ideas on how to use these optical illusions for a little pizazz with your site. I’ve reused their gradient/fade example over at this site: Footed Pyjamas (need some warm flannel footed pyjamas?) on the “Buy Now” button and it gives me a little thrill each time I slide my mouse over it.

I wonder what would happen with a wavy line, like stylized ocean waves, or maybe something else. I’ll have to play with it some more. :)

Web Page Speed

Posted on December 17th, 2009 in PHP, Search Engines, Webmastering by Russ

With chatter today about website speed, here’s a quick test to see how long a webpage takes to download.

Keep in mind that this should be run at some interval with an average taken. Server load and speed should be taken into effect.

$ time wget –quiet –delete-after –page-requisites http://www.gmail.com

An example output is:
real 0m0.421s
user 0m0.000s
sys 0m0.012s

“time” gives you how much time something took; the command after the time command. You want the “real” number.
“wget” is a great tool for downloading stuff from the web. The –page-requisites flag gets the CSS, JS, images and other things necessary for the page to be displayed. The other options (quiet, delete after) are just there to clean up the output.

This also doesn’t take into account how much time a browser might take arranging the pieces into a pie. A bunch of nested tables will cause the client to slow down. Not specifying image height and width will cause browsers to slow down. A slow computer … well, you get the idea. Run this and take an average of the REAL value and you should have a pretty good idea of how slow your site is.

Note
If you’re plugging this into a php script, keep in mind that “time” is outputting that into the STDERR stream.

Next Page »