Ruby Script On Heroku That Accesses Google Sheet On A Schedule

I recently had a need to write a simple script that writes to a Google Sheet document once a day. I decided to write the script in Ruby and host it on Heroku since I didn’t want my laptop to be on in order for the script to run. After spending some time Googling & some trial and error, I came up with something that works and is quite simple. For the purposes of this blog post, I will write a Ruby script that accesses a newly created Google Sheet document and does the following:

  • Prints out to the console how many rows are contained in the Google Sheet document
  • Adds the current date & time to a new row in the document

I will then set up a recurring job on Heroku to execute the script every 10 minutes.

The Steps

Create a new Google Sheet document.

Create a new project in Heroku. For the purposes of this example, I’m calling it: scheduled-ruby-script

If you haven’t already, install the Heroku CLI. After it’s been installed, set up your project locally:

$ heroku login
$ mkdir scheduled-ruby-script
$ cd scheduled-ruby-script
$ git init
$ heroku git:remote -a scheduled-ruby-script

At the project root, create a Gemfile with the following 2 lines in the file:

source ""
gem "google_drive"

Let’s go ahead and create the Ruby script. We’re going to utilize the Google Drive Ruby Gem. Let’s call the file script.rb and it should contain the following. NOTE: When you’re setting the google_sheet_id variable below, this comes out of the Google Sheet document’s URL. This is the unique identifier looking thingie part of the URL. For example, if the URL is then you should set the variable to: “1iB6vU90eFVjLa93jyb4TdT2fArNddXWQSEnFRamerA7”

require "google_drive"

session = GoogleDrive::Session.from_config("config.json")

# You can grab this from the URL of the Google Sheet document
google_sheet_id = "[SEE MY NOTE ABOVE!]"

ws = session.spreadsheet_by_key(google_sheet_id).worksheets[0]

ws[ws.num_rows + 1, 1] =

# Reloads the worksheet to get changes by other clients.

p "Number of rows in the Google Sheet document: #{ws.num_rows}"

Let’s test the script locally.

$ bundle install
$ ruby script.rb

When you run the script for the first time, you’ll be asked to go to a URL that starts with Go to the URL in your browser and copy the code that you’re provided with. Paste that back in your Terminal and press return. This will create a config.json file at the project root and it contains the credentials that allows your script to access to the Google Sheet document.

If your script runs successfully, you should see something like “Number of rows in the Google Sheet document: 1” printed out in the Terminal and see a timestamp in the Google Sheet document.

Once you’ve confirmed that the script is working locally, let’s commit your files and push them up to Heroku.

$ git add .
$ git commit -m “Writes to Google Sheet document and reads from it"
$ git push heroku master

Once the files are pushed up, let’s test it on Heroku.

$ heroku run bash
Running bash on ⬢ scheduled-ruby-script... up, run.5080 (Free)
~ $ ruby script.rb
"Number of rows in the Google Sheet document: 2"

And if you look at the Google Sheet document, you should see that another timestamp has been added. Note that when the script runs on Heroku, the timestamp will be in UTC.

Now, if we want script.rb to be executed every 10 minutes, you’ll need to configure Heroku Scheduler. Go to: > Select your application (eg, scheduled-ruby-script) > Click on Configure Add-ons.

Under Add-ons > Type in: Heroku Scheduler > Select the Provision button. You should now see that the Heroku Scheduler add-on has been added. Click on the Heroku Scheduler link.

Click on ‘Add new job’ and update the fields to have ruby script.rb run Every 10 minutes. Select the Save button.

Give it some time (< 10 minutes) and if everything works, you should eventually see a new record get added to your Google Sheet document.


Tips for my next trip to Korea

3 minute read

I recently returned home after a memorable 3-week trip to Korea with my parents and my youngest child. This was my 7th trip back to Korea after immigrating t...

My job search recap

3 minute read

After 4 weeks of very aggressive job searching, I was able to wrap up my job search late last week and I decided on an offer yesterday. Hooray! This is the f...

Back to Top ↑


Running Effective and Efficient Meetings

2 minute read

I spend a lot of time at work in meetings. I regularly think about having effective and efficient meetings and here’s a list of things that I think are impor...

Let’s Get Rid Of Performance Rating Scales

4 minute read

Several weeks ago I wrapped up conducting employee performance reviews for the 2020 calendar year and it’s the first time that I can remember in my career wh...

My Role As “Clarity Provider”

4 minute read

Over the last several months I’ve become increasingly convinced that one of my most important responsibilities as an engineering manager is to provide clarit...

My Fitness And Health Routine

5 minute read

Something that is personally very important to me is that I stay fit and healthy for as long as possible in life. While I wouldn’t label myself a “fitness nu...

My System For Staying Organized At Work

2 minute read

Being organized is a skill I personally value and at least for me - it’s a no-brainer that being organized can help everyone do their jobs better. It was imp...

Back to Top ↑


Personal Retreat

1 minute read

I drove about 2 hours west to Stockton, IL - to a place called Christ in the Wilderness (CITW), to spend a few days (Friday evening - Sunday morning) to myse...

Back to Top ↑



2 minute read

I recently returned home from attending Deconstruct along with a bunch of my co-workers. I thought I’d jot my thoughts down while the experience is still fre...

My Disappointment With The New Macbook Pro

2 minute read

When I started at Braintree I was given a new 2017 15” MacBook Pro with Touch Bar. It’s a really nice laptop overall and I don’t mean to sound ungrateful… bu...

A Few Weeks Into The New Job

3 minute read

I’ve been at Braintree now for almost 3 weeks and I can’t believe it’s only been a few weeks because I’ve experienced a ton of new things and have met a lot ...

Interview Process Takeaways

4 minute read

In the last several weeks I’ve had the opportunity to speak with numerous companies as a job candidate. While the experience is still fresh in my mind, I tho...

Back to Top ↑



3 minute read

I started 2017 with a ton of excitement over the opportunity to build Cappex’s very own college application product. I knew it was going to be an extremely c...

New Product Launch And Life Afterwards

1 minute read

A very large chunk of my life from the very beginning of this year until the end of July was focused on launching a new college application product. Thanks t...

Hello Is A Poor Greeting

2 minute read

I’ve done what I think is an insane amount of phone screens since December (well over 100) and in the last few weeks there’s something I’ve been noticing whe...

Hiring Is Tiring

3 minute read

Yep, hiring is tiring. Very much so.

Back to Top ↑


The Christmas Gift Test

1 minute read

Ever since I started managing people several years back I’ve practiced giving Christmas gifts and a hand-written Christmas card to everyone on my team. I in...

Do Not Store Personal Data On Your Work Computer

3 minute read

I know that it’s often convenient to have your personal files stored on your work computer, especially If you’re like me and you spend a lot more time on you...

10 Lessons From 10 Companies In 19 Years

11 minute read

Since landing my first programming job when I was a junior in high school until now, I recently realized that I’ve now worked at 10 different companies, incl...

I wish DST would end

2 minute read

I really wish Daylight Savings Time would cease to exist. I can’t possibly imagine that DST would go away in my lifetime due to the sheer complexities and c...

Be Thankful

3 minute read

Last 2 weeks at work have been rough. This most recent sprint as well as the release ended up being much more difficult than what my team is normally used t...

Gradle Build Scan Rocks

2 minute read

Earlier today I attend a webinar hosted by Gradle, Inc. where Gradle Build Scan was introduced. If you’re already using Gradle as the build tool for your pr...

Compare Property Files

1 minute read

I’ve been working on a rather massive refactoring work that involves changing how Java properties files are organized. It’s vitally important that the prope...

Page Load Speed Testing

1 minute read

I decided to conduct some simple page load speed testing. I hope the following info might be of some value to some folks out there.

Replacing SSD in MacBook Air (13” mid-2012)

2 minute read

I was running low on my 13” mid-2012 MacBook Air’s SSD, which had me pretty concerned. Thankfully I recently discovered that the SSD inside this thing is re...

Simple Interview And Phone Screen Tips

5 minute read

I’ve been busy doing a lot of phone screens and interviews as of late. Actually, I’ve been doing a lot of interviewing during my time at Cappex. Since join...

Resolving Tethering Issues With iPhone

1 minute read

I spend roughly an hour and a half Monday through Friday commuting to and from work and my laptop is tethered to my phone probably 90% of the time I’m on the...

Deleting Non-empty AWS Glacier Vaults

2 minute read

I had a couple of AWS Glacier vaults that I had been meaning to permanently delete for awhile. When I tried deleting them via the AWS dashboard, I got the f...

Back to Top ↑


Why Android Sucks

3 minute read

Android sucks. At least my experience of it has. Now, I’m NOT saying that Android-sucks-therefore-Apple-is-way-better. All I’m saying is that I’ve had 3 A...

Setting Up A 301 Redirect In Ruby On Rails

less than 1 minute read

I saw in Google Analytics that I’ve been getting a lot of hits on, which isn’t a valid page. I decided that it’d be best to set up a...

Back to Top ↑


My First Album Is Now Available For Purchase

1 minute read

My first album Acoustic Worship is now available for purchase on! Recording an album is something I’ve wanted to do for a very long time and I’m g...

Resolving Dns Issue On Mac Os X Yosemite

less than 1 minute read

I upgraded both my MacBook Air and MacBook Pro to Yosemite over the weekend and I saw that both my laptops were unable to connect to internal systems at the ...

A Memorable Phone Screen

3 minute read

A few days ago, I phone screened a QA Manager candidate that ended up being extremely memorable. It went something like this:

Workout Frequency Before And After Baby

less than 1 minute read

Ever since my son was born in late June, it’s been a challenge trying to find time to work out. Since I record every one of my workout sessions, I thought I’...

Merging Codebases In Git

1 minute read

A couple of weeks ago, I had to merge one codebase into another codebase and after a lot of searching for solutions on the web, I came across a solution that...

Back to Top ↑


Why I Love Being Married

2 minute read

My wife and I met through a (very) random suggestion from a mutual friend 3 and a half years ago. It was suggested to us that we should meet up, get to know...

Pictures From Turks and Caicos

less than 1 minute read

Here are some pictures I took while I was in Turks and Caicos earlier this month with my wife.

My Thoughts On Commenting In Code

3 minute read

A skill that is often overlooked amongst developers and development managers is the ability to write good comments in code, which is understandable I suppose...

Hacker News By Points

less than 1 minute read

I frequent Hacker News ( pretty often throughout the day and I realized that my eyes were almost always drawn to posts on the first page...

Playing Around With Lightroom

less than 1 minute read

I thought I’d give Adobe Lightroom a try and play around with editing some pictures. Well, here are the results.

One Less Debt

less than 1 minute read

Just paid off my student loans, which took me about 9 years and 3 months. I was planning on letting it drag on and on because of the super low interest on i...

Weekend Project Php Website On Heroku

1 minute read

I got hold of some really nice looking single page website templates earlier last week (from here) so I thought I’d go ahead and redo the website for my pare...

Three Monitor Setup

less than 1 minute read

Thanks to Plugable I’ve now got 2 monitors hooked up to my Lenovo laptop at work and I’m absolutely loving it. I definitely should’ve done this way sooner.

Teaching My Wife How To Code

less than 1 minute read

My wife recently decided that she wants to learn how to code and of course, I’ve volunteered to be her teacher. She has absolutely no experience with progra...

Stuff I’ve Been Learning

2 minute read

It’s been quite awhile since my last blog post and I had a sudden itch to write about things I’ve been learning (mostly at/through work) over the course of, ...

Back to Top ↑


Moving From Subversion To Git

1 minute read

Last Thursday, my team made a successful transition from Subversion to Git. Here are some thoughts after having been on Git as a team for about a week now:

I Am Not Going To Pay You To See Your Portfolio

less than 1 minute read

Earlier today, I had a web design candidate who informed us that he would be able to provide us with an up-to-date portfolio of his design work for a flat fe...

Lessons Learned While At Lakeview Church

1 minute read

This coming Sunday will be my last Sunday at Lakeview Church. I’ve been a part of this church since summer of 2006 and I’ve been blessed to experience such ...

Hello Ruby On Rails Postmarkdown

less than 1 minute read

Decided to ditch PHP + WordPress + Lithium Hosting for Ruby on Rails + Postmarkdown + Heroku.

No More Taking Work Home

less than 1 minute read

It’s been about 6 weeks since I started working at and while I’ve been really enjoying the work, I’ve also been guilty of bringing work home. I’v...

Job Search Tips From Personal Experience

4 minute read

Earlier this year I decided that it’s time for me to look for another opportunity outside the company. The company executives decided on being acquired by O... Redesign Launched

less than 1 minute read

I gave a (much needed) facelift over the course of this past week and it’s now live online. This is the first project completed on my n...

Been Awhile

less than 1 minute read

The last time I wrote in this thing was 10/22 of last year, which is also the time when wedding preparations got crazy. Well, thank God the wedding is now ov...

Back to Top ↑


Taking A Breather In San Francisco

3 minute read

I arrived in San Francisco last night with Jenny and a friend of ours at around 10:30 local time to attend Jenny’s friend’s wedding which takes place later t...

Writing Good Software Simple Reminders To Self

3 minute read

One of the main purposes for keeping this blog is for me to think through and reflect upon things and to remind myself of the lessons that I’m learning. I k...

Commuting To Downtown Chicago For Work

3 minute read

My office moved from Westmont to Chicago about 2 and a half months ago and ever since then I’ve been taking the Metra train to get to work. There are some t...

Wow 7 Years Already Since Undergrad

6 minute read

This past Wednesday, I paid a visit to my alma mater (UIC) to be among the panelists to share my post-college experiences of working in the corporate world. ...

My Engagement Ring Selection Process

7 minute read

One of the main motivations behind why Jenny and I wanted to start this blog in the first place was so that this blog would (eventually at some point once th...

I Am Engaged!

less than 1 minute read

On Saturday, I got engaged to the most amazing girl I know. :) It still hasn’t quite hit me yet. To be honest, I’m guessing it’ll hit me once I get used to...

New Site Design

less than 1 minute read

I’ve been wanting to convert my site to a single-page design and after working on this on & off for the last several weeks, I’m glad to have the site fin...

Back to Top ↑


Been A Long Time

2 minute read

It sure has been a long time since the last time I updated my blog. Here are the different things that have been occupying me in these last couple of months:

Excellent Book On Web Usability

1 minute read

One of the things I’ve been enjoying about work since I made the switch last November is being able to get my hands dirty with front-end web development and ...

Software Development As Missional Philanthropy

4 minute read

For some time now I’ve been really interested in going overseas for the purposes of doing missional philanthropic work. And by “missional philanthropy” I am...

User Interface Design 090

7 minute read

Do you remember how in college there were classes that were actually below 100-level? The classes that some folks were required to take but they didn’t coun...

If You Write Code Write Tests

less than 1 minute read

So… I’m scrounging around the internet looking for some TDD-related tidbits and I came across the following at

Making The Most Out Of Band Rehearsals

8 minute read

Band rehearsals–some love ‘em, some hate ‘em, but there’s no denying that they are very much necessary, even for bands that are comprised of phenomenal music...

Lessons Learned From Being In The Shoes Of QA

5 minute read

At work we have a huge product release coming up very soon. There are a lot of new features to the application, which means that there has been a ton of cha...

New Recording - Gone From The Portrait

less than 1 minute read

Over the weekend I started re-recording a song which I had written a few years back. Vocals, acoustic guitar, electric guitars, bass, keyboards, drums-via-k...

New Music - Lullaby (Instrumental)

less than 1 minute read

After lunch @ Sweet Tomatoes with some friends I came back home and took a much needed nice, (too) long nap. Fast forward a few hours and it was around 11: ...


less than 1 minute read

Yet another rendition of is done… at last! I decided to forsake my old Blogger posts since it’s been quite awhile since my last blog update an...

Back to Top ↑