Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian bennettscience

View GitHub Profile
View Create QR in Google Sheets
=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="&someCellReference)
View Google Script to shorten URLs.
// 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 Aug 13, 2015
Getting Inline Drawings from Google Docs
View inlineDrawing
// 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);
View 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.
View server.gs
/*
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');
}
View wordFormatter.gs
// 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 Sep 22, 2015
CSS styles for zachcresswell.org landing page
View newCSS.css
/* 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 Sep 24, 2015
Google Drive public dropbox upload
View form.html
<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 Sep 29, 2015
Generates an HTML page based on form input data. This source should be hosted as a webpage.
View template.html
<html>
<head>
<style type="text/css" media="screen"> <!-- Style the template -->
html,body {
margin:0;
padding:0;
}
p {
color:#8f8f8f;
font-family:Arial;
You can’t perform that action at this time.