Skip to content

Instantly share code, notes, and snippets.

View jptrsn's full-sized avatar

Edu_Coder jptrsn

View GitHub Profile
@jptrsn
jptrsn / extendedRuntime.gs
Last active December 10, 2015 01:18
Extended Runtime
/* Time Loop Example to show how to store and self-trigger a script
* Written by James Petersen, http://www.opensourceteacher.ca
* Copyright 2015, published under a Creative Commons Attribution-ShareAlike 4.0 International Licence
*
* This example writes to the ScriptProperties and ScriptCache, which will be the same for all users of this script
* For a multi-user script (for example, a web app) a better approach would be to use the UserProperties and UserCache
* For a multi-document script (for example, an add-on), a better approach would be to use the DocumentProperties and DocumentCache
*/
// 5 minute run time. Use this for production
@jptrsn
jptrsn / Tweet_Button.xml
Last active December 10, 2015 01:42
Google Sites gadget to include a tweet button
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Tweet Button" title_url="http://www.opensourceteacher.ca/apps-script/tweet-button"
description="Add a button to let your website viewers tweet right from your pages."
thumbnail="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-thumb.png"
screenshot="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-ss.png"
height="23" width="65" author="Open Source Teacher">
</ModulePrefs>
<UserPref name="handle" display_name="Twitter Handle (no @ symbol)" required="true"/>
<UserPref name="message" display_name="Tweet content text" required="true"/>
/**
// Twitter Translator for the GEG Montreal
// Written by James Petersen, some time during 2014.
//
// Website: http://www.opensourceteacher.ca
//
// Code built on top of the
// T W I T T E R A R C H I V E R
// - - - - - - - - - - - - - - -
//
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Google+ Profile Badge"
description="Add your Google+ profile to a Google Sites page."
thumbnail="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-thumb.png"
screenshot="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-ss.png"
height="400" width="300" author="Open Source Teacher">
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="href" display_name="Profile URL" required="true"/>
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Twitter Timeline"
description="Add a twitter timeline."
thumbnail="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-thumb.png"
screenshot="http://www.gstatic.com/sites-gadgets/common/images/sites-icon-gadget-ss.png"
author="Open Source Teacher"
height="600" width="250"
/>
<UserPref name="handle" display_name="Twitter Handle (no @ symbol)" required="true"/>
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs
title="List Data Type Example"
scrolling="true"/>
<UserPref name="mylist"
display_name="Add Terms"
datatype="list" />
<Content type="html">
<![CDATA[
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Share to Classroom" title_url="http://www.opensourceteacher.ca/apps-script/share-to-classroom"
description="Add a button to share the current page to Google Classroom."
thumbnail="https://www.gstatic.com/classroom/logo_square_48.svg"
screenshot="https://www.gstatic.com/classroom/logo_square_48.svg"
height="32" width="32" author="Open Source Teacher">
<Require feature="dynamic-height"/>
</ModulePrefs>
<UserPref name="size" display_name="Size" datatype="enum" required="true" default_value="32">
/* script example to retrieve question IDs from form questions, useful for building pre-filled URLs for form entry.
* Copyright 2015, James Petersen
* Published under a Creative Commons Attribution - NonCommercial ShareAlike 4.0 International Licence
*/
function getFormQuestions() {
var form = FormApp.openById(REF_FORM_ID);
var items = form.getItems();
var currentItem;
var validationRules = [];
var questionHeaders = [[],[],[],[]];
var lightSwitch = 0;
var persist = 30000;
var beaconService = require("ble_ibeacon");
var timerId = null;
var flasherId = null;
const blinkPattern = [100, 150, 100, 150];
function beaconData() {
return {
uuid : [0xb1, 0xae, 0x51, 0x2b, 0x97, 0x03, 0x4a, 0xe2, 0xb9, 0xc3, 0x9e, 0x26, 0x0c, 0xa7, 0xb3, 0x99],
############################################################ Christmas Tree 2018 ###########################################
'stop_action':
alias: Stop Action
sequence:
- condition: state
entity_id: light.christmas_tree
state: 'on'
- service: light.turn_off
data:
entity_id: light.christmas_tree