Neal Sheeran

Rants, Raves, and Geekery

Resources for Octopress

Permalink

Octopress is the “blogging framework for hackers”, and while I’m certainly no hacker, I do enjoy learning about how it works and bending it ever-so-slightly to my will. Here is a list of resources that I have found useful for using this excellent platform.

  • Obviously, the official documentation is a good place to start
  • Developer Brandon Mathis has always been responsive via the @octopress twitter account
  • The “official” support channel is a mailing list on Google Groups. I get summaries emailed to me weekly
  • Many fine folks have saved Octopress links to Pinboard. My specific links are here
  • If you run into issues, maybe someone else has. Check out the Octopress tag at Stack Overflow. You can subscribe to these via email as well.

I also use to follow the Issues tab of the Octopress GitHub repository. Brandon has since closed it so he can focus on the next release, which for months has been “2.1”, but will actually be a “3.0”. I’m excited to see what is in store.

W3 Total Failure — the Brooks Review »

Permalink

When I first started with WordPress, I knew one thing to be true: I needed caching. A WordPress site without caching is a site waiting to go down.

And then multiple issues about different cache plug-ins. Wouldn’t it be cool if you could avoid it altogether (not to mention the the security problems) and just have the ability to easily publish static HTML? Man, that would be so awesome…

Burglars Unwittingly Put Victim in Gun Closet; He Comes Out Shooting »

Permalink

The unidentified man was in his Houston home on Tuesday when three burglars suddenly kicked in the door, beat him up, and put him in an upstairs closet.

Little did they know, that closet just so happened to be where the man kept his guns.

Well, well. Enjoy spinning this one, gun control advocates.

My Sublime Text 2 Setup

Permalink

Consider this my obligatory Sublime Text 2 post. ST2 has become my editor of choice (over BBEdit, among others) based on how powerful it can become through the use of plug-ins. Here a few of mine that I find useful.

FileDiffs

Package to quickly find the differences between two files with a user-defined keyboard shortcut. Normally, a new tab will open that identifies the changed lines. I have actually turned this off because the awesome aspect of this plug-in is the ability to set up an external diff tool. I use the not-cheap, but excellent Kaleidoscope. When I select Shift-Ctrl-F, and choose what I want to compare the open file to, Kaleidoscope opens immediately with much better visual indications of what exactly has changed. Very useful. 1

MarkdownEditing

Standard Brett Terpstra greatness for writing Markdown in Sublime Text. Auto-pairing of Markdown characters, keyboard shortcuts for pasting Markdown links, and a special color scheme just for Markdown files. Also recommended if you are a Marked user is the Marked Bonus Pack, which includes a Sublime Text Build System to quickly preview a Markdown file in Marked. If you are not a Marked user, well… see the next tip, but you should really get yourself checked out.

Markdown Preview

A very simple package that gives some nice Markdown preview options, in a browser window or a new tab with generated HTML. I use Option-m for the former, and it is quite fast.

SmartMarkdown

Have your cursor sitting in a Markdown header? The Tab key will fold all the text beneath that header. Shift-Tab will fold all the headers in a document, regardless of where your cursor is. There are also shortcuts for navigating through different headers and increasing/decreasing their level.

SCSS

Write Sass? This gives you syntax highlighting for .scss files. Another somewhat-related tip: I use Bryan Jones’ excellent app, CodeKit to generate all my Sass files. CodeKit also has its own Kit language to create HTML partials. In order to get .kit files to have HTML syntax highlighting, go to the HTML package in the Package directory and find the HTML.tmLanguage file. In the fileTypes array near the top, add this line: <string>kit</string>. Done.

PlainTasks and SublimeTODO

Two excellent plug-ins for managing projects in Sublime Text 2. I wrote about them here.

Git, SideBarGit and Git Gutter

All great plug-ins for integrating git into Sublime Text. I especially like Git Gutter. It adds small symbols in the gutter that indicate added/deleted lines since the last commit.

Origami

Keyboard shortcuts for creating new editor panes and sending documents back and forth between them. The keyboard shortcuts take a bit to become second nature, but definitely worth it.

ReadmePlease

After you have installed all these plug-ins, use this one to quickly get access to any installed plug-in’s README file.

Themes and Color Schemes

I have to yet to find the perfect theme for ST2, but currently I’m running the Flatland Dark theme, along with its color scheme. Phoenix is another great theme with a lot of options and more often than not I find myself using the dark version of the default Solarized color scheme.

My current User Preferences file is in a Gist here 2, and if you are new to Sublime, this free screencast series at Tuts+ is excellent.

  1. I followed the directions to use Kaleidoscope with the plug-in here, but the app would not open. I believe with Kaleidoscope version 2, the app now places the command line utility ksdiff in /usr/local/bin. In my FileDiff User Settings file, I had to explicitly set the path to ksdiff as follows: "cmd": ["/usr/local/bin/ksdiff", "$file1", "$file2"], rather than creating a symlink to usr/bin as described in the wiki.

  2. Spaces, not tabs. Two of them.

Posting to Octopress, Part 2

Permalink

Shortly after I converted this blog to Octopress, I came up with some Keyboard Maestro macros to automate the rake tasks to create posts and generate/deploy the site. I have moved away from that workflow for a few reasons:

  • I had to come up with a post title right off the bat. Sometimes the title comes to me at the end. Granted, the actual title of the post is driven by the YAML title, but the URL for the post comes from the filename.
  • I didn’t like having drafts living in my _posts folder. An errant rake generate could publish a draft if I wasn’t paying attention. Yes, one can put published: false in the Yaml front matter, but one more thing I would have to go back and change. I also have a Hazel rule that archives and tags entries that would trip before I even added a category.
  • Creating an ‘elsewhere’ post involved a lot of copying/pasting: URLs, titles, quotes…you can probably guess where this is going.
  • No mechanism to write a post on an iOS device.
  • I didn’t have a KM macro to push to my git repository. Another extra step.

So rather than wrap some duct tape around my KM macros to address these issues, I started over, with some help from others. My new writing and posting process is based on the following:

  1. The Octopress _posts directory should be a final, ‘canonical’ destination. A markdown file only goes there when it is about to be published.
  2. Be able to draft a post using any text editor on my Mac. My previous KM macro was tied to Byword.
  3. Even though I write the majority of these posts on my Mac, have the ability to draft a post on an iOS device
  4. Pave the way to easily publish a post from a iOS device.

Tools I use to do this: Text Expander, Drafts App, Dropbox, and Hazel

Local Drafts

Some blog posts start in nvALT as a few random snippets and some links. For others, I fire up MultiMarkdown Composer. I usually don’t care about the YAML front matter until the very end. Or maybe I dump it in first. If the latter, I need to go back and change the YAML date. Here is the Text Expander snippet for basic YAML front matter (triggered by .opnp):

---
layout: post  
title: "%|"  
date: %Y-%m-%d %H:%M  
comments: true  
external-url:  
categories: []  
---

The same date/time string is in a standalone snippet to just update the date for a draft right before publishing: .opt --> %Y-%m-%d %H:%M. I save these files to the desktop with any filename, and an extension of .txt or md. When it comes to time to publish, another TE snippet is triggered with .opf, and the cursor is ready to type the rest of the filename:

%Y-%m-%d-%|.markdown

Files don’t get the .markdown extension until they are ready for publishing, for reasons I’ll get to shortly.

For an ‘elsewhere’, or linked-list post, I am indebted to Doug Rice of Jarhead for the following Text Expander snippet:

---
layout: post
title: "%snippet:safaricurrentpagetitle%"
date: %Y-%m-%d %H:%M
comments: true
external-url: %snippet:safaricurrentpageurl%
categories: [elsewhere, %|]
---

> %snippet:safaricurrentpageselectedtext%

Text Expander 4 can call snippets from within snippets, and this one will automagically look at the front-most tab in Safari and put the page title and the URL in the front matter, as well as the URL. Any selected text is added as a blockquote. The cursor ends up in the category array, ready to add any additional ones.

While my ‘normal post’ snippets works on my iPhone, the linked-list version does not, as the three sub-snippets are actually AppleScripts.

Drafting Posts on iOS

Drafts App for iOS is the obvious choice here. I have an action called “OctoPost” that will send the draft post to a folder on DropBox. I have the filename set to the following predefined format:

[[date|&Y-&m-%d]]-[[title]].md

Drafts can accept strftime strings for the date component of a proper Octopress filename, and can set any desired extension, but there isn’t really a way that I can see to set the rest of the file name, which becomes the URL.

The [[title]] snippet above takes the first line of the draft, but a normal Octopress post needs the YAML front matter to be first: ---. As written, this draft will need a title in the first line that would subsequently need to be moved to the appropriate YAML line (or deleted).

Publishing

Hazel rules for the win. The focal point for publishing posts is a ‘launch’ folder on my Desktop called OPDRrafts. Any files from the Drafts App folder get copied to this folder. This desktop drafts folder has two primary rules:

This changes the color label of the folder red, as an alert that a new draft is present. The Apple script is needed to make the folder change itself and is as follows:

tell application "Finder"
   set posix_parent_dir to POSIX path of (container of (item theFile) as text)
end tell
return {hazelSwitchFile:posix_parent_dir}

The second rule does all the heavy lifting. When a post is finished, I change the extension to .markdown to trigger the rule:

The rule moves the final markdown file to my _posts directory and then executes a shell script:

#!/bin/bash
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

# First try to load from a user install
 source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

# Then try to load from a root install
 source "/usr/local/rvm/scripts/rvm"

else

 printf "ERROR: An RVM installation was not found.\n"

fi
cd /Users/me/Code/octopress
rvm use 1.9.3@octopress
git add . && git commit -m "New Post" && git push origin 2.1 && rake generate && rake deploy;

The key action is the last line, which comes from Alessandro Nadalin and conveniently commits the change locally, pushes the changes to my git repo, generates and deploys the site. With a nifty Growl notification telling me so.

Summary

  1. Write posts either locally, or with an iOS device, using Text Expander snippets for YAML front matter and to create file names. Local files can be anywhere, and iOS drafts will get put in the ‘launch’ folder.
  2. Once complete, change the extension to 'markdown and if required, drop the file into the desktop ‘launch’ folder.
  3. About 90 seconds later, the post is published on the site.
  4. A second copy of the post is archived and tagged with Open Meta tags.

If you have an always-on Mac such as a Mac mini, you could easy publish a post to your site with nothing but an iPhone or iPad using Dropbox and Hazel rules, but there is the issue of getting Drafts app to name the file correctly. Of course, an iOS editor such as Byword or Writing Kit that connects to Dropbox and allows complete control of filenames fixes this.

Clayton Kershaw Homers, Tosses Shutout to Lead Dodgers Past Giants »

Permalink

Pretty great opening day for Clayton Kershaw. Wanna know why baseball is better than the NFL and their stupid halftime shows and silly gimmicks? Here’s why:

Dodgers co-owner Magic Johnson was the mound before the game when manager Don Mattingly came out and signaled for a reliever. In came Koufax to throw the first ball to former Dodgers ace Orel Hershiser.

A few minutes later, the crowd looked toward Vin Scully’s booth, where he began his 64th season, and the revered broadcaster pronounced: “It’s time for Dodger baseball.”