What Online Backup Service Do You Recommend?

About a month ago, I asked on Twitter for suggestions for online backup services as I’m tired of manually backing up and I never do it often enough. I was suggested Mozy, but I was also suggested a lot of alternatives. However I was leaving on a business trip basically the next day, so I never got around to reading the Tweets and they eventually slipped off my @mentions list.

So now I’m asking how I should have done it in the first place — on my blog. What online service do you use to backup your data? And before anyone suggests it, Dropbox is out of the running as it’s too expensive for actual backup (it’s great for sync though!).

Thanks!

YOURLS + Twitter for iPhone (UPDATE: TweetDeck Too!)

UPDATE: These instructions now apply to TweetDeck as well! You can find the field at Settings -> Services and pick “Other” for the shortening service.

Do you run YOURLS? Do you use Twitter for iPhone (aka Tweetie)? If so, this post will be of interest to you.

Twitter for iPhone supports using a custom shortening service. Thankfully the YOURLS API will output a format that Twitter for iPhone will accept.

So how do you go about setting it up you ask? Start by going to your YOURLS admin area and clicking the “Tools” link at the top. About half way down the page will be your signature (it’s like a password). It will be a 10 character string. Hang onto this, you’ll need it soon.

Now open up Twitter for iPhone and go to the “Accounts & Settings” screen. You can get there by pressing the three dots in the bottom right and then scrolling to the very bottom of the screen that comes up and pressing the “Accounts & Settings” button. There will then be a “Settings” button in the bottom left. There in the Settings, select “Services” and then “URL Shortening”. Lastly pick the “Custom…” option.

Now to enter the URL to your YOURLS API script. I found it easiest to craft this URL on my computer and then e-mail myself the URL which I could then copy/paste on my iPod Touch. It was a lot easier than typing it all out on the little keyboard.

This is the URL you will need to use:

http://yourdomain.com/yourls-api.php?action=shorturl&format=simple&signature=YOURSIGNATURE&url=%@

Replace “YOURSIGNATURE” with your signature that you located earlier in this post and leave the rest alone (the “%@” is the placeholder that Twitter for iPhone will look for). If you e-mail yourself the URL, make sure that you still have “%@” at the end of the URL and not “%25@” or something.

Now when writing a tweet, press the character count button and the keyboard will disappear. There in the bottom right will be a button to shorten all URLs in your tweet. They’ll be shortened using your custom domain!

Cool, huh? :)

svn blame

The other day I wanted to figure out when a particular line in WordPress was changed. I wanted to know this so I could find the commit message and ticket that went along with it so I could figure out the reasoning behind the change. How do you go about doing that though?

It turns out that svn blame is the command you want. It will output something like this:

$ svn blame http://svn.red-bean.com/repos/test/readme.txt
     3      sally This is a README file.
     5      harry You should read this.

So the first line was last modified by sally in revision 3 and the second line was last modified by harry in revision 5. Awesome huh?

Props to @ArtemR, @westi, and @zamoose for informing my noob ass on how to do this!

Twitter Followers Count Snippet for WordPress

UPDATE: This code no longer works as Twitter retired v1.0 of their API. v1.1 of their API requires authentication in order to access it. I have no plans to update this code for their new API. Sorry.

Konstantin Kovshenin posted some code on his blog for how to display how many Twitter followers someone has. While the idea was good, I think he went about the implementation in the non-best method. So, for fun and because I don’t post enough code snippets here on this blog, I thought I’d post how I would display how many followers someone has on Twitter. :)

function viper_twitter_followers( $username = 'Viper007Bond' ) {

	// Just to keep the code below cleaner, create the cache key now
	$cache_key = "viper_twitter_followers_{$username}";

	// First we look for a cached result
	if ( false !== $followers = get_transient( $cache_key ) )
		return $followers;

	// Okay, no cache, so let's fetch it
	$result = wp_remote_retrieve_body( wp_remote_get( 'http://api.twitter.com/1/users/show.json?screen_name=' . urlencode($username) ) );

	// Check to make sure we got some data to work with
	if ( empty($result) ) {
		// Cache the failure for 1 min to avoid hammering Twitter
		set_transient( $cache_key, 0, 60 );
	}

	// Parse the data
	$data = json_decode( $result );

	// Make sure we were able to parse it
	// If not, cache the failure (like above)
	if ( !isset( $data->followers_count ) )
		set_transient( $cache_key , 0, 60 );

	// Success! Cache the result for an hour.
	$followers = (int) $data->followers_count;
	set_transient( $cache_key, $followers, 3600 );

	return $followers;
}

echo 'I have ' . viper_twitter_followers( 'Viper007Bond' ) . ' followers on Twitter!';

Reading Material:

If you have any questions about the above code, let me know and I’ll do my best to answer them. :)