Zapier Named Variables - Scheduling Posts Part 2

Written by Pete Corey on Jan 5, 2015.

Last time, I talked about using Zapier to schedule Jekyll blog posts with Github Pages. I briefly touched on how I wished that Zapier had some kind of string manipulation functionality to help pull a schedule date out of the git commit message. Not long after the post went live, @zapier sent me a link that helped me accomplish exactly that.

Named Variables

Named variables in Zapier allow you to break apart your trigger data into multiple fields accessible from within your zap. In our case, named variables allow us to specify our Scheduled field anywhere within our git commit message and then use it when creating our Google Calendar event.

Integrating named variables into the scheduler zap was incredibly simple. First, push a git commit with the Scheduled variable somewhere within the commit message:

Scheduling this post for Monday, the 5th at 9 in the morning.

Scheduled(1/5/2015 9:00AM)

After the commit has been pushed to Github, I edited the scheduler zap and in step 5, changed the Start and End Date & Time fields from using Commit Message to using Commit Message Scheduled.

That’s it! Now, my git commit messages can contain useful information as well as scheduled dates which can easily be parsed out and used by Zapier.

I’ve shared an updated template of this zap. You can grab it here.

Scheduling Posts with Jekyll, Github Pages & Zapier

Written by Pete Corey on Dec 29, 2014.

I’ve written a few times about using Jekyll and Github Pages as my blogging stack. So far, I’ve been very satisfied with this setup except for one pain point. I’m unable to easily write posts and schedule them to go live at a later date… Until now! While I could have written and hosted a script or two to accomplish what I was after, I wanted to take a different approach. I ended up using Zapier to automate the publishing of posts at future dates.

The Game Plan

The basic idea behind using Zapier to schedule future Jekyll posts with Github Pages is two part. First, create a git branch that holds commits for posts you want scheduled for release. A zap listens for commits pushed to this branch and creates a Google Calendar event at the date and time you want to schedule the post to go live. A second zap listens for these calendar events to start and creates an instant-merging pull request into master from the post’s commit.

Scheduling Posts

The first zap will listen for commits to a specific branch (I called mine scheduled) on a Github repository.

When a commit is pushed, Zapier will create a Google Calendar event at the date and time specified in the git commit message. It will also store the SHA identifying the commit in the location attribute of the calendar event.

It’s important to note that scheduling posts in this way means that the only text you can put into your git commit message is the date and time the date will go live. Actual commit messages may give unexpected results.

I’ve shared a zap template for this step.

Merging to Master

The next step of the process happens when the Google Calendar event starts (when your post is scheduled to go live). A second zap is triggered when this event starts. The zap pulls the post’s SHA from the location attribute of the event and create a Github merge request into master. By making the merge an “instant merge”, the commit will immediately be pulled into master, which in turn causes Github to rebuild your Jekyll site.

I’ve shared a zap template for this step as well.

On Zapier & Final Thoughts

Sure, I could have implemented this as a shell script or simple program in a variety of ways, but I think that Zapier is a really elegant solution to this problem. The way Zapier composes webapps together is very interesting, vastly useful and can come with some unforeseen benefits. For example, using Google Calendar as the driver of my scheduling system has an added benefit of giving me a nice user interface to modify release dates of posts before they go live. I could also easily trigger things like tweets, emails, etc. to be send when a post goes live.

I did find myself wishing that Zapier came with a few string manipulation features. Instead of dumping the entire git commit into the calendar’s schedule date, I was hoping to slice out only a portion of the commit message, or use the last line or something. Maybe this kind of functionality will come in the future, or maybe it already exists and I just couldn’t find it. See my followup post on using named variables to extract a schedule date from the git commit message.

As a proof of concept, I’ll be scheduling this post to go live on December 29th, 2014. See you then!

Hide Menu: My First Sublime Text Plugin

Written by Pete Corey on Dec 24, 2014.

My new bspwm setup currently doesn’t have a pretty GTK theme installed, so the menu in Sublime Text looks fairly unattractive. With my workflow, whenever I open Sublime Text (subl .), the menu is always shown, regardless of if I hid it during my last session. So what’s the solution to hiding the menu at startup? Find a plugin, of course! Oh, there are no plugins that do this? Write a plugin, of course!

My current bspwm setup

Building the Plugin

Unfortunately, I’ve never written a Sublime Text plugin. Thankfully there are many resources to help out a person in my situation. This post explained how to create a new Sublime Text plugin. This one showed how to run code when Sublime Text is started. And finally, this guy gave me the command I needed to execute to toggle the menu visibility. After testing everything out, I researched how to submit the plugin to package control, and made my pull request. The final result is available via package control, on github, and the incredibly simple code is below:

import sublime
import sublime_plugin


def plugin_loaded():
    window = sublime.active_window()
    window.run_command("toggle_menu")

Problems…

Unfortunately, the plugin has its issues. As mentioned here, with some workflows, Sublime Text will remember the state of the menu’s visibility and the toggle_menu command issued by my plugin will show the menu instead of hiding it. As far as I know, there is no way to either detect if the menu is visible before issuing the toggle, or sending some kind of “set visibility” command rather than a toggle. I’ve opened an issue about this on the project’s github. If you have a solution or any feedback about it, please leave a pull request/comment.