Skip to content

Instantly share code, notes, and snippets.

Grant Timmerman grant

Block or report user

Report or block grant

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
grant / Dockerfile
Last active Jan 15, 2020
PHP Dockerfile
View Dockerfile
# NOTE: The entrypoint "/start", which starts up NGINX and PHP-FPM,
# is configured by creating a `.googleconfig/app_start.json` file with the
# contents:
# {"entrypointContents": "CUSTOM_ENTRYPOINT"}
grant / composer.json
Created Jan 15, 2020
PHP HTTP Function Composer
View composer.json
"require": {
"google/cloud-functions-framework": "^0.1.0"
grant / index.php
Last active Jan 15, 2020
PHP HTTP Function
View index.php
use Symfony\Component\HttpFoundation\Request;
function helloHttp(Request $request)
return sprintf("Hello %s from PHP HTTP function!" . PHP_EOL,
$request->query->get('name') ?: 'World'
grant / index.js
Created Jan 9, 2020
Cloud Run Storage – Cloud SQL
View index.js
const mysql = require('promise-mysql');
// Create a pooled connection to MySQL
let pool;
const createPool = async () => {
pool = await mysql.createPool({
user: process.env.DB_USER, // e.g. 'my-db-user'
password: process.env.DB_PASS, // e.g. 'my-db-password'
database: process.env.DB_NAME, // e.g. 'my-database'
// If connecting via unix domain socket, specify the path
grant / index.js
Last active Jan 9, 2020
Cloud Run Storage – Firestore
View index.js
// Create a Firebase client
const admin = require('firebase-admin');
credential: admin.credential.applicationDefault()
const db = admin.firestore();
async function uploadDoc(req, res) {
// Create a reference to the shoes doc.
let shoesDoc = db.collection('products').doc('shoes');
grant / index.js
Created Jan 9, 2020
Cloud Run Storage – Cloud Storage
View index.js
// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');
// Creates a client
const storage = new Storage();
async function uploadFile(req, res) {
// Uploads a local file to the bucket
await storage.bucket(res.query.bucket).upload(req.query.filename, {
// Support for HTTP requests made with `Accept-Encoding: gzip`
grant / Dockerfile
Created Nov 19, 2019
YouTube API on Cloud Run Dockerfile
View Dockerfile
# Use the official lightweight Python image.
FROM python:3.7-slim
# Copy local code to the container image.
COPY . ./
# Install production dependencies.
grant /
Created Nov 19, 2019
YouTube API on Cloud Run – Deploy Script
# !/bin/bash
# Set env var "GCP_PROJECT" to our project name
GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
# Set our Cloud Run region (so we aren't prompted)
gcloud config set run/region us-central1
# Build and upload your image in Google Container Registry
gcloud builds submit --tag$GCP_PROJECT/yt
# Deploy your container to Cloud Run
ENV=$(cat .env)
grant /
Created Nov 19, 2019
YouTube API on Cloud Run
import os
import argparse
from dotenv import load_dotenv
from flask import Flask, request
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
# Setup YouTube API
KEY = os.environ.get('KEY')
grant / main.go
Last active Nov 6, 2019
Go Functions Framework – main
View main.go
package main
import (
You can’t perform that action at this time.