When Presentations Collide

Last week I wrote about my presentation at TechSmith’s Recon conference, “Implementing Advanced Trello Functionality via the Trello API.”  Embedded in that post is a video of the presentation itself.  It’s not the video that was included when I first published the post, though.

I initially published the post with video embedded straight from TechSmith Relay, which I thought was publicly accessible because I didn’t realize I was already logged in on the machine I tested with.  Oops.

I could have just dumped the video off to YouTube or Screencast.com or used the built-in media handling of WordPress, but I decided I wanted this blog to have a tool like I had built for DetroitHockey.Net.  So I cloned that tool and made some tweaks, then used it to process and display a new video.

Of course, last year I presented on that tool at TechSmith’s DevCon conference.  Which means that I used the topic of my presentation last year to share my presentation from this year.

I just think that’s a little humorous.

Batch Requests with the Trello API

I write about the Trello API a lot.  So much that I’ve already noted that I write about it a lot. I keep coming across new stuff, though, so I’m going to keep writing about it.

My latest experiment was a look into using their batch call, which I don’t see a lot of documentation about so I figured was worth writing up.

Batch functionality lets you fire off a series of GET requests (and they have to be GET requests) as one request.  Depending on your code and what requests you’re making (and what data you’re getting back), this should speed things up a bit.  My test script went from running in 37 seconds to 20, for example.

In an extremely simple (and pretty much useless) case, you could replace GET calls to /1/members/me and /1/boards/511e8c0101d3982d05000d5b with a single batch call, /1/batch?urls=/members/me,/boards/511e8c0101d3982d05000d5b.

As shown, /1/batch takes the URLs parameter, a comma-separated list of the calls you want to make, minus their version number prefix.

Of course, this means you get only a single response back, and it looks a little different from a normal response.  The response is an array of objects – but not of the normal response objects you might expect.  Instead, it’s an object with a single property, with a name set to the HTTP response code of the request.

So if your first request was to /1/boards/511e8c0101d3982d05000d5b, a normal response would start as follows:

stdClass Object
(
    [id] => 511e8c0101d3982d05000d5b
    [name] => Welcome Board

The batch version of that response would look like this:

Array
(
    [0] => stdClass Object
        (
            [200] => stdClass Object
                (
                    [id] => 511e8c0101d3982d05000d5b
                    [name] => Welcome Board

Obviously that’s simplified, I just don’t think it’s necessary to show the whole response.

One nice little gotcha with that response and working in PHP is handling a numeric property name, which is done by putting curly braces around the number, as seen in the code to follow.

Lets say you want to get the names and IDs of all the boards you’re assigned to and the names and IDs of all of the lists on each of those boards.  Without batching, you could do the following:

  $trello = new trello_api($GLOBALS['config']['key'], $GLOBALS['config']['secret'], $GLOBALS['config']['token']);

  $data = $trello->request('GET', '/1/members/me');
  foreach ($data->idBoards AS $board_id) {
    $board_data = $trello->request('GET', ('/1/boards/' . $board_id));
    echo '<p>' . $board_data->name . ': ' . $board_id . '</p>';
    echo '<ul>';

    $list_data = $trello->request('GET', ('/1/boards/' . $board_id . '/lists'));
    foreach ($list_data AS $list) {
      echo '<li>' . $list->name . ': ' . $list->id . '</li>';
    }

    echo '</ul>';
  }

  unset($trello);

With batching, that becomes this:

  $trello = new trello_api($GLOBALS['config']['key'], $GLOBALS['config']['secret'], $GLOBALS['config']['token']);

  $batch = array();

  $data = $trello->request('GET', '/1/members/me');
  foreach ($data->idBoards AS $board_id) {
    $batch[] = ('/boards/' . $board_id);
    $batch[] = ('/boards/' . $board_id . '/lists');
  }

  $data = $trello->request('GET', ('/1/batch?urls=' . implode(',', $batch)));
  for ($n = 0; $n < count($data); $n += 2) {
    echo '<p>' . $data[$n]->{200}->name . ': ' . $data[$n]->{200}->id . '</p>';

    echo '<ul>';

    foreach ($data[($n + 1)]->{200} AS $list) {
      echo '<li>' . $list->name . ': ' . $list->id . '</li>';
    }

    echo '</ul>';
  }

  unset($trello);

This assumes that the API will respond with a 200, of course.

As I said, I didn’t see a ton of documentation about batch calls in the Trello API.  This is a stupid simple example but I thought it was worth putting out there.

Implementing Advanced Trello Functionality via the Trello API

I’ve written pretty extensively on my work with the Trello API and yesterday I got to present the code side of it at TechSmith’s internal development conference, ReCon.

Last year I presented for the first time (when the event was called DevCon) and I think I learned a lot from it that helped me this time around.  I’m pretty sure there were fewer “ums” and “uhs” but it was also a shorter presentation with less time for that.

The shorter presentation meant I had to absolutely blow through the information I wanted to put out there, so I’m worried I didn’t give enough time for it to set in.  It was supposed to be part of a larger presentation, an idea that fell apart late in the process, so I’m not sure what I could have done about that.

I think the biggest adjustment was the most important one.  In my presentation last year, my code slides weren’t very legible.  This time I made sure to focus on that, so there’s less code on each slide and the text is larger.  I couldn’t find a better way to get syntax-highlighted, properly-spaced code on to a Powerpoint slide than with screenshots, though, which seems stupid.

Unfortunately, I made one of the same mistakes as last year, not checking the audio beforehand.  I used a mic that was piped into the room speakers and recorded off an omni-directional mic that picked up everything in the room.  This makes the recording sound like I was in a car wash.

I enjoyed it significantly more than my presentation last year, though, and hope I have as good of a topic to speak on next year.

I referenced “Jenny’s presentation” and she’s posted it.  It covers a lot of the context I left out of mine.