Skip to content

Instantly share code, notes, and snippets.

View schlos's full-sized avatar

Miroslav schlos

View GitHub Profile
@schlos
schlos / gist:98ae7f2b31aa97c784cb126cdbdd62d4
Created August 24, 2018 21:29 — forked from mhawksey/gist:1170597
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
// Part of this code up to END OF (c) is:
/*
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
@schlos
schlos / gist:e0888ced78698e7846dd603ff04919dd
Created August 24, 2018 21:05 — forked from mhawksey/gist:1643207
EventManager v3.1.2
// EventManagerV3 glued together by mhawksey http://www.google.com/profiles/m.hawksey
// Related blog post http://mashe.hawksey.info/eventmanagerv3/
// With some code (settings, importIntoCalendar, sendEmails) from
// Romain Vialard's http://www.google.com/profiles/romain.vialard
// Manage your events: Calendar Importer and Registration Form
// https://spreadsheets.google.com/ccc?key=tCHuQkkKh_r69bQGt4yJmNQ
var ss = SpreadsheetApp.getActiveSpreadsheet();
var BOOKING_ACTION_COL = 10;
@schlos
schlos / code
Created August 24, 2018 20:50 — forked from mhawksey/code
Google Apps Script snippet that send a thank you response based on supplied email
function sendEmail(e) {
var emailTo = e.namedValues['20. Email confirmation (and badge)'][0];
if (emailTo != ""){
var text = 'Thank you for taking time to complete the ALT Annual Survey 2014. You can help us get a better understanding of how learning technology is used across sectors by sharing this link to the survey with your community: http://go.alt.ac.uk/ALT-Survey-2014\n\nYou might also use this suggested text in a tweet:\n\n " Just completed the ALT Annual Survey 2014 exploring use of learning technology across sectors. Have your say http://go.alt.ac.uk/ALT-Survey-2014 #altc "';
var textHtml = HtmlService.createHtmlOutputFromFile('mailText').getContent();
MailApp.sendEmail(emailTo,
"Thank you for completing the ALT Annual Survey 2014",
text,
{replyTo:"enquiries@alt.ac.uk", htmlBody: textHtml});
}
@schlos
schlos / importioAuthExample.gs
Created August 24, 2018 20:49 — forked from mhawksey/importioAuthExample.gs
Google Apps Script version for using import.io authenticated data sources http://blog.import.io/post/using-importio-authenticated-data-sources-with-php-and-go
function getResults() {
var connector = {'username':'YOUR_SITE_USERNAME',
'password':'YOUR_SITE_PASSWORD',
'connectorDomain':'YOUR_CONNECTOR_DOMAIN',
'userGuid':'YOUR_USER_GUID',
'connectorGuid':'YOUR_CONNECTOR_GUID',
'apiKey':'YOUR_API_KEY'}
var creds = {};
creds[connector.connectorDomain] = {
@schlos
schlos / quickstart.html
Created August 24, 2018 20:48 — forked from mhawksey/quickstart.html
Google Sheets as a Database – Authenticated INSERT with Apps Script using Execution API - Working Example
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Google Sheets as a Database – Authenticated INSERT with Apps Script using Execution API - Working Example</title>
<script type="text/javascript">
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
var CLIENT_ID = '<INSERT_YOUR_CLIENT_ID>';
var SCRIPT_ID = '<INSERT_YOUR_SCRIPT_ID>';
@schlos
schlos / GoogleAppsScript2GitHub.gs
Created August 24, 2018 20:47 — forked from mhawksey/GoogleAppsScript2GitHub.gs
Example script that demonstrates how you can commit files to Github using Google Apps Script. If copying into a script project remembers to add a oAuth2 library https://github.com/googlesamples/apps-script-oauth2. More info in this post https://mashe.hawksey.info/?p=17293
/*
To use you need to create an application on Github at https://github.com/settings/developers
The callback in this needs to be set to https://script.google.com/macros/d/{SCRIPT ID}/usercallback
Where {SCRIPT ID} is the ID of the script that is using this library. You can find your script's ID in the Apps Script code editor by clicking on the menu item "File > Project properties".
In this example code I've stored the apllicaitons clientId and clientSecret in the Script Properties:
- git_clientId
- git_clientSecret
@schlos
schlos / sendvotes.gs
Created August 24, 2018 20:43 — forked from mhawksey/sendvotes.gs
Short Google Apps Script snippet that pushes from:, subject and date to a Google Sheet (designed to be triggered frequently). I use the snippet to collect votes sent via email
function myFunction() {
try {
var out = [];
if (GmailApp.getInboxUnreadCount() > 0 ){
var threads = GmailApp.getInboxThreads();
for (var i = 0; i < threads.length; i++) {
out.push([threads[i].getMessages()[0].getFrom(), threads[i].getFirstMessageSubject(), threads[i].getMessages()[0].getDate()]);
threads[i].moveToArchive();
}
@schlos
schlos / slide_template.gs
Last active October 14, 2020 20:49 — forked from mhawksey/slide_template.gs
Port of Wesley Chun's 'Using the Google Slides API with Python' to Google Apps Script. Read more at https://mashe.hawksey.info/?p=17385
// Port of Slides API demo by Wesley Chun to Google Apps Script
// Source: http://wescpy.blogspot.co.uk/2016/11/using-google-slides-api-with-python.html
function slides_template() {
/*
from apiclient import discovery
from httplib2 import Http
from oauth2client import file, client, tools
*/
@schlos
schlos / Code.gs
Created August 24, 2018 20:38 — forked from mhawksey/Code.gs
Automatically include your latest favorited Tweet in your Gmail signature. More info https://knoll.tech/2017/01/24/automatically-include-your-latest-tweet-in-your-gmail-signature/
// Grabs my latest tweet favorited using the handy TwtrService wrapper by +MartinHawksey - https://goo.gl/2it7yb
function getLatestTweet() {
var data = TwtrService.get("statuses/user_timeline", {screen_name: /*"YourTwitterHandle(without the @)"*/, count: 1});
var id = false;
for (var i = 0; i < data.length; i++){
if (data[i].favorited) {
id = data[i].id_str;
break;
}
}