Migrate WordPress MySQL 4.0 to MySQL 5.0 (especially for 1and1 with phpmyadmin)

I recently had to migrate my database on 1and1 hosting from MySQL 4.0 to MySQL 5.0 and their instructions and a lot of the internet’s instructions were pretty incorrect. So here is the right way to do it.

1. Go to the “MySQL Administration” area of your hosting provider.

For 1and1, just login and under the “Web Space” click on the link “MySQL Administration”.

2. Create a new MySQL 5.0 database for WordPress to use.

3. Update your wp-config.php file to use the new database’s name, username, password, and hostname.

4. In the MySQL Administration area, find and click on a link for phpmyadmin for your old database.

5. Once you are in phpmyadmin, click on the databases name in the left hand column. It does not look like a link, but it is.

6. After clicking on the databases name, the right-hand column of the page should update with some tabs. Click on the top tab labeled “Export”.

7. Under the “Export” heading select all the tables in the export box so they are all highlighted. Then check the checkbox at the bottom to “Save as file” and select the “gzipped” radio button option. Then save the gzipped file locally.

8. Go back to the MySQL administration area and click to use phpmyadmin for the new MySQL 5.0 database you setup.

9. Once you are in phpmyadmin for the new database, click on the databases name on the left. Again, it does not look like a link, but it is.

10. The right hand coolumn shoudl update again with tabs at top, click on the “SQL” tab.

11. At the bottom you should see an area title “Or Location of the text file:” with a choose file button. Click on the button to choose the gzipped file you exported locally earlier. Then select the “gzipped” option for compression, and then click the “Go” button.

12. Visit your blog’s URL and WordPress might have to update the database automatically for you. Just agree if it asks to.

#12 might be because I updated to the newest version of wordpress when I did this as well. To update your version of wordpress, just go to wordpress.org, download the latest version. Unzip the files, and just copy and paste the files over your old wordpress files. Don’t forget to update the wp-config.php with your new database credentials.

How to clear the iOS and Mobile Webkit HTML5 Canvas

Took me forever to find this, but hopefully you found this post faster:

You can either use “context.clearRect(0, 0, canvas.width, canvas.height);” Which I found only worked sometimes, and best in desktop version of the browser.

What I did was the width trick (setting the canvas width to itself clears EVERYTHING), and since I had also drawn lines I had to run the beginPath() method like this:

context.fillStyle = "#000";
context.fillRect(0, 0, context.canvas.width, context.canvas.height);
context.canvas.width = context.canvas.width;

Creating a rectangle that paints the whole screen was key for mobile. beginPath() will clear all the old paths for you. For some reason it kept leaving the last path I drew even when I was trying to clear the whole thing. Have fun!

How to setup an Arduino board with LEDs – Blink Morse Code

Got my hands on my first Arduino project this weekend. My friend was nice enough to lend me an Arduino Duemilanove board with a couple starter supplies.

I did a little enhancement on the basic turn an LED on/off by giving it a string of char representing morse code and making it blink to that.

Here is the board setup:

Ardunio LED breadbroad and wire setup

How to setup the board:

  1. Plug a wire from Pin 5 to the breadboard (red wire in pic above)
  2. Continue the circuit by pluggin in a resistor from where Pin 5 connects on the breadboard to the where you wish to insert the LED
  3. Connect the side of the LED that DOES NOT have the flat edge to the resistor on the breadboard
  4. Plug the flat end on the LED in any row on the breadboard that is not where the other wires are connected
  5. Connect a wire from where the flat end of the LED is connected to the Pin labeled “Gnd” (a.k.a. Ground on your Ardunio board) (white wire in pic above)

Here is code to compile and upload to your Ardunio. The morse code is represented by dots and underscores. Read the comments in the code to get a clear understanding of what is going on:

Not the most elegant, but I am a beginner so far. You should now see the LED blink whatever Morse code you write with periods and underscores. Have fun.

Ruby on Rails strftime() options

Format Meaning
%a The abbreviated weekday name (“Sun”)
%A The full weekday name (“Sunday”)
%b The abbreviated month name (“Jan”)
%B The full month name (“January”)
%c The preferred local date and time representation
%d Day of the month (01..31)
%H Hour of the day, 24-hour clock (00..23)
%I Hour of the day, 12-hour clock (01..12)
%j Day of the year (001..366)
%m Month of the year (01..12)
%M Minute of the hour (00..59)
%p Meridian indicator (“AM” or “PM”)
%S Second of the minute (00..60)
%U Week number of the current year, starting with the first Sunday as the first day of the first week (00..53)
%W Week number of the current year, starting with the first Monday as the first day of the first week (00..53)
%w Day of the week (Sunday is 0, 0..6)
%x Preferred representation for the date alone, no time
%X Preferred representation for the time alone, no date
%y Year without a century (00..99)
%Y Year with century
%Z Time zone name
%% Literal “%” character

How to send SMS Text Messages with Twilio from Rails

It was kind of confusing to find a straight forward example on how to send a text message through Twilio using Rails. Here is a step by step guide I wish I had.

  1. Sign up for a free account with Twilio. You will get a good amount of free credit to play around with.
  2. Install the Twilio Ruby Gem by navigating to your project folder in Terminal and typing:

    sudo gem install twiliolib
  3. In your controller (create a new controller if you want), put this chunk of code at the very top. Replace SID, ACCOUNT_TOKEN, and CALLER_ID with what Twilio provides you:

    require "twiliolib.rb" # your Twilio authentication credentials ACCOUNT_SID = "put_your_sid_in_parentheses_here" ACCOUNT_TOKEN = "put_your_token_in_parentheses_here" # version of the Twilio REST API to use - do not change API_VERSION = '2010-04-01' # Sandbox phone number # or outgoing Caller ID you have purchased through Twilio CALLER_ID = "put_your_sandbox_phone_number_here" #CALLER_PIN only needed to send using sandbox number. Looks like 9999-9999 CALLER_PIN = "put_your_sandbox_pin_number_here"
  4. Then in a method in that controller try this:

    #Text message info t = { 'From' => CALLER_ID, 'To' => "replace_with_your_cell_num_in_parentheses", 'Body' => ("#{CALLER_PIN} Twilio scales!") } begin account = Twilio::RestAccount.new(ACCOUNT_SID, ACCOUNT_TOKEN) resp = account.request("/#{API_VERSION}/Accounts/#{ACCOUNT_SID}/SMS/Messages", 'POST', t) resp.error! unless resp.kind_of? Net::HTTPSuccess rescue StandardError => bang #This area will be called if an error happens with the Twilio API redirect_to({ :action => :index, 'msg' => "Error #{ bang }" }) return end redirect_to({ :action => :index, 'msg' => "SMS sent." })
  5. Then you should get a text message that says: “Sent from a Twilio Trial Account -9999-9999 Twilio Scales!”
  6. Now that you have it working with a sandbox number it’s easy to to switch to a real phone number. Just go into the “Numbers” section of your account and buy an outgoing phone number. Give the phone number an SMS URL. I just gave it the url of my app.change out the sandbox phone number
  7. Then use that new phone number instead of your sandbox phone number and delete the CALLER_PIN from the top and in the body part of the text message you are sending.

If you found this post helpful please link to it from your blog or website. Leaving comments below is also cool. Thanks!

Smart Way Around IE CSS Hacks & Conditional Stylesheets

If you are ever bothered by adding hacks to your css or including your ie css styles in multiple style sheets than do I have a solution for you.

It’s so simple and awesome.

Step 1) Surround your html tag with conditional statements like so:

<!--[if lt IE 7 ]> <html class=”ie6″> <![endif]-->
<!--[if IE 7 ]> <html class=”ie7″> <![endif]-->
<!--[if IE 8 ]> <html class=”ie8″> <![endif]-->
<!--[if IE 9 ]> <html class=”ie9″> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=”"> <!--<![endif]-->

Step 2) In your css just preface your targeted ie styles with the class name of the html tag you are targeting like so:

.ie6 h1 { color:red; }
.ie7 h1 { color:green; }
h1 { color:black; }

Super easy to target any version of IE without having to remember hacks or keep all your ie styles seperated in seperately served stylesheets.

Originally discussed here: Conditional stylesheets vs CSS hacks? Answer: Neither!

JQuery Toggle Hide and Show Link

Even if you’re new to JQuery it’s always mind-boggling how easy it is to do pretty cool UX stuff with it.

Here’s you you make a link that shows and hides content on you page:

function() {
$("#toggle_link").text("Hide Extra Info");
function() {
$("#toggle_link").text("Show Extra Info");

Give you link the id of "toggle_link" and the text you want to hide the class of "extra_info_text." Pretty darn easy.

How to Save Over $500 When Hiring a Web Designer or Developer

Most people looking to hire a web designer want a kick-ass website that makes them money. They want a return on their investment but are surprised that it definitely costs minimum $2,000 to get a nice website.

So how do you save money and get a website you love that makes you money?


1. Go Buy Your Domain and Hosting by Yourself

You need both a domain and hosting before your web guy can start. Come up with a short, memorable domain like:


Then you will need to buy what is called hosting. This is just a place for your web guy to put the files that are your website.

You can get a Free Domain & Web Hosting for $6.95 Per Month with Bluehost. Great Deal.

You just saved yourself minimum $90 and your web guy can start right away.

2. You Update Your Website. Not the Web Guy. Use CushyCMS!

I will charge minimum $60 an hour to upkeep your website once it’s done. And if you need one small piece of text updated, yep, minimum increment is 1 hour and you will be charged $60.

So in order for you to avoid paying so much tell your web person FROM THE START that you want to be able to update your own website. Tell them to use CushyCMS.

Cushy is just a cute word but CMS stands for Content Management System. It is just a way to enable you to edit text on your own website by logging in, typing like you are in Microsoft Word, and hitting Save. Magic.

It requires barely any work for your web guy to set up. They may not even charge you for it!

How much does using CushyCMS save me?

Let’s say you have a website that has news or events on the homepage and you have a couple a month. So you need to have your web guy update it 3 times a month. Minimum $180. Just for one month! This will save you a lot over the year.

3. Hire a Web person that is good at Design & Copywriting.

If you are going to spend $2000 or more on something for you business you better hope you at least get that money back through new customers or orders.

Two things will get you that money back.

Good Web Design / Development and good Copywriting that sells.

You can find these good web people on Sortfolio (just select your city, or any city and go virtual, and select a budget).

You will save with the cheap web designer but you will also never earn your money back. You will make it back with the good Web Designer.

Think about it. You try to give the best return for people buying from you. Same with web people.

Let me know if you have any questions in the comments.