Sam Rayner

Hi, I’m Sam. I design and build apps for iOS and the web. I live in Sheffield, UK and play Ultimate far too much. You can reach me via email or on Twitter.

Sprintly Workflow for Alfred 2

Since the first Alfred 2 beta was released, I’ve been building a workflow for Sprintly, the agile task management web app we use at Terracoding. The basic features are done so here it is for any other Mega Supporters who use Sprintly.

Download Sprintly for Alfred

Using the sly command, you can switch products, list, add and manage items. Full documentation is on Github.

NOTE: The workflow requires a system Ruby ≥ 1.9. If you haven’t upgraded to Mavericks yet version 1.0.1 will work with RVM.

To install, run sly setup {email} {api_key}.

Screenshots

Feel free to make a pull request on Github or let me know what features you would like to see on Twitter: @samrayner.

Hopefully in the future there’ll be an update mechanism for workflows, but until then keep an eye on the repo for changes. I’ll keep the download link above up-to-date.


Using Ruby 1.9 with Alfred

I’ve been building a Sprint.ly Workflow for Alfred 2 (currently in beta) and wanted to use it as an opportunity to brush up on my TDD and Ruby-foo.

Alfred 2 let’s you run PHP, Python, Perl and Ruby scripts but they run from usr/bin/lib and Mountain Lion ships with (a pretty outdated) Ruby 1.8.7.

If you have a newer version of Ruby installed with RVM or rbenv, here’s how to bootstrap Alfred to use it instead. In your Workflow, set up a Ruby script action as normal and fill it with:

SCRIPT_FILE = "example"

def ruby_exec_path(manager)
  begin
    ruby_path = `~/.#{manager}/bin/#{manager} which ruby`
    if $?.exitstatus == 127
      raise Errno::ENOENT
    end
  rescue Errno::ENOENT
    ruby_path = ""
  end
  return ruby_path.strip
end

ruby_path = ruby_exec_path("rvm")
ruby_path = ruby_exec_path("rbenv") unless ruby_path.length
ruby_path = "ruby" unless ruby_path.length

parent_dir = File.expand_path(File.dirname(__FILE__))
puts `#{ruby_path} "#{SCRIPT_FILE}.rb" "{query}"`

This fetches your active Ruby and runs the script example.rb, passing the Alfred query as an argument.

Create example.rb in your Workflow directory and you can grab the query string inside it:

QUERY = ARGV[0]

Anything your file puts into STDOUT will be passed back to Alfred to use in your Workflow!

As well as letting you use The New Ruby Hotness, this has the added benefit of moving code out of Alfred and into files that are more easily tested and version controlled. The only down-side is that your Workflow will require users to be running RVM or rbenv if you share it.


Update (Aug 4): Good news! OS X Mavericks is set to ship with Ruby 2.0 by default so you shouldn’t need to use this hack for much longer.


Quick Tip - Previewing Icon Designs

Previewing an icon while editing in Photoshop

When designing an icon in Photoshop (or your illustration app of choice), a neat way to preview it downscaled to its intended size is to reveal a sliver of desktop behind the window and save your working copy there.

If you have icon previews enabled, you should see a nicely resampled image that updates every time you hit save! You can resize the preview by tweaking your desktop icon size (ctrl+click > Show View Options).1

I imagine this tip would work especially well if you’re lucky enough to have a HiDPI monitor. I still use Iconsider to preview icons on my iPhone’s retina display.

  1. You can do something similar within Adobe applications via Window > Arrange > New Window for X but zooming right out results in poor resampling and loss of detail.

Post Archive

2016

2015

July

2014

February