Skip to content

Instantly share code, notes, and snippets.


Grant Timmerman grant

View GitHub Profile
grant / index.js
Created Nov 12, 2020
Critterwatch Vision
View index.js
const vision = require('@google-cloud/vision');
const visionClient = new vision.ImageAnnotatorClient();
const {Firestore} = require('@google-cloud/firestore');
const firestore = new Firestore();
const trackedAnimals = ['raccoon', 'alpaca', 'peacock', 'dog', 'gecko', 'squirrel', 'red panda'];
* Triggered from a change to a Cloud Storage bucket.
grant / package.json
Last active Aug 5, 2020
Sheets as a Service – Basic Package
View package.json
"name": "sheets-on-run",
"main": "index.js",
"scripts": {
"start": "functions-framework --target=addRow"
"dependencies": {
"@google-cloud/functions-framework": "^1.6.0",
"googleapis": "^58.0.0"
grant / index.js
Last active Aug 1, 2020
Sheets as a Service – Basic Script
View index.js
const path = require('path');
const {google} = require('googleapis');
const sheets = google.sheets('v4');
// TODO: Add your Sheet ID
const SPREADSHEET_ID = '2L2LpYPyxJQTf14OLM6mVuiou88MsEi4Q-IUUxswNlfe';
* Appends row data to the Google Sheet
grant /
Last active Aug 1, 2020
Create a Service Account
# Get the current project
PROJECT=$(gcloud config get-value core/project 2> /dev/null)
# Create a service account (aka robot account)
gcloud iam service-accounts create sa-name \
--description="sa-description" \
# Create and download credentials for the service account
gcloud iam service-accounts keys create creds.json \
grant / Dockerfile
Last active Jul 27, 2020
R Functions Framework Dockerfile
View Dockerfile
# Use an R image.
FROM rocker/r-ver:3.6.1
# Copy R package binary
COPY functionsframework_*.tgz /
# Install functions framework dependencies.
RUN R -e "install.packages('functionsframework_0.0.0.9000.tgz', repos = NULL, type = 'source')"
RUN R -e "install.packages(c('optparse', 'plumber'))"
grant /
Created Jul 26, 2020
R Functions Framework Local Install
# Install devtools, specifying a CRAN mirror
install.packages("devtools", repos='')
# Import devtools
# Install GitHub project
grant /
Created Jul 26, 2020
R Functions Framework Deploy
# Set env var "GCP_PROJECT" to our project name
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
# Build and upload your image in Google Container Registry
gcloud builds submit \
--tag$GCP_PROJECT/hellor \
# Deploy your container to Cloud Run
gcloud run deploy hellor \
> swift --version
Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
Target: x86_64-apple-darwin19.5.0
grant /
Created Jun 29, 2020
Vapor Cloud Run
# Set project to current project in gcloud
PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
# Build the container using Cloud Build, giving plenty of time for the `swift build` step
gcloud builds submit --tag$PROJECT/vapor --timeout="20m"
# Run the container
gcloud run deploy vapor --image$GCP_PROJECT/vapor --platform managed --allow-unauthenticated
View routes.swift
import Vapor
func routes(_ app: Application) throws {
app.get { req in
return "It works!"
app.get("hello") { req -> String in
return "Hello, world!"
You can’t perform that action at this time.