Skip to content

Instantly share code, notes, and snippets.

@mhawksey
mhawksey / html5reset.css
Created May 17, 2011 08:36
Instant Google Custom Search Engine
<!DOCTYPE html>
<html lang="en">
<head>
<title>Instant Google Custom Search Engine (CSE)</title>
<meta charset="utf-8">
<meta name="description" content="Google Custom Instant">
<link href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="html5reset.css" type="text/css" media="screen">
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
@mhawksey
mhawksey / regform.php
Created May 27, 2011 15:43
Embedding and customising a Google Form in WordPress example (with dynamic parallel session selection)
<?php
$formKey = "blahblahblah"; // ENTER YOUR OWN VALUE - you can find your formkey by going to your live form in the spreadsheet and copying the value from the url
$redirectUrl = "http://www.yoursite.com/thank-you/"; // ENTER YOUR OWN VALUE - the url you want to direct people to after they fill in the form
$dataUrl = "https://spreadsheets0.google.com/spreadsheet/pub?blahblahblah&single=true&gid=1&output=csv"; // ENTER YOUR OWN VALUE - for parallel sessions you need to publish the public sheet via the share settings. This url is not published in the live webpage source
// function to get external webpages/data
function getData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@mhawksey
mhawksey / regform-notemplate.php
Created May 31, 2011 10:42
Embedding and customising a Google Form (with dynamic parallel session selection)
<?php
$formKey = "blahblahblah"; // ENTER YOUR OWN VALUE - you can find your formkey by going to your live form in the spreadsheet and copying the value from the url
$redirectUrl = "http://www.yoursite.com/thank-you/"; // ENTER YOUR OWN VALUE - the url you want to direct people to after they fill in the form
$dataUrl = "https://spreadsheets0.google.com/spreadsheet/pub?blahblahblah&single=true&gid=1&output=csv"; // ENTER YOUR OWN VALUE - for parallel sessions you need to publish the public sheet via the share settings. This url is not published in the live webpage source
// function to get external webpages/data
function getData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
@mhawksey
mhawksey / gist:1014281
Created June 8, 2011 11:51
twitteralytics v2.2 - using oAuth for increased rate on search results
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sumSheet = ss.getSheetByName("Readme/Settings");
var REFERER = sumSheet.getRange("B9").getValue();
var SEARCH_TERM = sumSheet.getRange("B10").getValue();
var SEARCH_DURATION = sumSheet.getRange("B11").getValue();
var NUMBER_OF_TWEETS = sumSheet.getRange("B12").getValue();
var RESULT_TYPE = sumSheet.getRange("B13").getValue();
function onOpen() {
var menuEntries = [ {name: "Test Collection", functionName: "testCollection"}, {name: "Run Now!", functionName: "collectTweets"} ];
@mhawksey
mhawksey / gist:1017960
Created June 9, 2011 22:52
Gets twitter connections for protovis network gadget
function getProtovisTwitterConnections(){
// This code is a reworking of code taken from Tony Hirst's (@psychemedia) Friendviz
// http://ouseful.open.ac.uk/twitter/friendviz.html
// Usage: Select a row or column of twitter usernames from a sheet (without '@') then run this function
// This creates a new sheet called pData with data formatted for the Graphing Connections Between
// Recent Twitterers (Protovis Demo) gadget. To graph the results from the main spreadsheet select
// Insert -> Gadget and enter a Custom url to http://hosting.gmodules.com/ig/gadgets/file/108150762089462716664/friendviz.xml
// The data range for the gadget is pData!A1:B2
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getActiveSheet();
@mhawksey
mhawksey / gist:1029258
Created June 16, 2011 13:47
Google Apps Script to display email notification
function doGet(e) {
try{
var app = UiApp.createApplication();
var mainPanel = app.createVerticalPanel();
var emailTable = app.createFlexTable().setId("emailTable");
app.add(mainPanel);
mainPanel.add(emailTable);
var mail = GmailApp.getInboxThreads(0, 10);
for (var i = mail.length; i > 0; i--) {
var msg = mail[i-1];
/*
Copyright 2011 Martin Hawksey and Dito LLC
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 / gist:1067246
Last active September 26, 2015 08:17
IMPORTANT This is a better way of doing this --> https://gist.github.com/4641774 Automatically create new spreadsheet for each user completing a form. Used in http://mashe.hawksey.info/2011/07/apps-script-intro-form-split/
// This code has been developed for Google Apps Script
/*
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
@mhawksey
mhawksey / gist:1067301
Created July 6, 2011 14:06
Automatically create new sheet for each user completing a form. Used in http://mashe.hawksey.info/2011/07/apps-script-intro-form-split/
/*
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 / gist:1080389
Created July 13, 2011 14:26
Friendviz add-on for Twitteralytics
function getProtovisTwitterConnections(){
// This code is a reworking of code taken from Tony Hirst's (@psychemedia) Friendviz
// http://ouseful.open.ac.uk/twitter/friendviz.html
// Usage: Select a row or column of twitter usernames from a sheet (without '@') then run this function
// This creates a new sheet called pData with data formatted for the Graphing Connections Between
// Recent Twitterers (Protovis Demo) gadget. To graph the results from the main spreadsheet select
// Insert -> Gadget and enter a Custom url to http://hosting.gmodules.com/ig/gadgets/file/108150762089462716664/friendviz.xml
// The data range for the gadget is pData!A1:B2
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName("Summary")