The slides for this talk are available on my GitHub if you want to follow along.
Today I decided to switch to iTerm2 on OS X. Shortly after making this decision I was frustrated by not being able to “jump” between words with the option-arrow shortcut. Fortunately, the solution is rather simple — just modify the option-left/right arrow shortcuts in Preferences > Profiles > Keys. The “Action” should be “Send Escape Sequence” + b for jumping backwards and f for jumping forward, (e.g.,
I know I’ve tried iTerm in the past, and I’m pretty sure not being able to do this right away kept me from continuing to use the tool. After making this change everything has been swell, though.
I’m very pleased to announce that I’ll be speaking at the 2013 JAMF Nation User Conference in Minneapolis, MN. I’ll be discussing my experience with hosting the JSS on Amazon Elastic Compute Cloud (EC2), along with any lessons learned during the process, (of which there are many).
The three day conference is being held at the Guthrie Theater from October 15-17. Hope to see you there!
The other day I was presented with the challenge of determining whether Guest login was enabled on 150+ Macs. Fortunately, my client was using the Casper Suite, so I was able to whip up an Extension Attribute rather quickly. Here’s what I came up with to get the status:
Have you ever needed to run a quick download speed test, but were too lazy to open up a new browser window and use one of the Web-based tools? Or perhaps you just prefer to use the command-line like me. Never fear, because appending this line to your ~/.bash_profile will allow you test your download speed from within your login shell by simply typing
Having recently made the decision to migrate my blog from WordPress to Octopress I decided I would share my findings in hopes that someone else will benefit from them, and so I can refer back to this post should I need to do something similar in the future.
The primary reason I decided to move to a statically generated site is because I found myself spending more time worrying about whether my site was running and was secure than I did writing. My site was hacked last year because I was running an outdated version of WordPress, and since moving to a new host, (Amazon EC2), I have frequently had to restart MySQL and Apache just to keep the site up. This could be partially due to the fact that I was running the site on a micro instance, but now that my blog is static I don’t have to worry about that any longer. Another reason why I chose Octopress for my blogging platform is that I like to tinker, and being able to use tools that I’m already familiar with and use every day was a huge plus, (Vim, Git, and Markdown, specifically).
So, without further ado1, here are the steps I took to mirgrate from WordPress running on an Amazon EC2 instance to Octopress running on Heroku.
Prepping Your Environment
I performed the migration using a fairly stock OS X 10.8 machine. If you’re using a Mac, you should probably be using Homebrew to manage packages.
1 2 3
The next thing you should do is add the following to your ~/.bash_profile.
1 2 3 4 5
Now install Ruby 1.9.3 with rbenv.
1 2 3 4 5 6 7 8
Setting Up Your Local ~/Sites Directory and Installing Octopress
On OS X 10.8 the ~/Sites folder no longer exists in the home directory by default. No problem though, because we can create it, and we’ll even get the correct permissions and pretty icon when we do so.
I also recommend checking out Anvil for Mac. This will allow you to easily manage your local site and give you a .dev domain for testing. Best of all, it’s free.
1 2 3 4 5 6 7 8
If you took my advice and installed Anvil for Mac, do the following to create a symlink to your site in the
1 2 3 4
Use rack-rewrite for Redirects
This is useful for redirecting old URLs to your new Octopress site, especially if you used date-based permalinks for archives on WordPress, (something like example.com/2012/02/22), and you want those to redirect to /archives on your new site.
Add this to the end of your Gemfile.
Add this to config.ru.
$root = ::File.dirname(__FILE__) in config.ru add your redirects, (these are just some examples). Of particular interest are the regular expressions that redirect dates in yyyy-mm-dd format to /archives.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 2 3 4
Now restart your local server, (turn the slider on and off with Anvil).
Create _heroku Directory for Deployment
I opted to keep the generated Heroku site in a separate repository so I can keep public in my .gitignore. This will help keep your commit history clean, as not (nearly) every file that Git is tracking will change every time you re-generate your site.
1 2 3 4 5 6
Create an HTML file in _heroku/public so you can deploy to Heroku.
Make the Gemfile in _heroku only include these lines.
1 2 3 4
Add this task to your Rakefile. This will result in your site being deployed to Heroku when you type
rake deploy. Don’t run
rake deploy at this time, though, because you haven’t set up Heroku yet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
…then update these variables, (in your Rakefile).
1 2 3
Signing up for and Configuring Heroku
1 2 3 4
Now you can do your first deploy to Heroku!
1 2 3 4 5 6 7
Exporting your WordPress Posts and Comments
Log on to your WordPress Admin and export your content in XML format. You can find this under Tools > Export. Keep this data handy because we’ll be using it in the next step.
The next steps I took were to sign up for a free Disqus account, install the (Disqus) WordPress plugin, and export my comments to Disqus from the plugin options. This will ensure that your comments are preserved after migrating to Octopress, (as long as your permalinks don’t change). Also be sure to add your Disqus shortname to _config.yml.
Importing your WordPress data into your Octopress Site
There are a number of tools available for importing your WordPress posts into Octopress as Markdown files, but the one I ended up using was exitwp. You can follow these steps to import your WordPress site with exitwp.
1 2 3 4 5 6 7 8 9 10 11 12 13
Now, copy your WordPress XML files to ~/Documents/exitwp/wordpress-xml, then run
xmllint on your export file and address any errors you encounter. You should also customize what you want exported in ~/Documents/exitwp/config.yaml, (e.g., whether or not you want images to be downloaded and included in your build directory). To run the tool type
python exitwp.py in the terminal from within the ~/Documents/exitwp directory.
You should now see your converted site in ~/Documents/exitwp/build, which you can copy to your source directory.
Remove /blog/ from Octopress URL
Follow these steps if you don’t want /blog/ to appear in your Octopress URL.
Update the permalink setting in _config.yml.
Move the contents of the blog directory.
1 2 3
Update the navigation in source/_includes/custom/navigation.hmtl.
1 2 3 4 5 6 7 8
Update the Archives link in source/index.html.
1 2 3 4
Update the category base URL in _config.yml.
1 2 3 4 5 6 7 8
Update the Archives page title in source/archives/index.html.
1 2 3 4
Change Author Name After Importing from WordPress
Another thing that bothered me for a while about my WordPress blog was that the author metadata for posts and pages reflected the ‘admin’ shortname. This is because I left the default username when initally setting up WordPress years ago. I’m sure there’s an easy way to change this, but now that my blog consists of plain text files I have the freedom to use whatever tools I choose to make changes. Here’s a perfect example of that using find and sed.
Using Google Fonts
If you love Google Fonts add this to the top of
source/_includes/custom/head.html, (just be sure to use your own favorite fonts!).
Prevent Comment Text from Wrapping on Small Screens
One of the first things I noticed with the default Octopress theme is that the Disqus comments text that appears above posts was wrapping on smaller screens, which caused it to overlap with the post title. To fix this, I added the following to sass/custom/_styles.scss.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
You might also want a custom 404 page. Fortunately, that’s pretty easy too.
1 2 3 4 5 6
Then update the yaml front matter in 404.markdown.
I followed a post on Ewal.net to get Fancybox working with Octopress. The only difference is that I didn’t add a reference to jQuery in the head because it’s already present in the default installation of Octopress.
To add Fancybox support to an image simply add this to your post.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Open Vim when running rake new_post and make new posts un-published by default
Add the following to your Rakefile if you want
rake new_post to open in your editor and new posts to be un-published by default. Replace Vim with your favorite editor if you dare. :)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
Here are the relevant Heroku commands. Don’t forget to update the
url: in _config.yml one last time, (e.g., remove herokuapp from URL).
Yes, I spelled that correctly. Google it.↩
For the past few months I have been drawing every day on 2.5 x 3.5 inch pieces of Bristol board as part of my most recent ‘kooBtrA’ project. kooBtrA = ArtBook in reverse, as I plan to self publish a full-color book containing all the images sometime after one year passes.
As you might imagine, finding the time to draw every day can be challenging. Not to mention the fact that I’ve also been posting these images to my Tumbleog; which includes scanning, resizing, and logging into Tumblr to post the image along with a description and tag. This became mundane after the first few days of posting, so I decided to set time aside to automate this process, as doing so would surely save me time in the long run.
I did a bit of research and discovered that Tumblr offers the ability to send posts via email. This immediately gave me the idea of using Automator) to streamline this process, as Automator offers a very straightforward ‘New Mail Message’ Action. This would allow me to create an Image Capture Plugin that grabs the image that was scanned and include it in the email message, right? Well, yes, but with one caveat. With Snow Leopard’s introduction came a few changes, one of which removes the ability to scan to a specified folder while using an Image Capture Plugin, (the image is saved to the ~/Pictures folder, then the Workflow runs). The workaround in my case was to use a Folder Action, which would result in the Workflow running any time a new file is added to the specified folder.
What I had been doing until this point was scanning the image to a subfolder of my ~/Documents folder; scaling the image to 300px max on either side depending on orientation; then uploading the image to Tumblr.com along with a description and tag. The Folder Action Workflow I ended up producing cuts the time this took in half.
The first thing I did was create two variables. One for the name of the post and one for the number of the post. You can achieve this by right or control clicking in the variables window at the bottom of the application window and choosing ‘New variable.’ I left the value blank, as this will vary with each post. The next step was to start dragging actions over to the right of the application window. The first is an ‘Ask for Text’ Action, which asks for the name of the post, then sets the value of the variable. The same goes for the number of post. The Workflow then asks for the Finder items to act on, then copies them to a new location and scales them to 300px. Finally, the ‘New Mail Message’ Action is added, which utilizes the name and number variables that were set previously, as well as receives the resized image from the previous Action. The last Action that was added was ‘Send Outgoing Messages,’ which is fairly self explanatory.
Below is the printed Workflow for your reference should you wish to accomplish something similar. If you have any suggestions as to improving this Automator Workflow please leave a comment. For more information regarding Tumblr’s post via email option please visit http://www.tumblr.com/docs/en/email_publishing.
Last week I was presented with a problem that involved restoring a MySQL database for a client using only the
/data folder from an original MySQL installation. The solution turned out to be rather simple, but that didn’t stop me from racking my brain for a few hours. Thus, I thought I’d share my experience in hopes of helping others that may run into this.
NOTE The MySQL database I was tasked with restoring was associated with a WordPress installation. My guess is that this is irrelevant, though.
I made the decision early on to solve this problem locally, (I find that working directly from a web server usually just gets me into trouble). I use MAMP on a regular basis and as such have quite a few MySQL databases associated with that installation. Rather than fooling with this at all I opted to use XAMPP on a Windows XP SP2 machine. Either one of these solutions will work, as they essentially provide the same services. I chose to avoid using MAMP on my machine because of everything I have invested into that application, but that doesn’t mean you have to.
The first thing you’ll want to do is install a fresh copy of either MAMP, (Mac only), or XAMPP. Then create an empty database using phpMyAdmin with the same name as your original database, (the one you’re trying to restore). For example, if your previous database was called ‘wordpress,’ in phpMyAdmin, (under the ‘Create new database’ text field), you would enter ‘wordpress.’ This will create a folder named
/Applications/MAMP/db/mysql if you’re using MAMP, or
C:\xampp\mysql if you’re using XAMPP. At this point you’ll want to turn off the MySQL service. Now, copy the contents of, (not the entire folder), your mysql database folder that contains the .frm files to the new location. The next step is to copy the
ibdata1 file to the MySQL folder in either XAMPP or MAMP, then start the MySQL service again. Now you should be able to locate your database tables in phpMyAdmin.
At this point, (assuming you don’t want to keep the data locally on your machine), you’ll want to export the database using phpMyAdmin. Be sure to check Add DROP TABLE, choose SQL as the export type, and check the ‘Save as file’ checkbox. The .sql file that will be generated can easily be imported into another instance of phpMyAdmin. The new database doesn’t need to have the same name as the previous database, either. I was unable to use my previous database name because the site I was working on had been moved to a shared hosting server, (where someone had already chosen the name of my previous database), and everything worked fine.
Also keep in mind that this can be accomplished whether or not your server is running phpMyAdmin. There are plenty of alternatives available that will allow you to accomplish the same tasks, and there’s always the command line. The most important step is to simply copy the contents of the
/data folder and the
ibdata1 file. Hope this helps!
Leave a comment if you have any questions!
The kind folks at Pages Bookstore have invited me to do a book signing and give a short talk on comics production on May 8, 2010. The event will be taking place from 1-3 pm in downtown Flint, MI. If you’re in the area stop by to pick up one of my short comics and chat with me for a bit.
The promotional poster I did for the event can be found in the portfolio section of this site.