How to move WordPress sites between cloud servers using Ubuntu 11.10 and PHPMyAdmin

Here’s a quick howto:

I use Rackspace as my cloud service; I was moving a few sites from one server using Ubuntu 10.04 LTS (Lucid Lynx) to a new one using 11.10 (Oneiric Ocelot). I hit a few issues, so I thought I’d tell you how to export a WordPress site in its entirety and move it between two LAMP servers.

  1. Open a file manager on your local machine, and open both remote locations.
  2. Copy the root and all files of the site to your new server in the same location.
  3. Copy the sites-available virtual host file from /etc/apache2/sites-available/ directory to the same location on your new server.
  4. Create the symbolic link in sites-enabled by changing into /etc/apache2/sites-enabled/ and using this command: “sudo ln -s /etc/apache2/sites-available/yourhostfile yourhostfile”.
  5. Open PHPMyAdmin for your old server in a browser window. Login, and open the database for the site you want to move.
  6. Go to the Export tab. Assuming you’re using UTF-8 encoding (and that’s a very safe bet), all you have to do is ensure that the Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT box is checked under Structure, and that all options are highlighted in the Export box. Export the uncompressed database and save to a convenient location.
  7. Open PHPMyAdmin in your new server, login, and create a new database with the same name as the one you’re importing.
  8. Import the database you exported.
  9. Create a user on that database with the same name and password.
  10. Edit the DNS zone file for your site to point to the new IP address for your new server.
  11. SSH into your server, and use this command: “sudo service apache2 restart”.

Hit Ctrl+F5 once you think the DNS records will have propagated, and ensure it worked.

 

How to recruit a software developer. (Part 2)

We’ll continue with the problem of incentivization for recruiters.

Recruiting must be the most outsourced, underfunded, middleman-heavy profession there is. There are several frustrations that go along with being heavily recruited by people who do not know or care whether you fit a given job description, and they range from the merely careless and time-profligate to the truly unethical.

(1) CARELESS: Recruiters who mass email everyone on CareerFinder and Monster with the word “Ruby” in their profile for an Austin, Texas-based junior web developer 3-month contract gig specializing in Ruby on Rails.

I am not a Ruby developer, I will not move to Austin, Texas, especially for a three month contract, and I’m not a junior ANYTHING. I have some skills with Ruby, meaning that I can install the necessary scripts, edit them, run them to operate a site, and I know enough to know when I need to call a specialist. This makes me able to list
Ruby as a general low-level skill on my resume, but does not in any way qualify me for a development job on a site that solely uses Ruby for an environment. However, that keyword hits big with recruiters, and I get probably 15 emails a day from recruiters trying to get me to take a job for which I am unqualified and in a location to which I would not move. A simple glance at my resume with the words “Senior Development Manager and Web Architect” emblazoned across the top and a brief scan of my skillset tells anyone I am a skilled coder who has been moved up the chain to management, and would likely help those recruiters to target me far more efficiently.

(2) CARELESS: Recruiters who speak such poor English that their emails are unreadable–and that sometimes includes native English speakers.

I am glad that you’re “pleased for making time and hoping you will be helping me networking to fill VERY IMPORTANT positino immediatly in NEW YORKCITY as JAVA DEVELOPAR” [not a joke; I seem to be
perpetually emailed by the recruiter version of Paul Christoforo], but I don’t need it filling my day. At the very minimum, have your job posts reviewed for content and grammar before sending them to thousands of developers.

(3) UNETHICAL: Recruiters who are paid by the emails they generate, not by the positions they fill.

This is a common problem among firms that have outsourced to the Philippines, India, Bangladesh, Malaysia…in fact, name your popular outsourcing destination in Asia, and you’ll find these recruiters, who are paid to send out as many emails as possible. They’re no better than spam, but because they’re targeted to you and have your email address, you can’t filter them the way you would filter a Cialis or pr0n ad.

(4) CARELESS: Recruiters who have not paid attention to your preferred location–and don’t care.

I will not take a job in South Dakota; I’m sorry. I’ve lived in several midwest states and think that South Dakota is quite eerily beautiful. I
will not be transferring my life, my career, and my love of well-produced opera to Sioux Falls any time soon.

(5) UNETHICAL: Recruiters who expect you to do their job for them.

My final post will be the most egregious example I’ve found, combined with a horrific example of #6. The most common variety is this:

——————————————————————————————-
To better represent you, kindly fill out the skills inventory below. Thank you

1) Agile/Scrum (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
2) Software Development Proj Mgmt (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
3) Web-Based Application architecture knowledge (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
4) Test Driven
Development / XP (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
5) Java development principals (Beginner/Intermediate/Expert) (Years of experience/Date Last used)
6) Release Management (Beginner/Intermediate/Expert) (Years of experience/Date Last used)

——————————————————————————————-

Remember that I get about 50 or so of these emails per day; this person doesn’t even want to read my resume, and instead wants me to fill out his paperwork for him. Note: this was for a position in California, making it irrelevant anyway.

(6) UNETHICAL: Recruiters who expect you to prep and interview with no information about the company.

This is the worst one. How can I know if I want to take a position if I’m not told: (1)
what the salary will be, (2) where the company is physically located, (3) what benefits are available, and (4) to whom I would be reporting? This is just another version of wasting my time. I don’t talk anymore to recruiters who are secretive; they are occasionally fronts for disreputable companies who want a chance to sell you before you find out what their online reputation looks like.

Next, the traits of successful recruiters.

Third Edition Earthdawn Dice Roller in Java

So, I play an RPG called Earthdawn; it’s a lot like D&D, but for real nerds.

One of the things we all do in my gaming group is write our own dice rollers; rolling actual dice is SO passé–and there’s an ongoing argument about whether or not a seeded random is more or less random than the natural flaws in dice and rolling surfaces. Java is the language in which I learned to write math, so I somewhat naturally write algorithms in Java without thinking. It’s easy enough to translate this into C# or whatever.

Ok, so, here’s the algorithm. In Earthdawn, dice rolls are predicated on the step level of the difficulty. You may have an attack roll at step 18 and a damage roll at step 22. In 3rd edition Earthdawn, that translates to rolling d12+d10+d8 to attack, and 2d12+2d6 for damage. Here’s the chart (click to embiggen):

As you can see, there’s some kind of progression here; it turns out that the algorithm is a simple infinite series. There’s a jump in the number of dice every seven steps. Hence, the algorithm has a few simple steps:

(1) Divide the step number by 7.
(2) Determine and store the floor and the modulus.
(3) Roll a number of d12s equal to (floor – 1).
(4) Roll dice equal to the corresponding modulus (the first addition of dice past the 7 threshold will be 2d6, so if the modulus is 1, 2d6 are rolled and added).

That is the step algorithm such that no lookup is now necessary; Earthdawn has exploding dice and epic
fails, however, so two things are necessary. Look at the exploding dice method; if you roll the maximum value of a die, you can roll it again. You can keep rolling that die until a value shows that is less than the maximum value, such that a d6 rolled with a result of 6 can be rerolled. On the second roll, 6 results. On the third roll, 2 results, so the total value of that die roll is 14. For epic fails, if you roll more than one die and all dice show ones, you have epically failed (similar to a fumble in D&D, and with equivalent disastrous results).

Here’s my dice roller; click to embiggen:

So, here’s the code. It’s intended to be self-contained (you can see that I use a pic of Captain Malcolm Reynolds; just drop a pic in your file structure and reference it in the code if you want a background). Obviously this is bare-bones; you can adapt it at your leisure and to whatever GUI you desire. Any suggestions are welcome; I am always debugging this (and the JavaScript I’m using to display syntax highlighting is a little cranky, so forgive any indentation issues). If you can think of a way to optimize this algorithm, let me know; I always need bragging rights over the guys 😉

package dice;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import 
javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;

@SuppressWarnings("serial")
public class ImagePanel extends JPanel implements ActionListener{

	int six = 6;
	int eight = 8;
	int ten = 10;
	int twelve = 12;
	int dice = 0; //counter for total number of dice
	
	public int middle; //step value entered by me.
	public boolean fail; //whether or not an epic fail happened.
	public JFrame frame;
	public Random r;
	Image img = new ImageIcon("img/MalcolmReynolds13.jpg").getImage();
	SpinnerModel stepEntry = new SpinnerNumberModel(1, 1, 300, 1);
	SpinnerModel karmaCounter = new SpinnerNumberModel(25, 0, 25, 1);
	JSpinner stepSpinner = new JSpinner(stepEntry);
	JSpinner karmaSpinner = new JSpinner(karmaCounter);
	
	private JTextField diceResult;
	private JButton myButton;
	
private JCheckBox myCheck;
	private JLabel enterStep = new JLabel("Enter Step Here.");
	
	public static void main(String[] args) {
		ImagePanel panel = new ImagePanel(new ImageIcon("img/MalcolmReynolds13.jpg").getImage());
		JFrame frame = new JFrame("Tarah's Dice Roller Of Awesomeness");
		
			frame.getContentPane().add(panel);
		    frame.pack();
		    frame.setVisible(true);
	}

	public ImagePanel(String img) {
		this(new ImageIcon(img).getImage());
	}

	public ImagePanel(Image img){
		this.img = img;
		Dimension size = new Dimension(img.getWidth(null), img.getHeight(null));
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);
		JPanel panel = new JPanel();
		add(panel, "Center");
		myButton = new JButton("Roll The Dice.");
		myButton.addActionListener(this);
		myButton.setBorder(BorderFactory.createLineBorder(Color.black));
		diceResult = new JTextField("Roll Result", 9);
		
diceResult.setBorder(BorderFactory.createLineBorder(Color.black));
		myCheck = new JCheckBox("Use Karma.", false);
		myCheck.setBorder(BorderFactory.createLineBorder(Color.black));
		GridLayout myGrid = new GridLayout(3, 2);
		panel.setLayout(myGrid);
		panel.setBorder(BorderFactory.createLineBorder(Color.black));
		panel.add(enterStep);
		panel.add(stepSpinner);
		panel.add(myButton);
		panel.add(diceResult);
		panel.add(myCheck);
		panel.add(karmaSpinner);
		setVisible(true);
	}

	public void paintComponent(Graphics g) {
		g.drawImage(img, 0, 0, null);
	}
	
	public void actionPerformed(ActionEvent e) {
		boolean useKarma = false;
		middle = (Integer)stepSpinner.getValue();
		System.out.println("actionPerformed() thinks the step number is: " + middle);
		if (myCheck.isSelected() == true) {
			System.out.println("Using Karma.");
			useKarma = true;
			int decrease = ((Integer)karmaCounter.getValue()) - 1;
			karmaCounter.
setValue(decrease);
		}
		String s = Integer.toString(rollTheDice(useKarma, middle, fail));
	    diceResult.setText(s);

	} 

/////////////////////////////////////////////
/////////////////MATHYNESS///////////////////
/////////////////////////////////////////////
	
	//This is the Earthdawn Exploding Dice Method.
	public int d (int die){

		int sides = die;
		int result = 0;
        int roll;
    
		do {
			r = new Random();
            roll = r.nextInt(sides) + 1;
            result = result + roll;
            System.out.println("This is a d" + sides + " roll with result: " + result);
       } while (roll == sides);

		return result;
	}
	
	public int oneToSeven (int o) {
		int result = 0;
		if (o == 1) {
			result = d(six) - 3;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 2) {
			result = d(six) - 2;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 3) {
			
result = d(six) - 1;
			if (result < 1) {
				result = 1;
			}
		}
		if (o == 4) {
			result = d(six);
		}
		if (o == 5) {
			result = d(eight);
		}
		if (o == 6) {
			result = d(ten);
		}
		if (o == 7) {
			result = d(twelve);
		}
		return result;
	}
	
	public int prefix (int p) {
		int prefixTotal = 0;

		for (int i=1; i= 8) {
			int d12s = prefix(full);
			int rest = suffix(mod);
			result = d12s + rest;
			
			if (result == full+1) {
				fail = true;
			}
		}
		return result;
	}
	
	public int rollTheDice(boolean addKarma, int stepValue, boolean epicFail) {
		boolean addK = addKarma;
		dice = 0;
		int result = 0;
		result = step(stepValue);
		epicFail = fail;
		if (addK == true) {
			int dK = d(six);
			result = result + dK;
			if (epicFail == true && dK == 1) {
				JOptionPane.showMessageDialog(frame, "Epic FAIL.");
			}
		}
		else if (addK != true && epicFail == true) {
			JOptionPane.showMessageDialog(frame, "Epic FAIL.");
		}
		return 
result;
	}
}

The IDE Wars: NetBeans or Eclipse for Java Software Development

I’ve been working on several applications for a few years; some are ready or released into the wild. I’ve used NetBeans and Eclipse to develop one application in particular; I’ve written an Earthdawn dice roller application. Earthdawn is like Dungeons & Dragons, but for real nerds. The Earthdawn dice system is complex, including a shifting iterated seven-step algorithm for determining the dice rolled for a given action. In addition, dice explode in Earthdawn. That means that if a given die results in its maximum value (i.e. a d6 result is a 6 or a d12 result is a 12), you reroll the dice and add that to the total, continuing to reroll if the die continues to result in its maximum value and stopping when it does not. Plus, you also have the option of adding a karma die (dependent on race, like Elf or Dwarf) to any roll which permits it.

Obviously, this is a complex system, and dealing with the RNG was not the hard part. The hard part was
figuring out the algorithm by which you can calculate the dice you would roll for any given step. For example, rolling a step 10 means that you roll a d8 + d6. Rolling a step 20 means that you roll 2d12 + d10. You can find this on a chart in the 3rd Edition Earthdawn Player’s Guide, but it actually took doing a Taylor series to determine that there is an algorithm which repeats every 7 steps. This means that my app can calculate what you’d roll for a step 63 dice roll, when the book doesn’t provide a chart that high.

I’ve been fiddling with this app for a year or so, and while I’ve been developing the backend in Eclipse, I found that the frontend needed some serious help. I looked around for an IDE specifically to develop the frontend of a Java app, and NetBeans turned out to be full-featured enough to develop in much the same way that I’d dev a C# app in Visual Studio 2010. I’m an old school algorithm coder, and I don’t do as much frontend app development, as opposed to my long term work in
frontend web development. In fact, most of my experience in frontend app development is in VS from 2003 on. So, believe it or not, I was looking for an IDE experience closer to VS.

NetBeans is open source; I found that specifically for the purpose of frontend Java software development, it’s a far better IDE than Eclipse. While Eclipse works better for academic algorithm coding, NetBeans is tailor-made for someone who wants to turn out an app with a backend; in fact, I coded the backend over rather a lot of time in Eclipse to test it with multiple RNGs developed at CERN, Argonne, etc, and simply copied over the relevant classes into NetBeans to hook them up to the frontend. I’d actually recommend this as the most efficient experience if you’re trying to create a complex backend with a simple and effective frontend…especially if you have an app that needs a frontend instead of a script. NetBeans has a simple application package process as well, if you need to pack up the app and send it out. I have
Ubuntu, OpenSUSE, Windows, and Mac users in my group, and Java will execute on each of those platforms.

I’ll also shortly be posting the app so you can examine it for yourselves 😉