Mentoring at Code with me: Portland

I am really excited to be on the list of awesome mentors for the upcoming Code with me workshop in Portland. There are a few things that make code worth coding to me and this easily covers a couple of them.

First, I like to see impact. Sitting down and typing a bunch of code is often fun, but it’s really fun when you know that the thing you are working on is going to better another thing for somebody else. The journalists attending this workshop will walk away with some piece of knowledge that will be directly applied to bettering somebody else’s thing. That’s cool.

And second, I really dig the art of knowledge transfer. I can’t begin to count the number of times I go into a situation ready to pass on knowledge and walk out knowing more than I did going in. It will be a lot of fun to see what I walk away with here.

If you’re a journalist in the Pacific Northwest, you should totally apply and come teach me some stuff.

In the last 3 months I’ve been hacking away at various Vagrant configurations. A look at uniques in my bash_history is fun:

164 vagrant up
115 vagrant destroy
 42 vagrant halt
 17 vagrant resume
 15 vagrant suspend
  6 vagrant reload

Evolving WordPress Development With Vagrant

Yesterday we tagged version 0.2 of Varying Vagrant Vagrants, an evolving Vagrant configuration with an end goal of providing a system to pass development projects between team members at 10up for easy ramp up on projects. While any development project can be supported, our initial focus is WordPress. If you’re doing any kind of WordPress development, you should check it out. If you check it out and you fall in love, you should think about working with us.

UPDATE 04/12/03: This post is a great intro and provides good context  for the overall Vagrant discussion that’s been happening. Quite a bit has changed in the last few weeks and I would recommend stopping by Hi WordPress, Meet Vagrant for some of the latest fodder. Thanks!

What is Vagrant?

Vagrant is an open source “tool for building and distributing development environments”. Created by Mitchell Hashimoto, it provides a method to automatically provision a headless virtual machine for use with virtualization software such as VirtualBox. The various configurations of these virtual machines are sandboxed away from your local machine.

What is VirtualBox?

VirtualBox is open source virtualization software from Sun Microsystems. It provides a method to handle these prepackaged virtual machines, or boxes, that are configured with Vagrant.

What is Varying Vagrant Vagrants?

Varying Vagrant Vagrants is an exploration into the world of of Vagrant and how it can help to make development efficient and in sync with production systems. It replaces the common MAMP or XAMPP setups that we have become familiar with and ensures that all members of the team can develop in the same environment for a project without worrying about the operating system on their local machine.

One development environment is currently provided with Varying Vagrant Vagrants.  This includes Ubuntu 12.0.4 with Nginx, PHP-FPM, MySQL and Memcached. While this does not match every production environment, it has become a very common setup for highly scalable WordPress sites. It is these sites where developing in sync with production can be the most important. The closer we can come to matching the exact environment, the more likely we are to catch bugs and environment specific situations before deployment.

How Do I Get Started?

Getting started is easy, and will more than likely take you less than 30 minutes.

  1. Download and install the latest version of VirtualBox for your operating system.
  2. Download and install the latest version of Vagrant for your operating system.
  3. Clone or download the Varying Vagrant Vagrants repository to a local directory.
  4. Navigate to the new directory and type `vagrant up`

With that, your virtual machine is running. Test it immediately by going to 192.168.50.4 in a web browser. To start working with WordPress, one more step is necessary.

  • Modify your local machine’s hosts file so that `local.wordpress.dev` is mapped to `192.168.50.4`.

Once mapped, visiting `local.wordpress.dev` in your browser will bring up an initial WordPress installation. Follow through that to create your first WordPress development environment in Vagrant. Themes and plugins that you are developing can go into the respective `www/wordpress-default/wp-content/` directories.

From here, you should experiment.

If you are familiar with object caching, the common plugins for working with PECL memcache can be installed. Memcached itself is already installed and running for when you’re ready.

If you start poking around the internal documentation for Varying Vagrant Vagrants, you’ll see quite a few places where you can hook in with customizations of your own to continue to extend the development environment.

What’s Next?

Two goals are driving the development for the next releases of Varying Vagrant Vagrants.

  1. Provide a way to start with one of multiple WordPress configurations. Multisite is an obvious addition, but it would also be nice to include configurations for object caching as well as helpful development plugins.
  2. Provide a way to pass projects around with a Vagrantfile and WordPress configuration included that can help others jump in to assit immediately.

Please feel free to pass along any feedback or issues with the current release via the GitHub issues page. Any input is much appreciated!

If you want to geek out on some context for my Vagrant experience so far, check out these posts:

A WordPress Meetup Introduction to Vagrant – What You’ll Need

Note: I’ll be giving a couple of talks about getting started with Vagrant over the next couple months and I intend for this to be a decent description covering some of the basics those who are attending should complete. If are planning on attending in PDX or Seattle, please read this through and complete the steps as best you can.

I wrote an initial blog post a couple months ago that highlights my fascination with Vagrant and may help give a broad overview of the problem I was trying to solve. Keep in mind that I went from eager excitement to mind blown user of Vagrant within 24 hours. This will be you.

Now, ignore everything there and start from scratch.

VirtualBox

VirtualBox is an open source (GPL) cross-platform (that’s everyone!) virtualization application. Oracle provides a great overview in its first steps documentation here - https://www.virtualbox.org/manual/ch01.html

  1. Download the latest version of VirtualBox (4.2.6) for your operating system and install it on your computer. https://www.virtualbox.org/wiki/Downloads
  2. Download the matching VirtualBox Extension Pack (4.2.6), the same for all platforms, and install it on your computer. Having VirtualBox installed should make this a recognized file type. https://www.virtualbox.org/wiki/Downloads

Vagrant

Vagrant is an open source (MIT) tool that allows you to setup one or multiple development environments on your local machine that are sandboxed away from your operating system. The getting started guid describes it best:

“Vagrant uses Oracle’s VirtualBox to build configurable, lightweight, and portable virtual machines dynamically.”

I’ll go into much more detail during the presentation, but this is a good start.

  1. Download the latest stable version of Vagrant (1.0.6) for your operating system and install it on your computer. http://downloads.vagrantup.com/tags/v1.0.6
  2. Read the overview page of the getting started documentation for Vagrant. If it doesn’t make sense, don’t worry. A familiarity with the terminology will be helpful. Bonus points for every page past the overview section you read. It will all be helpful the second time around. http://docs.vagrantup.com/v1/docs/getting-started/index.html
  3. Additional reading is available under the general documentation section. http://docs.vagrantup.com/v1/docs/index.html

Create a project.

Vagrant is best explained when you are already up and running with it. To best be prepared for the meetup, it would be great if everyone had the following completed.

  1. Somewhere on your computer, decide where you want a local environment to live and navigate to that directory. For sanity, I’m going to use ‘pdxwp-vagrant‘ as the environment directory and ‘development‘ as the directory it will live in on your computer.
  2. Navigate to the containing directory via ’cd development
  3. Clone the varying vagrant vagrants repository with ‘git clone https://github.com/10up/varying-vagrant-vagrants pdxwp-vagrant`. This will create a directory called ‘pdxwp-vagrant‘ in your ‘development‘ directory that contains all of the files we will need to start up vagrant.
    • If you don’t have git available to you by the command line, you can extract the repository’s zip file into a ‘pdxwp-vagrant‘ directory instead.
  4. Change into the ‘pdxwp-vagrant‘ directory and type ‘vagrant up
    • A series of messages will appear indicating that Vagrant is downloading a ~600MB box that will act as the base of the virtual machine that we are building. This box started with a specially packed version of Ubuntu 12.0.4 made available directly from Vagrant’s servers. I then installed nginx, mysql, php-fpm and memcached before repackaging it for distribution. This allows us to skip a lot of the provisioning.
    • Boxes are cached in your user’s home directory under ‘~/.vagrant.d/boxes`. As long as nothing changes with the ‘config.vm.box‘ or ‘config.vm.box_url‘ parameters in your ‘Vagrantfile‘, the box should stay cached on your system until it is deleted so that you do not have to download 600MB every time you start the server.
  5. Once ‘vagrant up‘ has finished, you’re ready to go. By default the IP address of the box is ‘192.168.50.4‘. Add an entry for this IP address to your hosts file that points to ‘local.wordpress.dev‘. This will give you access to a default WordPress install right off the bat.

And you’re ready! At this point, don’t worry about screwing anything up. As long as you have VirtualBox and Vagrant installed and the 600MB box cached to your machine, interacting with the box during the meetup will be a breeze.

See you soon!

Apple TV, AirPlay and Incorrect Expectations

It’s so hard to figure out ahead of time what is supported by this AirPlay stuff. Or at least it was for me it seems. So here’s what I know for some other lost soul stumbling through the damn wilderness one day.

The Apple TV (newest revision as of 01/23/2013) will play audio for music to wireless AirPlay speakers. It will not play audio for videos to wireless AirPlay speakers. The audio for your videos – Trailers, YouTube, etc – is passed through HDMI or the digital audio output connection.

The iPad (gen 3 retina), iPhone 5 and Macbook Air can each be mirrored onto the Apple TV and both sound and video will be passed. However, the audio will follow the same restrictions laid out above and will not be played through your wireless AirPlay speakers but through the HDMI or digital audio output.

I was able to get the Macbook Air, connected to the monitor via HDMI, to stream audio via AirPlay for the video I was playing, but the audio was about 4 seconds off and seemed to be causing the laptop a lot of pain.

Short version – only expect audio from music on any of your devices to play wirelessly. Do not expect audio from video on any of your devices to play properly. If you achieve a different result… please share!

My next step is to try one of these HDMI to HDMI + Audio adapters as I’m trying to do all of this without a real TV, just a DVI monitor that doesn’t support audio over HDMI. Fingers crossed.