Skip to content

Instantly share code, notes, and snippets.

@mhawksey
mhawksey / gist:1170597
Created August 25, 2011 13:02
Google Apps Script to fill in a Document template with Spreadsheet data
function onOpen() {
var menuEntries = [ {name: "Create Diary Doc from Sheet", functionName: "createDocFromSheet"}];
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.addMenu("Fitness Diaries", menuEntries);
}
function createDocFromSheet(){
var templateid = "1O4afl8SZmMxMFpAiN16VZIddJDaFdeRBbFyBtJvepwM"; // get template file id
var FOLDER_NAME = "Fitness Diaries"; // folder name of where to put completed diaries
// get the data from an individual user
@mhawksey
mhawksey / gist:1172082
Created August 25, 2011 21:50
for app workshop
martin@hawksey.info
test1@hawksey.info
test2@hawksey.info
test3@hawksey.info
test4@hawksey.info
test5@hawksey.info
test6@hawksey.info
test7@hawksey.info
test8@hawksey.info
test9@hawksey.info
@mhawksey
mhawksey / gist:1247932
Last active August 14, 2018 17:27
Google Apps Script to get viralheat sentiment analysis for a bunch of cells
var VIRAL_KEY = "YOUR_API_KEY"; // your viralheat API key. Register at https://viralheat.com/register
var doc = SpreadsheetApp.getActiveSpreadsheet(); // sets the current spreadsheet
var sheet = doc.getSheetByName("Main"); // defines we are working from the sheet named Main
var START_ROW = 2; // location of first row of data
var TEXT_COL = 1; // the column number of where the text you want to analyse is
var MOOD_COL = 6; // the column number of where you want to record the mood returned by viralheat
var PROB_COL = 7; // the column number of where you want to record the probability that the mood is correct
function getStats() {
var last = sheet.getLastRow(); // find the last row in the sheet
@mhawksey
mhawksey / gist:1258908
Created October 3, 2011 11:17
Snippet to pass current page url to FiveFilters.org Kindle It service (used in blog sidebar)
<p>You can also download this post as:</p>
<p align="center"><strong>
<script type="text/javascript">var l = encodeURIComponent(document.URL);
document.write('<a href="http://fivefilters.org/kindle-it/send.php?url='+l+'&submit=Preview">Kindle It</a> | <a href="http://fivefilters.org/kindle-it/send.php?context=download&format=epub&url='+l+'">ePub</a> | <a href="http://fivefilters.org/kindle-it/send.php?context=download&format=mobi&url='+l+'">mobi</a>');</script></strong></p>
<p align="center">Powered by <a href="http://fivefilters.org/kindle-it/">FiveFilters.org</a> (<a href="http://fivefilters.org/fundraising/donate.php?id=kindle-it-v1">donate</a>)</p>
@mhawksey
mhawksey / gist:1260250
Created October 3, 2011 21:04
Kindle It widget
l = 'http://fivefilters.org/kindle-it/send.php?url='+encodeURIComponent(window.location.href);
e = l+'&context=download&format=epub';
m = l+'&context=download&format=mobi';
function pop(){
h = 527;
w = 873;
wd = window.open(l, 'KindleIt','scrollbars=no,menubar=no,height='+h+',width='+w+',resizable=yes,toolbar=no,location=no,status=no,top='+((screen.height/2)-(h/2))+',left='+((screen.width/2)-(w/2)));
}
document.write('<p style="text-align:center;font-weight:bold;"><a href="javascript:void(0);" onclick="pop()">Kindle It</a> | <a href="'+e+'" target"_blank">ePub</a> | <a href="'+m+'" target"_blank">mobi</a></p>');
document.write('<p style="text-align:center;">Powered by <a href="http://fivefilters.org/kindle-it/">FiveFilters.org</a> (<a href="http://fivefilters.org/fundraising/donate.php?id=kindle-it-v1">donate</a>)</p>');
@mhawksey
mhawksey / gist:1276293
Last active October 23, 2023 09:00
Google App Script to insert data to a google spreadsheet via POST or GET - updated version as per https://mashe.hawksey.info/2014/07/google-sheets-as-a-database-insert-with-apps-script-using-postget-methods-with-ajax-example/
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@mhawksey
mhawksey / index.html
Created October 12, 2011 16:56
SpreadEmbed - Simple site to convert Google Spreadsheet column of links into objects using embed.ly
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>SpreadEmbed</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" src="jquery.embedly.min.js"></script>
<script type="text/javascript">
google.load('visualization', '1');
@mhawksey
mhawksey / index.html
Created October 13, 2011 20:45 — forked from yohman/index.html
Guardian Tag Explorer
<!DOCTYPE html>
<html>
<head>
<title>Guardian Tag Explorer</title>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.geom.js?1.29.1"></script>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.layout.js?1.29.1"></script>
<link href='http://fonts.googleapis.com/css?family=Ubuntu:500' rel='stylesheet' type='text/css'>
<link href="http://jqueryui.com/themes/base/jquery.ui.all.css" type="text/css" rel="stylesheet" />
@mhawksey
mhawksey / force.json
Created October 20, 2011 08:43
Export example from NodeXL
{
"nodes": [
{"id":0, "name": "Twitter Powered Subtitles for Conference Audio/Videos on Youtube", "url":"http://blog.ouseful.info/2009/03/08/twitter-powered-subtitles-for-conference-audiovideos-on-youtube/", "nodeSize":2.12},
{"id":1, "name": "Twitter Powered Youtube Subtitles, Reprise: Anytime Commenting", "url":"http://blog.ouseful.info/2009/03/10/twitter-powered-youtube-subtitles-reprise-anytime-commenting/", "nodeSize":1.7},
{"id":2, "name": "Twitter Powered Subtitles for BBC iPlayer Content c/o the MASHe Blog", "url":"http://blog.ouseful.info/2010/02/17/twitter-powered-subtitles-for-bbc-iplayer-content-co-the-mashe-blog/", "nodeSize":1.91},
{"id":3, "name": "Scheduling Content Round the Edges – Supporting OU/BBC Co-Productions", "url":"http://blog.ouseful.info/2010/02/22/scheduling-content-round-the-edges-supporting-oubbc-co_productions/", "nodeSize":1.55},
{"id":4, "name": "Maintaining a Google Calendar from a Google Spreadsheet, Reprise", "url":"http://blog.ouseful.info/2010/03/07/maintaining-a-goo
@mhawksey
mhawksey / googPlusFrFo-preliminarySketch.py
Created October 20, 2011 17:02 — forked from psychemedia/googPlusFrFo-preliminarySketch.py
First doodling around a Google Plus friends/followers network grapher
# ABOUT:
# A script that grabs a list of the friends or followers of one or more folk on Google+,
# grabs a sample of their friends, and generates the resulting social graph
# USAGE:
# Requirements: networkx (see DEPENDENCIES)
# Configuration: see CONFIGURATION
# Output: files will be save to the reports directory
# To run the script:
# 1) Download this file to a directory somewhere as eg googPlusFrFo-preliminarySketch.py