Skip to content

Instantly share code, notes, and snippets.

@mhawksey
mhawksey / sneek peak
Created January 29, 2014 21:37
Gmail 'sneak peak' bookmarklet. Add as a browser shortcut and when in Gmail clicking it will give basic extended popup on messages. Made with http://benalman.com/projects/run-jquery-code-bookmarklet/
javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.createElement("script");c.type="text/javascript";c.src="//ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function(){if(!b&&(!(d=this.readyState)||d=="loaded"||d=="complete")){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,"2.0.3",function($,L){$('span.y2').each(function(){$(this).attr('title', $(this).text())});});
@mhawksey
mhawksey / gist:8953096
Last active August 29, 2015 13:56
Google interactive chart with image fallback
<script data-cfasync="false" type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js"> {
"dataSourceUrl": "//docs.google.com/spreadsheet/tq?key=0AqGkLMU9sHmLdEJRZ3JkZmI2dGJpZXprNkNfRFhtWnc&transpose=0&headers=1&range=B1%3AF169&gid=1&pub=1",
"options": {
"titleTextStyle": {
"bold": true,
"color": "#000",
"fontSize": 16
},
"fontName": "Tahoma",
"animation": {
@mhawksey
mhawksey / index.html
Last active August 29, 2015 13:57
setQuery test for Visualization API
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
@mhawksey
mhawksey / index.html
Created March 18, 2014 21:02
setQuery test for Visualization API
<!--
You are free to copy and use this sample in accordance with the terms of the
Apache license (http://www.apache.org/licenses/LICENSE-2.0.html)
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
@mhawksey
mhawksey / gist:9659908
Created March 20, 2014 09:06
Google Apps Script-let for timestamping a Google Document footer
// modified from http://binarywaste.blogspot.co.uk/2013/06/google-docs-inserting-date-in-footer.html
function timeStampFooter() {
var doc = DocumentApp.getActiveDocument();
var footer = (doc.getFooter()) ? doc.getFooter() : doc.addFooter();
footer.setText("");
var divider = footer.appendHorizontalRule();
var footerText = footer.appendParagraph('Confidential and Proprietary + Accessed ' + new Date());
footerText.setFontSize(9);
footerText.setForegroundColor('#4a86e8');
footerText.setAlignment(DocumentApp.HorizontalAlignment.RIGHT);
@mhawksey
mhawksey / gist:11234995
Last active August 29, 2015 14:00
Google Apps Script equivalent to import.io PHP example - see http://mashe.hawksey.info/2014/04/using-google-apps-script-integrate-import-io/
var userGuid = "5895d593-9461-4b8b-8452-95bb82458bd2";
var apiKey = "YOUR_API_KEY";
/**
* Query importio for data.
*
* @param {string} connectorGuid the number we're raising to a power
* @param {object} input the exponent we're raising the base to
* @param {string} userGuid the exponent we're raising the base to
* @param {string} apiKey the exponent we're raising the base to
@mhawksey
mhawksey / gist:cd972b6e4e00d3fc3423
Last active August 29, 2015 14:01
import.io with Google Apps Script example (sending data as email)
function getImportio() {
var url = "YOUR_IMPORTHTML_URL";
/*
* Class UrlFetchApp
*
* Fetch resources and communicate with other hosts over the Internet. This service allows
* scripts to communicate with other applications or access other resources on the web by
* fetching URLs. A script can use the URL Fetch service to issue HTTP and HTTPS requests
* and receive responses. The URL Fetch service uses Google's network infrastructure for
@mhawksey
mhawksey / gist:ae3f39a3a5e02a025da2
Created May 19, 2014 22:16
import.io with Google Apps Script example (writing to sheet)
function getImportioToSheet() {
var url = "YOUR_IMPORTHTML_URL_FORMAT_JSON";
var resp = UrlFetchApp.fetch(url);
var data = JSON.parse(resp.getContentText());
// handling JSON response turning into 2d array [][]
var ioData = data.results;
var tbl = [];
tbl.push(Object.keys(ioData[0])); // extracting a header
for (var i = 0; i < ioData.length; ++i){
<script type="text/javascript">
google.load('visualization', '1.1', {packages: ['corechart','charteditor']});
</script>
<script type="text/javascript">
var $jq = jQuery.noConflict();
// set some globals
var headings,demos;
var colNames = {};
var globalColIdx = {};
var data = {};
@mhawksey
mhawksey / sunrise.php
Created June 17, 2014 12:10
Example sunrise.php file for nest wordpress sub directories as described in http://www.paulund.co.uk/wordpress-multisite-nested-paths
<?php
if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
$current_site->id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1);
$current_site->domain = $domain = DOMAIN_CURRENT_SITE;
$current_site->path = $path = PATH_CURRENT_SITE;
if( defined( 'BLOGID_CURRENT_SITE' ) )
$current_site->blog_id = BLOGID_CURRENT_SITE;
$url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );