TIL: Running Tests in VS Code

Since I’ve started using Visual Studio Code (still seems weird to say that…) I’ve been looking for a way to easily run tests. Today I learned how you can easily run tasks in Code in the integrated terminal.

Configure Task

First, choose the TasksConfigure Tasks menu. Code has a bunch of pre-built ones, but we just want to run a shell command so choose Others.

Use a configuration task like the following:

  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
      "taskName": "Run tests",
      "type": "shell",
      "command": "rails",
      "args": [
      "group": "test",
      "presentation": {
        "reveal": "always",
        "panel": "new"

See that ${relativeFile} bit? There’s a bunch of variables you can put there:

  • ${workspaceRoot} the path of the folder opened in VS Code
  • ${workspaceRootFolderName} the name of the folder opened in VS Code without any slashes (/)
  • ${file} the current opened file
  • ${relativeFile} the current opened file relative to workspaceRoot
  • ${fileBasename} the current opened file’s basename
  • ${fileBasenameNoExtension} the current opened file’s basename without the extension
  • ${fileDirname} the current opened file’s dirname
  • ${fileExtname} the current opened file’s extension
  • ${cwd} the task runner’s current working directory on startup
  • ${lineNumber} the current selected line number in the active file

Imagine setting up tasks to run your entire suite (e.g. rails test), the current file (rails test ${relativeFile}), the current line (rails test ${relativeFile}:${lineNumber}), etc.

Now running this task (with ⌘R and selecting the task) will popup the integrated terminal and run the task.

Bonus tip: ⌘-Click files and files with line numbers to jump directly to that file and line in Code. Super handy.

Keyboard Shortcut

Now that we have our task, we can setup a keyboard shortcut to run it easily. I setup ⌘R to run tests like so:

  "key": "cmd+r",
  "command": "workbench.action.tasks.runTask",
  "args": "Run tests",

Spotify Volume Control with Hammerspoon

One of Spotify’s best features is its ability for a client to become a remote to another version of itself running on a different device. A few months ago I started using the Mac app on my laptop to control the speakers connected to a PC in my office.

Everything works pretty well, except for the volume. Out of habit, I would use the volume keys on my Mac to adjust the volume only to change the system volume and not affect Spotify at all. After probably 600 times of doing this I decided to fix it.

Hammerspoon to the rescue! (For those not in the know, Hammerspoon allows you to write Lua scripts to control your Mac with a really great “standard library” of functions to control things like window positions, volume, running AppleScript, etc.)

With this little bit of code in my ~/.hammerspoon/init.lua file I can use:

  • F7 to goto the previous song
  • F8 to play/pause Spotify only (sometimes iTunes or something would randomly launch before)
  • F9 to skip to the next song
  • F11/F12 to adjust the volume of Spotify if playing, otherwise adjust the system volume
-- Remap media keys to Spotify-priority equivalents
hs.hotkey.bind({}, "f7", function()

hs.hotkey.bind({}, "f8", function()

hs.hotkey.bind({}, "f9", function()

hs.hotkey.bind({}, "f11", function()
  playing = hs.spotify.isPlaying()

  if playing then
    output = hs.audiodevice.defaultOutputDevice()
    output:setVolume(output:volume() - 10)

hs.hotkey.bind({}, "f12", function()
  playing = hs.spotify.isPlaying()

  if playing then
    output = hs.audiodevice.defaultOutputDevice()
    output:setVolume(output:volume() + 10)

You have to change the Keyboard System Preferences to intrepret the top row as F1, F2, etc. instead of Brightness, Volume, etc.) I picked F7 through F12 so the markings on the keys matched the functionality.

Of course, this may all be irrelevant with the Magic Toolbar

The New toledoblade.com

The Toledo Blade just launched a new version of their website. It’s… not very good.

Of course, it’s very easy to be dismissive and make fun of the old guard trying something, especially at the local level. It’s easy to make fun and point at all the things that are wrong. But, who makes toledoblade.com? Is it one person? A small team? Is the project just outsourced somewhere? I have no inside knowledge of or connections to web at The Blade. But I’d wager they aren’t given the resources, attention, and/or respect they deserve. I bet their largest and loudest demographic fears change and is very vocal about the paper’s slow drift away from newsprint to pixels. Great for morale.

Instead I’d like to offer some constructive criticism for how The Blade specifically, and maybe local news outlets in general, can be more relevant. I get it: local news is hard. I don’t have the Holy Grail for how to fix the dying organization that is printed news. I’m just a web developer who started making things for the web in Toledo, has gone on to make more things for the web at a global news organization in New York City, and came back to make some more things for the internet (which I guess we’re not capitalizing any more).

Is it Local?

The largest and first two stories (about 43% of the real estate in the “above the fold” homepage) is dedicated to the 2016 Presidential Election with stories sourced from the Associated Press, content also syndicated in hundreds of other media outlets. Only 30% is local content written by Blade staff.

The Blade hires a lot of really great reporters that spend a lot of their time out in my community (perhaps even in my neighborhood!) gathering information that is most likely relevant to my life as a Toledoian. But where is it?

I think there is an opportunity to geotag articles by location and use that data to provide hyper-local content down to my street. Or use what it knows about me and my social graph and interests to surface more relevant content in other ways.

Poor Implementation

It took 688 HTTP(S) requests over a whopping 18 seconds to deliver a single article (over Buckeye Broadband!) Only a tiny fraction of this bandwidth was for the content I requested, the rest is in service of advertising and tracking. (This isn’t just a problem with The Blade, but practically every news organization and website that depends on advertising revenue.)

Only a handful of The Blade’s readers will see this view, but everyone feels the sluggishness and is affected by the ever shrinking notion of privacy online. If you’re going to track my movements around the site, use it for other useful purposes other than just re-marketing.

Content Advertising is King

Advertising isn’t just the majority of bandwidth, it’s often the majority of the page as well. Huge banner ads that obscure content are commonplace, and are constantly vying for your attention as you scroll down the page.

I should probably mention I am a digital subscriber to The Blade, but I’m not sure what that means on the new site. I don’t see anywhere to log in, and even if I did it’s not clear how that would change my experience, if at all.

Words and Images

Throughout their history, newspapers have only produced words and images: first printed on a page then uploaded to a server. They haven’t transitioned to other forms of storytelling like video and data-driven interactives.

I’m sure part of the reason is lack of a work force to generate said content. Web designers, developers, UX specialists, iOS and Android developers, data journalists, video producers, system administrators, etc. are expensive and hard to find in Toledo. But I’m not even sure newspapers think they need them.

It’s clear the dead tree-based newspaper is still king and at the center of the organization. Rich media has no place there and therefore is most likely of little value to the organization overall. But you need more than just words to properly explain what is happening in our ever complicating community.

I hope either The Blade or someone else starts telling that story.