Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian bennettscience

View GitHub Profile
@bennettscience
bennettscience / clearChildNotes.gs
Created Jan 15, 2019
Copy notes between Google Sheets
View clearChildNotes.gs
// If you make a mistake, this will clear all notes from the child sheets
function clearChildNotes() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet2');
var buildings = sheet.getRange(1, 1, sheet.getLastRow(), 3).getValues();
for(var i=0; i<buildings.length; i++) {
SpreadsheetApp.openByUrl(buildings[i][1]).getSheetByName('Sheet1').clearNotes();
}
}
@bennettscience
bennettscience / Code.gs
Created Mar 29, 2018
Event manager Apps Script webapp
View Code.gs
var ss = SpreadsheetApp.getActiveSpreadsheet();
/**
* doGet - Return webapp
*
* @param {String} e query string to serve different pages
* @returns {String} rendered HTML to the browser
*/
function doGet(e) {
if (!e.parameter.page) {
@bennettscience
bennettscience / onEdit.gs
Last active Sep 30, 2020
Dynamic data validation in Apps Script
View onEdit.gs
function onEdit(e) {
var row = e.range.getRow();
var col = e.range.getColumn();
// If the edited column was 2 or 3, do the next part. Ignore other changes
if(col == 2 || col == 3) {
var value = sheet.getRange(row, col).getValue();
updateList(row,col, value);
}
}
@bennettscience
bennettscience / helpbotBrain.gs
Last active Mar 22, 2018
Main files for an apps script bot and webapp pair
View helpbotBrain.gs
/**
* getLookup - Get an array of videos matching the search key request
*
* @param {Object[]} keys - Array of search terms
* @returns {Object[]} matches - Array of video objects matched to the tag
*/
function getLookup(keys) {
var sheet = ss.getSheetByName("db");
var data = sheet.getDataRange().getValues();
@bennettscience
bennettscience / config
Created Mar 17, 2018
git config sample
View config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
@bennettscience
bennettscience / outcome.py
Created Feb 1, 2018
Playing with the Canvas LMS python API
View outcome.py
from canvasapi import Canvas
API_URL = 'https://my.url.com'
API_KEY = 'mySTringKEy123'
canvas = Canvas(API_URL, API_KEY)
outcome = canvas.get_outcome(5426)
class Rating:
@bennettscience
bennettscience / comment.js
Created Dec 31, 2017
Push a comment to a firebase database from a static HTML page
View comment.js
$(function() {
var ref = new Firebase("https://nodes-commenting.firebaseio.com/"),
postRef = ref.child(window.location.pathname);
postRef.on("child_added", function(snapshot) {
var newPost = snapshot.val();
if(newPost.moderated) {
$("#comment-list").prepend('<div class="comment">' +
'<h4>' + escapeHtml(newPost.name) + '</h4>' +
'<div class="profile-image"><img src="http://www.gravatar.com/avatar/' + escapeHtml(newPost.md5Email) + '?s=100&d=retro"/></div> ' +
@bennettscience
bennettscience / index.js
Created Dec 31, 2017
Node JS function to watch Firebase realtime database
View index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const nodemailer = require('nodemailer');
admin.initializeApp(functions.config().firebase);
// set up email credentials in firebase.config
// See https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users for example
const gmailEmail = functions.config().gmail.email;
@bennettscience
bennettscience / code.gs
Last active Nov 28, 2017
Automatically create bit.ly shortlinks of Google Forms via the API
View code.gs
// Copyright 2017 Brian E. Bennett
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
@bennettscience
bennettscience / feedback.gs
Last active Sep 11, 2020
Automating feedback forms with Google Apps Script
View feedback.gs
// Copy this script into the feedback spreadsheet TEMPLATE
/************************ OnOpen *******************************/
function onOpen(e) {
var ui = SpreadsheetApp.getUi().createMenu("Shortlink")
.addItem("Show URL and QR code", "showQrAndLink")
.addToUi()
}
/************************ GLOBALS *******************************/
You can’t perform that action at this time.