The Serverless Tool Nobody Talks About

I'm a big fan of the recent rise of "Serverless" computing, spearheaded by AWS's Lambda. Many people have pointed out that "Serverless is made of servers", which is a fair point. ("Functions as a Service" is probably better.) But they aren't servers that I have to pay for when I'm not using, keep patched, manage runtimes for, and so on. There are obviously tons of use cases where FaaS won't work -- but when it will, why not?

It hit me the other day, though, that I've used another tool that lets code be written and run -- even sophisticated use cases like running on a schedule, interacting with other web services, and so on -- which vastly predates AWS Lambda. That tool is Google Apps Script.

Here's a problem I had been thinking of solving with Lambda (mostly as an exercise in building an end-to-end app, but also because it was a real problem I had.)

My kids get allowance: $1/week for every year old they are. We still want them to physically get the funds, so they can have the tangible reality of collecting it, having to give it back when they buy things they've saved for, and allocate between Spend/Save/Give categories.

The problem is, I had a terrible track record of remembering to hand it out on our typical period. And a lot of the time I did remember, it coincided with a lack of small bills or coins.

What I needed was a system which would 'buffer' for me. The desired features were:

  • Deposit a kid-appropriate number per week
  • Allow me to decrement it when "paying out" -- and properly secured, so that nefarious parties (or creative hacker inclined 7 year olds) could not tweak the balances
  • Allow the older kids to have read-only views of the values that they could consult via the web. (Desktop bookmarks on iOS.)
  • Have an audit trail of when and what changes were made.

I sketched this with Lambda. All very possible, but non-trivial.

  • Data could be stored in DynamoDB, or even -- given the low write volume -- as structured data in S3.
  • Auth is still a little complicated, even if you using Cognito, but could be linked to Google or Facebook, or even tied to a simple token stored in KMS.
  • Read-only access is simple, if publishing the values to a s3 website-enabled bucket.
  • Editing could be a pretty simple Single Page App, hosted in the bucket, that targeted an API Gateway endpoint.
  • Periodically incrementing the values is also easy, with a scheduled Lambda task.
  • The audit trail could be stored in DynamoDB or Cloudwatch Logs.

So it's very doable, but that's also a lot of overhead. If I wanted to build a SaaS allowance product, though, it could be a pretty excellent starting point, with a pretty incredible scaling/cost profile!

However, here's what it took in Google Apps.

  • Create a new spreadsheet.
  • Set up the basic structure of the document
  • Launch the script editor (Tools > Script Editor)
Launch Script Editor
  • Enter the simple code
Code Listing

In copy/paste compatible form:

function divvyAllowance() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    for (var i = 2; i <= 4; i++) {
        incby = ss.getRange('B' + i).getValue();
        balance = ss.getRange('C' + i);
        balance.setValue(balance.getValue() + incby);
  • Click the 'clock' icon in the script editor to enter the schedule, and set the function to run weekly.

And that is it! It meets all the requirements, at no additional cost -- in fact, no cost at all, in many Google plans.

  • I can use the Google Sheets app to check on the values if I'm being consulted about a kid's current balance while in a store.
  • I can share write access with my wife, too.
  • I can give the kids read-only URLs to consult if need be
  • The sheets Revision History will track every edit, including the automated ones.

So, of course, this provides far lower control, customization, and possibly even scalability as the full-bore serverless implementation outlined above. But it's also VASTLY more simple and manageable. So, thanks Google, for being Serverless pioneers, and still being a good option for a lot of these use cases!

How I Use an Electric Pressure Cooker

My favorite small appliance, bar none, is my Electric Pressure Cooker. I have the Instant Pot, but most modern electric cookers have the same properties that got me so excited.

I was an early adopter of the pressure cooker, largely prompted by seeing them used on Iron Chef (the original Japanese version.) If they helped these chefs put world class food out in record time, surely they could be useful in helping me put food on the family dinner table! However, I started out with a range-top model, and I found it needed a lot of babying -- adjusting the flame to get it up to boil, turning it down when it got up to heat, getting it off the heat when the right amount of time had gone by. No huge dealbreakers, but I did have some issues with scorched bottoms, or overcooked food because I was distracted when the timer went off (kids will do that to you), and so on.

Enter the electric cooker. Simplicity itself -- program the amount of time you want under pressure, seal the lid, and walk away. Once the time is up, it automatically turns to a 'keep warm' mode while pressure starts dissipating.

All this, while not heating up your house like an oven does, or leaving the funky aftersmell of a crock pot in the house, which seems to linger for days.

I ended up convincing a few other people to pick up the Instant Pot while Amazon had them very on sale, and then had a few conversations like "ok, I got one of these, now what?" So here are some of my favorite things to do with it.

First, the high level. The pressure cooker works best with things that normally like "low and slow" heat. It's not (generally) good for delicate fish, or things that usually want quick high heat like steaks. But for things that you'd normally smoke, stew, braise, or slow cook, the pressure cooker might work great. This is handy because a lot of those are also cheaper cuts of meat.

It's also great for almost anything that you would boil or steam, it can generally do that quicker and retain more of the nutrients.

One thing that took some adjustment is how much of a black box things are once you start cooking. I'm used to being able to keep an eye on how food is looking visually as it cooks, stick a thermometer in it, etc. With this device, once you press go, you need to be pretty sure that you're going to like what's in there when the buzzer goes off. If I'm cooking something new, I'll usually google around for recipes and find people that have cooked that item before, to get a sense for how long to give it under pressure. (Or, check out this handy chart from Hip Pressure Cooking, one of the best blogs/books about leveraging this awesome tool.) That's another advantage of the 'tougher cuts': most of them are pretty tolerant of being cooked 20 minutes even if 15 would be ideal. The good thing is once you release the pressure, if the food is not done, you can always repressurize it. Since the contents are already hot, it will get going again quickly.

So with that out of the way, here are some of my go to recipes. Most of these don't even deserve to be called a recipe :)

Sweet Corn is everywhere this time of year. Just shuck the corn, put it vertically into the cooker, add 1 cup of water straight into the bottom, and set it for 2 minutes. It pressure steams the corn, leaving it bright, juicy and crisp-tender.

Crunchy Potato Wedges: When we have people over, I generally make a batch of these, and they go very quickly. Wash red or gold potatoes, then cut into wedges, put them in a steamer basket inside the cooker, then give them 1 minute of pressure. Meanwhile, I preheat the oven to 450 convection. When the potatoes come out, dump them onto the trays (don't worry if they break up a little), drizzle with olive oil and sprinkle generously with salt, then slide them in the oven. Pull them out when they are golden brown and delicious. They'll be crunchy on the outside and the insides will be little potato clouds of goodness.

Similarly, Mashed Potatoes are quick and simple; chop up the potatoes with 1 cup of water (or a more flavorful liquid), and pressure-cook 4 minutes, then do whatever you normally like to do with potatoes once you drain them.

If you're looking for a quick way to get a more flavorful liquid, you can use your pot with veggie or meat scraps to make delicious stock in just 30 minutes.

Stews and Chilis: Almost anything can be made into a stew, I find. There are even preset buttons on the instant pot for it. The trick is that if you're using a meat, it probably wants more time than the vegetables do, so there are two good approaches. (1) put the meat/liquid and vegetables that you expect to 'break down' (onions, garlic) first, and cook until almost done, then release pressure, add the other vegetables (carrots, potatoes, etc) and put back under pressure for a few more minutes. The other idea I like is from Dad Cooks Dinner -- put a steamer basket on top of the stew, and put the other items in it, so they steam instead of boil.

For some reason the first time I tried cooking rice in the Instant Pot, it did NOT go well. But since then I've had great results.

  • Perfect Basic Rice. The trick is 1 part wet rice to 1 part liquid.
  • 7 minute Risotto! I have made this tons of times, with a variety of vegetables mixed in. It's not full-on-full-on risotto, but for almost no hands on work, it's fantastic. Also, the leftovers are one of my favorite things to eat for a decadent breakfast. If you make "puck" shapes out of the rice, and brown them on both sides, they are very tasty, especially if you top them with a fried egg.

Any meat that normally gets shredded is typically delicious. I enjoy Pulled Pork, or my favorite variation, Carnitas. While those dishes start to take longer (75 minutes+), they're still way quicker than the alternative ways to cook them. (Or Pork with dried plum sauce. Now I'm hungry.)

For other things that I enjoy having a crispy, roasty exterior, you can still cook them first in the Instant Pot. So Beef Ribs are one of my favorite things, but they are tricky to cook! If you cook them slow enough to get them tender, they can start to go the other way and get dry. So, 20 minutes of steam, while preheating the grill, and then put it over the heat until it gets crunchy and amazing.

I love Steel Cut Oats but I don't love wrangling them on the stovetop. But 10 minutes in the instant pot, and breakfast is ready. I love to mix things in, as well. (Dates! Almonds! Coconut flakes!)

One of the other hacks I really think is killer for weeknight meals is being able to cook Pasta, right in the sauce.. The sauce gets cooked into the noodles, and you don't need to do multiple pots, straining, etc.

That's probably enough for now. The Electric Pressure Cooker is amazing. Get one, give it a chance, and love it.

Contents © 2016 Joshua Barratt - Powered by Nikola