Skip to content

Instantly share code, notes, and snippets.


Sara Robinson sararob

  • Firebase
  • San Francisco, CA
View GitHub Profile
sararob /
Last active Sep 17, 2021
This Cloud Function will kick off a Vertex Pipeline run whenever a specified amount of new BigQuery data is available for training. Deploy it as an HTTP function and set up a Cloud Scheduler job to automate running it on a recurring basis. See this blog post for details:…
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
import kfp
import json
import time
from import bigquery
from import NotFound
from import AIPlatformClient
client = bigquery.Client()
View predict.js
// Get measurements for a new flower to generate a prediction
// The first argument is the data, and the second is the shape.
const inputData = tf.tensor2d([[4.8, 3.0, 1.4, 0.1]], [1, 4]);
// Get the highest confidence prediction from our model
const result = model.predict(inputData);
const winner = irisClasses[result.argMax().dataSync()[0]];
// Display the winner
View train-model.js
xData, yData, {
batchSize: batchSize,
epochs: epochs
View define-model.js
import * as tf from @tensorflow/tfjs’;
const model = tf.sequential();
model.add(tf.layers.dense({inputShape: [4], units: 100}));
model.add(tf.layers.dense({units: 4}));
model.compile({loss: ‘categoricalCrossentropy’, optimizer: ‘sgd’});
View image-queue.js
'use strict';
// Dependencies
const gcloud = require('google-cloud', {
projectId: 'sara-bigquery',
keyfileName: 'keyfile.json'
const vision =;
const fs = require('fs');
const async = require('async');
sararob / cloud-nlp.js
Created Apr 19, 2017
Call the Cloud Natural Language API from Node.js
View cloud-nlp.js
'use strict';
const fs = require('fs');
const ndjson = require('ndjson');
const request = require('request');
fs.createReadStream('reddit-comments.json') // Newline delimited JSON file
.on('data', function(obj) {
sararob / bike-query.sql
Last active Aug 12, 2019
The life of Citibike # 17526
View bike-query.sql
# Enable Standard SQL to run this query
# More on BigQuery here:
REGEXP_REPLACE(starttime, '([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})', '\\3-\\1-\\2') as starttime,
FROM `sara-bigquery.nyc_citibike.trips_*`
WHERE cast(bikeid as int64) = 17526 # This is the bike with the most trips (found from another query)
order by starttime
sararob /
Last active Aug 12, 2019
Bash script for recording audio and calling the Cloud Speech API
# 1) This requires having SoX ( installed. On a Mac, you can do this with `brew install sox --with-flac`
# 2) You'll also need an API key for your Google Cloud Platform project:
# Create a request file with our JSON request in the current directory
FILENAME="request-"`date +"%s".json`
sararob / count-adjectives.sql
Last active Nov 20, 2016
Count all adjectives in tweets about Hillary and Trump in BigQuery
View count-adjectives.sql
COUNT(*) as c, adjective, subject
(SELECT tokens FROM [sara-bigquery:syntax.election_tweets]),
"[{ name: 'adjective', type: 'string'},
{name: 'subject', type: 'string'}
"function(row, emit) {
sararob / upvote-security-rules.json
Created Aug 25, 2015
Upvoting example for Firebase security rules
View upvote-security-rules.json
"rules": {
".read": true,
"articles": {
"$article": {
"title": {
".write": "auth != null",
".validate": "newData.isString() && newData.val() != ''"
"url": {