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.

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

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.

Ultra DNS: adding a SPF record

Posted on December 16th, 2009 in PHP by Russ

Just a quickie note:
Had to add a SPF record to a domain where the DNS is at ultradns.com.

Skim down to the “txt” areas, and add a text one like this, with your domain as the first textbox.

This one is because this particular client uses google mail for their domain.

v=spf1 include:aspmx.googlemail.com ~all

This one is a seriously generic and just allows any server that’s listed as an MX for the domain.

v=spf1 mx ~all

Trying Git

Posted on December 15th, 2009 in PHP, Webmastering, system administration by Russ

The ominously named “git” is a rather dull knife in my toolbox. I’m used to subversion (svn). I use svn routinely for my own work, as a backup. So I modify some files, do a svn commit and then push my files to where ever they need to go.

Git’s another beast. Because it’s an distributed system, doing a “git commit” doesn’t send my files to the backup. I have to do a “git commit;git push” for that. I’m liking the .gitignore file (compared to svn propedit syntaxes). And I’m liking the easiness of branching. I’ve got a couple of projects that are pretty much duplicates of one another with different filling. Like making a pie, but this one is apple, that one is cherry. With subversion, it feels a lot more like those projects are full of stuff. But git feels leaner. Which is good, right?

Apache ModRewrite Problem

Posted on November 13th, 2009 in PHP by Russ

Ok, here’s a perplexing one.

If (cookie does not exist) AND (cache file exists) THEN redirect user.
[code]
RewriteCond %{HTTP_COOKIE} !^.*cookiename.*$ [NC]
RewriteCond %{REQUEST_URI} ^/?original/page/
RewriteCond -s other/page/index.html
RewriteRule .* other/page/index.html [L]
[/code]

Result: 404, file (/original/page/) does not exist (note that /original/page is itself a redir).

So … what am I doing wrong?

Automatic Updated Services

Posted on November 3rd, 2009 in PHP by Russ

After finding out how easy it was to update my twitter status from a script, or to send direct messages, I’ve got several processes that will send me a twitter DM when they’re done. Real Estate updating script finished? It “pings” me. Server offline? Nagios “pings” me. Or it’ll just update its status and I’ll follow it in my RSS reader.

And now I’ve discovered “posterous.” and Posterous will feed an RSS feed.. so I could email Posterous (post at posterous dot com), and follow that on an RSS reader and whammo, it’s all done too. More content allowed … maybe a full php error handler? Who knows. Yeah I know I’m cheap for not shelling out for HopToad, but that’s what we get with bills like mine.

Next Page »