Category “Geek”

Comments Closed

Useful SQL queries for migrating a WordPress database

First, if at all possible, use the WP Migrate DB Pro or BackupBuddy plugins to migrate your WordPress database. The money spent will save yourself a lot of frustration and hair pulling, and hours if not days of cleanup and massaging of the WordPress database.

But if that’s not possible, welcome to my world for the past week. I’ve had to migrate a WordPress database without my favorite migration tools. After scouring the web for tutorials and tips, I’m compiling them here for easy reference.

Gather Your Tools

First thing you need is to get your hands on the following:

1. Database name, prefix, user and password.

You can find these defined in the wp-config.php file. In the following examples, be sure to swap out the database name wordpress and prefix wp_ with the correct values from your situation.

2. Access to phpMyAdmin so that you can interact with the database.

We’ll be running the commands below through the SQL tab in phpMyAdmin.

phpmyadmin-sqlquery

Running SQL queries on your database with phpMyAdmin

You could also connect directly to MySQL through the terminal / shell prompt. Good luck if you don’t have phpMyAdmin.

3. Backup, Backup, Backup

Don’t say I didn’t warn you. Export your untouched database and lock it up. If all goes wrong, restore to this backup.

Change the Site URL

The first thing you would want to do is to change the site URL. You can browse the wp_options table for the siteurl and home options values directly, or you can use this SQL command:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl.com', 'http://www.newsiteurl.com') WHERE option_name = 'siteurl' OR option_name = 'home';

Next, you’ll want to replace all instances of oldsiteurl.com in your post’s contents and GUID.

UPDATE wp_posts SET post_content = REPLACE (post_content, '//www.oldsiteurl.com', '//www.newsiteurl.com');
UPDATE wp_posts SET guid = REPLACE (guid, '//www.oldsiteurl.com', '//www.newsiteurl.com');

Read More »

Comments Closed

Setup MAMP and Parallels to test Windows browsers on Mac

Had to figure this out earlier today and figured others might be looking for an answer too. I am assuming that:

  1. You are using MAMP with the default ports (80 for Apache)
  2. You are using Parallels with Windows 7 (although these steps should work for older versions too)

Step 1: Setup your local environment with MAMP

This step is pretty straightforward. If you put your website in <Document Root>/sitename should be able to load it at http://localhost/sitename/.

Here’s a helpful tutorial. Don’t forget to set your Apache and MySQL ports to the default 80 and 3306.

Step 2: Figure out your Mac’s IP address on the network

Go into your Mac’s Network Preferences. You’ll see 2 or more connections on the left and the active one will say Connected. Click on it and you’ll see the IP address on the right side of the pane.

To make sure your Mac’s IP address doesn’t change, click on Advanced → TCP/IP. The options sheet below appears.

Network_Preferences

Change the IPV4 option to Using DHCP with manual address and type in an unused IP address. In the example above I used 192.168.1.100. Read More »

Disable shortcodes for ElegantThemes

Go to ePanel/custom-functions.php and remove:

require_once(TEMPLATEPATH . '/epanel/shortcodes/shortcodes.php');

However I recommend that you don’t use ElegantThemes. Sure they’re cheap, but they don’t offer Automatic Updates which makes their themes pretty insecure and vulnerable to hackers.

If you want high quality themes with rock solid security and top-notch support, go with StudioPress or WooThemes.

Custom DIY standing desk with Ergotron LX Dual Stacking Arm, made from IKEA NUMERÄR countertop

When I put together my original IKEA standing desk, I was still experimenting and wanted a solution where I could convert back into a regular sitting desk if necessary.

That solution worked well enough but it was never a long term solution. The biggest problem I had with it was that the computer screen was too far away from my face (the desk I used was 60cm deep) and I found myself leaning forwards to make out text on the screen. The desk was also pretty unstable and would begin to wobble if I was typing quickly.

So when I moved into my new home in late 2011, I began devising a more permanent and flexible solution. The result is this: a standing workstation made from an IKEA NUMERÄR countertop and an Ergotron LX Dual Stacking Arm.

My new standing desk is elbow height, with the awesome Ergotron LX Dual Stacking Arm

Read More »

WTOTW: Automatically post selected Instagram photos to your blog with ifttt

My Instagram yesterday got a lot of likes and apparently people are really interested to do this, so here’s a quick tutorial how.

This tutorial will show you how to post *selected* Instagram photos to your WordPress blog, automatically. All you need to do is to tag your Instagram with a hashtag for it to work.

ifttt

The key to doing this is a service called ifttt, which is short for “if this then that”. Basically you tell it to watch for a trigger (if this) and do something in response (then that). See the quick one-page guide on their site. Tip: ifttt is pronounced like ‘lift’ without the ‘l’. Read More »

Comments Closed

Quick tip: transfer email accounts and email data between cPanels

I recently had to manually migrate a cPanel account (and all the websites and email accounts within it) to a new web host. I had BackupBuddy to migrate the sites super-easily, but the email accounts remained a problem. Not only were they full of emails but I didn’t have the email account passwords as well.

After Googling around I found the answer. Just copy the mail and etc directories to the new cPanel account. The mail directory contains all the email messages, while the etc directory contains all the settings. Simple!

And how do you copy the directories between servers? You could download it to your computer and up again to the new server, but this is where learning how to use the unix command scp comes in handy

Comments Closed

How to find the ID of a Facebook page for non-admins

If you need to find the ID of a Facebook page, you can click the Edit button and find the ID in the edit page URL, for example www.facebook.com/pages/edit/?id=20531316728

But what if you’re not an admin for the page? You can still find out the page’s ID simply by going to http://graph.facebook.com/PAGENAME.

So if you point your browser at http://graph.facebook.com/facebook, you’ll find that the ID for Facebook’s official Facebook Page is 20531316728.

Hat tip @dustyhawk

Comments Closed

GoDaddy supports SOPA, so let’s all move to Hover

Recently I’ve started using Hover as my main domain registrar, an excellent alternative to the popular GoDaddy which is where many people buy their domain names from. Like many others, I have got tired of GoDaddy’s site and service. Their CEO’s elephant-killing antics didn’t help with their public image too.

Today, we have another reason to ditch GoDaddy – they are a supporter of the Stop Online Piracy Act. While stopping online piracy is a noble cause, this bill being put forward by US lawmakers is really dumb. So dumb that Google, Yahoo!, Twitter, Craigslist and many other internet giants are opposed against the bill. Ars Technica has a great explanation on why SOPA is so bad.

Anyway, back to Hover. Go check out their website and compare them against GoDaddy. They currently have a promotion where transferring domains to Hover only costs USD10.

P.S. Use my affiliate link and get 10% off ;) http://hover.com/clickstarter