I just now put together an EcmaScript 2016 gist for calculating how many remaining Codeship builds you have without overstepping your average daily allotment. Since the premium accounts for Codeship start at $49/mo, it makes sense for a lot of amateurs such as myself to dabble in the sandbox account, which limits you to 100 builds per month. Here’s what the code looks like:

/**
 * This function gratefully taken from
 * http://stackoverflow.com/a/1185804/1591507
 */
Date.prototype.monthDays = () => {
  const date = new Date();
  const d = new Date(date.getFullYear(), date.getMonth() + 1, 0);
  return d.getDate();
}

/**
 * @param {string} numberofBuildsDone - the number of builds
 * that you’ve already used for the current month
 */
const calc = (numberofBuildsDone) => {
  const numberFreeBuildsPerMonth = 100;
  const daysInMonth = new Date().monthDays();
  const currentDayInMonth = new Date().getDate();
  const availableBuildsPerDay = numberFreeBuildsPerMonth / daysInMonth;
  const numBuildsLeftForToday = Math.round((availableBuildsPerDay * currentDayInMonth) - numberofBuildsDone);
  return `You can make ${numBuildsLeftForToday} more builds today.`;
}

Just take this code, paste it into your Chrome console, and then run something like this:

calc(37);

Since it’s February 13 and there are 28 days in this month, running that right now outputs this:

You can make 9 more builds today.

Pretty cool, right?

Every time I publish something on DC, that takes a build. Every time I update a post, that takes a build. In theory if I do zero editing and I don’t work on any other projects that I’ve integrated with my Codeship account, that means I can publish a maximum of 100 posts on DC in a month. That may sound like a lot, but when you remember that DC is my version of Twitter, that means the equivalent of not being able to tweet more than 100 times in a month. I’ll probably eventually change my tech stack so I’m not confined to this limit, but for now, it’s kind of a fun constraint.

If you’re on the free plan of Codeship for something and you want to keep an eye on how quickly you’re burning through your allotted amount, feel free to fork or star my gist.