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
grant / btc_sheets.js
Last active Apr 12, 2019
BTC API – GCF + Apps Script
View btc_sheets.js
/**
* Get's the bitcoin price at a date.
*
* @param {string} date The date in yyyy-MM-dd format. Defaults to today.
* @return The value of BTC in USD at the date. From Coinbase's API
* @customfunction
*/
function BTC_CF(date) {
var dateString = Utilities.formatDate(new Date(date), "GMT", "yyyy-MM-dd");
var res = UrlFetchApp.fetch("https://us-central1-new-project-as-test.cloudfunctions.net/btc?date=" + dateString);
@grant
grant / btc.js
Created Apr 12, 2019
BTC API – GCF
View btc.js
const rp = require('request-promise');
const DEFAULT_DATE = '2019-04-10';
exports.btc = async (req, res) => {
const date = req.query.date || DEFAULT_DATE;
async function getBTC(date) {
const res = await rp(`https://api.coinbase.com/v2/prices/BTC-USD/spot?date=${date}`, {
headers: {
'CB-VERSION': '2016-10-10',
Authorization: `Bearer ${process.env.COINBASE_TOKEN}`
View index.js
// server
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
// client
var b = fetch('https://us-central1-{project}.cloudfunctions.net/{method}').then((response) => {
const a = response.json().then(c => {console.log(c)});
})
View index.js
/**
* Responds to any HTTP request.
*
* @param {!express:Request} req HTTP request context.
* @param {!express:Response} res HTTP response context.
*/
exports.helloWorld = (req, res) => {
let message = req.query.message || req.body.message || 'Hello World!';
res.status(200)
.set('Content-Type', 'text/html')
@grant
grant / listGmailLabels.js
Created Oct 30, 2018
Lists Gmail Labels in Apps Script
View listGmailLabels.js
function myFunction() {
var labels = GmailApp.getUserLabels();
labels[0].getName()
var sortedLabels = labels.sort(function (label1, label2) {
var a = label1.getName().toLowerCase();
var b = label2.getName().toLowerCase();
if(a < b) { return -1; }
if(a > b) { return 1; }
return 0;
})
@grant
grant / saxophone.js
Created Jul 24, 2018
Create a Saxophone tutorial presentation
View saxophone.js
var PRESENTATION_TITLE = 'Saxophone Tutorials';
var YOUTUBE_QUERY = 'saxophone tutorials';
/**
* Gets a list of YouTube videos.
* @param {String} query - The query term to search for.
* @ref https://developers.google.com/youtube/v3/docs/search/list
*/
function getYouTubeVideosJSON(query) {
var youTubeResults = YouTube.Search.list('id,snippet', {
View clasp.ts
var ts = require('typescript');
var t = ts.transpile(s, {
compilerOptions: {
strict: true,
lib: ["es2015"],
}
});
console.log(t);
View cal.js
var fs = require('fs');
var readline = require('readline');
var google = require('googleapis');
var googleAuth = require('google-auth-library');
// If modifying these scopes, delete your previously saved credentials
// at ~/.credentials/calendar-nodejs-quickstart.json
var SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
var TOKEN_PATH = 'creds.json';
@grant
grant / TestGoogleAPIs.go
Created Dec 21, 2017
Produces a list of Google APIs
View TestGoogleAPIs.go
package snippets
import (
"testing"
"github.com/stretchr/testify/assert"
"net/http"
"time"
"encoding/json"
"log"
"fmt"
@grant
grant / quickstart.go
Last active Dec 6, 2017
Sheets Quickstart – Go alternative (developers.google.com/sheets/api/quickstart/go)
View quickstart.go
package main
import (
"fmt"
"log"
)
// https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
var SpreadsheetId = "1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms"
You can’t perform that action at this time.