Skip to content

Instantly share code, notes, and snippets.

@bennettscience
bennettscience / gifify2.sh
Last active September 8, 2017 18:51
gifify hack
#!/bin/bash
set -euo pipefail
function printHelpAndExit {
echo 'Usage:'
echo ' gifify [options] filename'
echo ''
echo 'Options: (all optional)'
echo ' c CROP: The x and y crops, from the top left of the image, i.e. 640:480'
@bennettscience
bennettscience / form.html
Created June 15, 2017 00:24
Form for Ray Bird snail mail
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Camp Ray Bird Summer Camp</title>
<meta name="description" content="Summer Camp and Mission Work at Camp Ray Bird"/>
<meta name="rating" content="safe for kids" />
<link rel="stylesheet" href="styles/style.css" type="text/css"/>
<script type="text/javascript">
@bennettscience
bennettscience / code.gs
Last active March 28, 2024 10:12
Custom course registration site with Google Apps Script
// ALL SERVER CODE RUNNING ON THE SPREADSHEET
// new property service GLOBAL
// see: https://developers.google.com/apps-script/reference/properties/
var SCRIPT_PROP = PropertiesService.getScriptProperties();
// Grab the correct spreadsheet
var sheet = SpreadsheetApp.openById("spreadsheetIdHere");
/**
@bennettscience
bennettscience / edit_content_img.php
Last active January 2, 2017 04:08
flickr RSS XML object
/* Put this into the WordPress functions.php file to embed a large image from the Flickr RSS feed */
function edit_content_img($content) {
$content = preg_replace("/(_m)/", "_b", $content);
return $content;
}
add_filter( 'the_content', 'edit_content_img');
@bennettscience
bennettscience / linkTranslatedDocs.gs
Created November 24, 2016 01:59
Link two documents for translation updates
var ui = DocumentApp.getUi();
var docProps = PropertiesService.getDocumentProperties();
// Grab the document body.
// No formatting, tables, etc are kept.
function getText() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
Logger.log(body.getText());
var array = [];
@bennettscience
bennettscience / assignCons.gs
Created November 18, 2016 16:35
Custom spreadsheet to track students missing an ID
/**
* @param {Obj} a - array from daily list built
**/
function assignCons(a) {
// These rely on the global variables set at the top of the script
var sheet = ss.getSheets()[2];
var data = sheet.getDataRange().getValues();
var target = ss.getSheets()[3].getRange("A2").getValue();
@bennettscience
bennettscience / code.gs
Last active November 8, 2016 02:34
Displaying data using AJAX from a Google Sheet
// Server side scripts to draw and load the page.
// Call the sheet
var ss = SpreadsheetApp.openById('SPREADSHEET_KEY');
// Initialize the HTMLService and draw the page from the template.
function doGet() {
return HtmlService
.createTemplateFromFile("index")
.evaluate();
@bennettscience
bennettscience / chart.gs
Last active September 19, 2018 07:58
Code to display Google Sheets data as a web-based dashboard
// Pie Chart visualization client-side scripting
// Initialize the script and grab the data from the spreadsheet.
google.script.run.withSuccessHandler(drawChart).getSpreadsheetData();
google.load("visualization", "1", {packages:["corechart"]});
// Using the returned data from the spreadsheet, draw the chart.
// ssData is a 2D array of the candidate name and their electoral vote totals from the spreadsheet.
function drawChart(ssData) {
@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);
}
@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