The Story of Two Incredibly Productive Days of Coding
Tags: meta, devjournal, ruby, webdev
Published: 2017-06-22 17:21:00

---
title: The Story of Two Incredibly Productive Days of Coding
published: true
description: Two days is plenty of time to code up a quick feature... *or maybe not*.
tags: meta, journal, ruby, webdev
---

Two days ago I made this tweet:

{% tweet 877158153011568641 %}

With the various responsibilities of day-to-day operations, onboarding new developers, and general procrastination, I had let slip the only coding task I had that was at all tied to a deadline. Two days is plenty of time to code up a quick feature... _or maybe not_. That's the problem. When I went to take on this task, I really had no idea how long it would take.

The feature in question is a native video player for [dev.to](/), and since it's Thursday, our launch day, you can see it in action here:

{% link https://dev.to/thepracticaldev/moving-from-a-java-monolith-to-microservices-at-squarespace %}

We had picked [JWPlayer](https://www.jwplayer.com/) as service that fit our immediate requirements for the player and hosting of the videos. It seemed like the right choice for what we want now: a lightweight, customizable video player library and simple hosting service, as well as what we want in the future: additional configuration, scalable solutions for bigger operations. But I had not read any of the documentation and we were not entirely sure about the direction. Two days is plenty of time if things go smoothly. Two days is not a lot of time at all if you hit roadblocks. We could fall back on other options, but we wanted this to go well so we wouldn't have to ship something held together with duct tape, only to be replaced later. What we ended up with is a minimum viable product _we can build on top of_, rather than one we'll need to fully replace in the future.

And guess what... It went remarkably smoothly and I actually finished the whole project **in about 90 minutes**. I felt kind of silly about that tweet after how smoothly this process went. By Tuesday afternoon, I was done.

With the extra time on my hands, in addition to catching up on other things and helping other developers on their tasks, I decided to lean in a bit harder on this feature by adding automatic timestamp links to comments, similar to how YouTube does it.

Here is an example:

{% devcomment b8d %}

This feature also went incredibly smoothly. Feeling pretty good about the whole thing, I TDD'd this process really nicely and even wrote the needed regex myself without looking it up.

Here is the Ruby code appended to the comment html processing method to make this happen:

```ruby
def wrap_timestamps_if_video_present!
    return unless commentable.video.present?
    self.processed_html = processed_html.gsub(/(([0-9]:)?)(([0-5][0-9]|[0-9])?):[0-5][0-9]/) {|s| "<a href='#{commentable.path}?t=#{s}'>#{s}</a>"}
  end
```

The process was not without some yak shaving. In order to implement the timestamp link, I wanted to make sure the application's cache and our CDN both ignore the time query parameter, so that we aren't serving different versions of the page for every different parameter. This was an overdue task that affects many other parts of this web application. It meant providing a whitelist of parameters our application will ever care about to the CDN [through VCL configuration](https://docs.fastly.com/guides/vcl/query-string-manipulation-vcl-features). I'm glad I got the opportunity to do this. It was mostly a matter of reading the docs and was pretty simple to implement once I understood the whole thing.

Forecasts are hard to make, not only because any technical problem has a lot of unknown layers of complication, but because the demands on our time are equally hard to predict. I was pulled of my "heads down time" countless times in the last few days to deal with small issues, answer emails, or otherwise become preoccupied. I try to limit these interruptions, but they happen.

This process was supremely productive and satisfying. I hope you enjoy the video series and future video content on the platform. Right now, video upload is purely an admin feature. If you'd like to upload your own videos for distribution to the [dev.to](/) community, email [yo@dev.to](mailto:yo@dev.to).