Hour ofĀ Code

This weekĀ 15 million students learned to code.

A friend of mineĀ called me Wednesday night to ask if I was available to talk to some of his high school students about Computer Science and hangout while they worked on theĀ Hour of Code. They have no Computer Science curriculum so this could be one of a few times they could experience Computer Science first hand in high school.

I didn’t really know what Computer Science was when I started studying it, so I think getting kids exposed to it while they’re still deciding what they want to study can only be a good thing.

We started by showing a promotional video for Hour of Code.

Then they started programming.

One group got in way over their heads. I noticed right away that they were writing Objective-C, so I asked if they had written any iOS apps, or even had any programming experience. They didn’t. My first thought was that starting with Objective-C without any experience would be pretty hard, but I offered to answer any questions they had. The next time I walked past, they flagged me down. They needed to instantiate an object.

Again, I thought it would be pretty hard to write Objective-C without understanding what Objects are ā€” or, even the basic things you learn in the first week of any programming class. I gave a basic description of objects and helped them move on to the next step.

The next time I walked past, they had a ship flying on the screen and were working on creating a guy to shoot at the ships. They asked me a few more questions throughout the hour or so that I was there and by the end they had gotten pretty far through the iOS tutorial with ships flying back and forth and a guy to shoot at them when you tapped the screen.

It was a fun day answering questions about Computer Science and hopefully convincing a few of them to dig into it some more on their own.

Minneapolis

WordCamp Milwaukee 2013Ā Slides

On June 8, 2013 I gave a talk about automating your WordPress development Workflow at WordCamp Milwaukee. Here are the slides along with some notes.

As I’ve mentioned before, computers are really good at carrying out repetitive tasks and we should use that to our advantage to make development easier.

We all know you should develop locally and on the latest development version of WordPress. But in order to checkout the trunk, you have to use SVN ā€” unless you know about git-svn. You can checkout the entire core repository with:

git svn clone -s http://core.svn.wordpress.org

That’s going to take a while because it is going to download all the WordPress history from forever, but once it’s done it’s just another simple git-svn command to keep it up to date:

git svn rebase

You can also put git repositories inside other git repositories. This is useful so you can use a different repository for each plugin and theme. Just initialize a new repository in the themes or plugins directory and it will work just like normal ā€” even if you’re already using git to manage your development version of WordPress.

Automate your Environment

If you like using a virtual machine for your local development environment, vagrant has to be the way to go. A simple configuration file defines the virtual machine and vagrant, which relies on VirtualBox, takes care of setting it up. Pair that with provisioning software like Puppet or Chef and you’ve got a development environment that you can get up and running with a single command.

Vagrant depends on a Vagrantfile that defines the virtual machine. It’s important to note that the folder that the Vagrantfile lives in will be shared using VirtualBox’s built in sharing on the guest to /vagrant.

Puppet scripts define how a server should look. So, “has apache, php, and mysql installed” is an example. The idempotence of puppet is really cool. You can run a puppet script over and over again and it won’t break anything. If you say a server should have nginx and it already has nginx, puppet will just skip that step. The weird part about puppet, and the thing I found most confusing at first, was that stuff doesn’t run in order. You have to clearly specify dependences because the software is going to optimize your script as much as possible. This gets easier to follow once you work with it for a while.

My current setup is at https://github.com/joshbetz/WCMKE–2013-Vagrant-Puppet

When everything is configured, simply run vagrant up and vagrant will start the virtual machine. Other commands are vagrant ssh, vagrant halt, vagrant destroy, and vagrant provision. SSH is straight forward. Halt shuts down the machine. Destroy removes the machine from VirtualBox. Provision runs the provisioner, whether that’s Puppet, Chef, or a shell script.

This is really powerful. Like your dotfiles, you can put this in the cloud and download the configuration when you need it. And simply run vagrant up to start the machine.

The other nice thing is that our development environments can be open source now. Working together on this stuff is a powerful thing, but I don’t think I have to convince the WordPress community of the power of open source.

Automate your Development

Since we are talking about WordPress development, I’m also going to mention some ways you can make the software work for you while you’re writing code.

  1. Developer Plugin – http://wordpress.org/extend/plugins/developer/
    It’s maintained by Automattic and basically just helps you set up your local development environment the right way. From checking your wp-config.php for the proper constants, to verifying that you’re on the latest development release of WordPress, to recommending awesome plugins that make WordPress development run more smoothly.

  2. Theme Unit Test – http://codex.wordpress.org/Theme_Unit_Test
    This one is maintained by the WordPress Theme Review Team. Even though it’s called the Theme Unit Test, this is useful for all developers. It’s a collection of a huge range of content for you to import into WordPress. Even if you’re developing the next hit plugin, you’re going to need content to test on. There are posts of every post format and any kind of example you could think of.

  3. Underscores.me – http://underscores.me
    Something else that is maintained by Automattic. While it’s technically a theme, I think of it more as a collection of awesome snippets that you can drop into your theme. That’s not to say you couldn’t download this and style it the way you want and be done. It would probably be great as a theme by itself, but there’s so much awesome in here that I just like to scan through the code once in a while and see what new magic I find.

So, to wrap this up, make your computer work for you. Automate everything that can be automated unless you know you’ll never need to do it again. When you do something twice, that’s a good sign that you’ll probably do it again. šŸ™‚

Sublime Text 3Ā Packages

Since I recently switched from VIM back to Sublime Text 3, I thought I’d share some of the packages that I’m using.

While Sublime Text 3 is still in beta, it seems to be stable enough to use. That being said, many of the packages have limited or no support for Python 3 at this point, which is necessary for ST3. Some of the more popular packages have branches on GitHub dedicated to Sublime Text 3 support. You can install those packages through Package Control by first adding the URL associated with that branch as a repository. For example, “https://github.com/weslly/Nettuts-Fetch/tree/st3“.

First, since I came from VIM, I thought it would be nice to use Vintage. I’ve used Vintage in the past and haven’t necessarily loved it though. Luckily, while I was searching for other packages that have Sublime Text 3 support, I stumbled upon Vintageous which has been excellent so far. At this point it’s kind of the reason that I don’t want to go back to Sublime Text 2.

Package Control

I was very happy to find that Package Control works in ST3. There are special installation instructions that involve manually cloning the repository, but nothing too complicated. After the initial install process, everything seems to work like normal.

Theme

Since the theme and color definitions aren’t dependent on a particular version of Python, the old themes and color schemes should still work. As always, I’m using the Soda theme with the Tomorrow Night color scheme. For now, I’m using the Tomorrow Night Eighties variant because it’s so hipster. šŸ˜‰

Languages

Like the themes, language definitions aren’t dependent on a particular version of Python. The additional language definitions I’ve installed are CoffeeScript and Sass.

Other

Lastly, I’m using a few other utility packages that just make life easier.

  • GitGutter: I used something similar to this in VIM and I couldn’t imagine life without it. Basically, it tells you what changes have been made to the current file since the last commit.
  • Alignment: The standard version of this one doesn’t work, so you’ll have to find a working fork. I’m using https://github.com/kevinsperrine/sublime_alignment/tree/python3 and it works so far. This one lines up stuff in your code. I primarily use it on long lists of variable definitions or similar blocks so that all the equals symbols line up, making the code easier to read.
  • Fetch: Another package that needs the correct branch to be manually added to package control at this point. https://github.com/weslly/Nettuts-Fetch/tree/st3 is what I’m using. Since it’s made by Nettuts, I’ll let them explain in their article, Introducing Nettuts+ Fetch.
  • SublimeLinter: While SublimeLinter theoretically works with ST3, I haven’t been able to use it so far. Even though I normally don’t have an issue missing semicolons and such, it’s nice to have a linter watching your code so you don’t waste time tracking down bugs based on syntax errors.