Skip to content

Instantly share code, notes, and snippets.

=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="&someCellReference)
// Grabbed from http://webapps.stackexchange.com/questions/76050/google-sheets-function-to-get-a-shortened-url-from-bit-ly-or-goo-gl-etc
// Add a menu action item when the sheet is opened.
function onOpen() {
SpreadsheetApp.getUi()
.createMenu("Shorten")
.addItem("Go !!","rangeShort")
.addToUi()
}
@bennettscience
bennettscience / inlineDrawing
Created August 13, 2015 16:07
Getting Inline Drawings from Google Docs
// Don't forget your global variables up top.
// Search through the page elements. Paragraphs are top-level, which is why I start with those.
if( type == DocumentApp.ElementType.PARAGRAPH ){
// Look for child elements within the paragraph. Inline Drawings are children.
if(element.asParagraph().getNumChildren() !=0 && element.asParagraph().getChild(0).getType() == DocumentApp.ElementType.INLINE_DRAWING) {
// For whatever reason, drawings don't have their own methods in the InlineDrawing class. This bit copies and adds it to the bottom of the doc.
var drawing = element.asParagraph().copy();
body.appendParagraph(drawing);
@bennettscience
bennettscience / doctranslate.gs
Last active August 29, 2015 14:27
docTranslate.gs
// This function converts a document from English to Spanish quickly.
// The post from http://stackoverflow.com/questions/25509159/how-i-can-get-the-textwrap-image-in-google-doc/25509591#25509591
// was helpful for creating the logic to check for images in the document.
function translate() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
// Add a page break for the translated material.
body.appendPageBreak();
We couldn’t find that file to show.
/*
This is based on the template shared by Amit Agarwal (@labnol) on
the blog, Digital Inspiration. The original post with instructions:
http://www.labnol.org/internet/receive-files-in-google-drive/19697/
*/
// Find the form that is collecting the information to upload.
function doGet(e) {
return HtmlService.createHtmlOutputFromFile('form.html');
}
// Add a custom menu item to the document when opened.
function onOpen() {
var ui = DocumentApp.getUi()
.createMenu('Set Fonts')
.addItem('Run','setFont')
.addToUi();
}
function setFont(){
var doc = DocumentApp.getActiveDocument();
@bennettscience
bennettscience / newCSS.css
Created September 22, 2015 16:01
CSS styles for zachcresswell.org landing page
/* Copy this CSS into the CSS Editor from the wp-admin dashboard */
#main {
display: block;
float: left;
margin: 0 auto;
width: 100%;
}
/* Modify only the style of the landing page post ID */
#post-1301 .entry-content {
@bennettscience
bennettscience / form.html
Created September 24, 2015 15:56
Google Drive public dropbox upload
<html>
<body>
<div id="wrapper">
<h1>Student Work Submission</h1>
<form id="myForm">
<input type="text" name="myName" placeholder="Your name.." />
<select name="classPer">
<option>P1</option>
<option>P2</option>
<option>P3</option>
@bennettscience
bennettscience / template.html
Last active April 13, 2023 14:46
Generates an HTML page based on form input data. This source should be hosted as a webpage.
<html>
<head>
<style type="text/css" media="screen"> <!-- Style the template -->
html,body {
margin:0;
padding:0;
}
p {
color:#8f8f8f;
font-family:Arial;