Skip to content

Instantly share code, notes, and snippets.

/*
You need to fix some HTML first. Find <div class="header">, third tag within the body, and delete the 'style' attribute.
It's overriding some of the CSS, which causes some funk.
*/
/* find #header on line 1703 of index.html and delete: */
#header {
background-color: #222222;
}
@bennettscience
bennettscience / getPlainText.js
Created October 14, 2015 20:22
Takes a window selection and downloads a plaintext file.
var text = "";
function getPlainText() {
if(window.getSelection == undefined) {
alert("There is no text selected. Please select some text from the page and try again.")
} else {
text = window.getSelection().toString();
console.log(text);
var download = document.getElementById('download');
download.href = 'data:text/plain;charset:utf-8,' + encodeURIComponent(text);
@bennettscience
bennettscience / spamReport.gs
Created October 15, 2015 19:16
Reports Twitter spam from a Google Sheet archive.
function reportSpam() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Archive');
var range = sheet.getRange(2, 1,sheet.getLastRow(), sheet.getLastColumn());
var cells = range.getValues();
// Loop through the range where [i] is the ROW
for(var i=0;i<cells.length;i++) {
// Look for profile ID's matching spam websites
@bennettscience
bennettscience / articleFormatter.gs
Created January 10, 2016 19:08
Formats a Google Document for close reading and annotation by students.
// For close reading, it's important to have ordered and numbered paragraphs.
// This script takes the text and formats it based on paragraph breaks.
// More on this script at http://blog.ohheybrian.com
function formatArticle(){
var doc = DocumentApp.getActiveDocument()
var body = doc.getBody();
// Get the paragraphs
var paras = body.getParagraphs();
@bennettscience
bennettscience / hypothesis.gs
Last active June 9, 2016 03:41
Google Apps Script for interacting with the Hypothes.is API
function hypothesis() {
// Check Drive for an existing document with annotations. If one isn't present, create it.
var docs = DriveApp.getFilesByName('Hypothes.is Annotations');
if(docs.hasNext()) {
var doc = docs.next();
var id = doc.getId();
} else {
var doc = DocumentApp.create('Hypothes.is Annotations');
var id = doc.getId();
@bennettscience
bennettscience / comment
Created July 15, 2016 19:51
Comment posted to lisa dabbs blog re: use of Periscope in education
Hi Lisa,
I want to push back on the idea that new teachers should jump into using Periscope. Yes, it's important to share and get feedback and it can be a great way to do that. But jumping right in and sharing <i>student</i> images and <i>student</i> information without at least mentioning the Terms of Use and Privacy Statements is, in my opinion, dangerous.
From the Periscope Privacy Statement (my emphasis added):
<b>We use and store information about your location</b> to provide features of our Services, such as broadcasting with your location, and to improve and customize the Services. We may infer your location based on information from your device. <b>If you have turned on location services for Periscope, we may share your precise location.</b>
There is no limitation on how long they store that information. If a new teacher is broadcasting and a student with limitations from their parents is included in that broadcast, that can lead to serious issues. Broadcasting specific location data is never a wi
@bennettscience
bennettscience / postToTrello.gs
Last active August 5, 2016 00:16
Post Google Spreadsheet submissions as new Trello cards
// Stored variables for POST request to Trello API
// An app authorization token needs to be requested via the URL:
// https://trello.com/1/authorize?key=YOUR_APP_KEY&name=APP_NAME&scope=read,write&expiration=never&response_type=token
var API_KEY = yourKeyHere;
var TOKEN = yourAuthTokenHere;
var ID_LIST = listToPostToHere;
// Collect data and post it as a Trello card
// Trigger set to run each time the spreadsheet has a new row added
function postToTrello(name, author, description, trelloIdList) {
@bennettscience
bennettscience / pageAction.js
Created September 19, 2016 14:09
JS Source files for the church mission wall project
// Listen for user input and display a prompt if none for 30 seconds.
$(document).ready(function() {
var i = null;
$("#body-wrap").mousemove(function() {
clearTimeout(i);
$("#overlay").fadeOut();
i = setTimeout(function() {
$("#overlay").fadeIn();
}, 20000);
@bennettscience
bennettscience / shutwake.sh
Created September 19, 2016 14:27
Bash script to automate shutdown and startup of a kiosk computer
#! /bin/bash
echo 0 > /sys/class/rtc/rtc0/wakealarm
echo `date '+%s' -d '+ 10 minutes'` > /sys/class/rtc/rtc0/wakealarm
shutdown
@bennettscience
bennettscience / showDates.gs
Created October 21, 2016 01:39
Script to loop through a Google sheet and set returned data as a note on a selected cell.
// Globals yada yada
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var ui = SpreadsheetApp.getUi();
// Once all is said and done, add the info to the selected cell
function addNote(e) {
var cell = sheet.getActiveCell();
cell.setNote(e);
}