This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ts = require('typescript'); | |
var t = ts.transpile(s, { | |
compilerOptions: { | |
strict: true, | |
lib: ["es2015"], | |
} | |
}); | |
console.log(t); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)}); | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "attach", | |
"name": "Attach", | |
"port": 9229 | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"debug.node.autoAttach": "on" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {google} = require('googleapis'); | |
/** | |
* Returns a list of Google APIs and their descriptions. | |
* @param {Express.Request} req The API request. | |
* @param {Express.Response} res The API response. | |
*/ | |
exports.listGoogleAPIs = async (req, res) => { | |
// Call the API | |
const apis = await google.discovery('v1').apis.list(); | |
// Build the response |