Skip to content

Instantly share code, notes, and snippets.

View brainysmurf's full-sized avatar

Adam Morris brainysmurf

View GitHub Profile
@brainysmurf
brainysmurf / main.js
Last active November 29, 2015 06:49
main.js
function main() {
alert('You are the man!');
}
function test_doGet() {
var e = {};
e.parameter = {};
e.parameters = {};
e.parameters.callback = 'callback';
e.parameter.url = "";
e.parameter.sheet = 'Sheet1';
e.parameter.range = 'A1:H';
Logger.log(doGet(e).getContent());
}
@brainysmurf
brainysmurf / oneRowConcated.gs
Last active February 12, 2016 08:27
MultipleChoiceToOneRowEach
/*
Summary of the Multiple Choices selected, with a space-bar ' | ' between each item
Removes leading and trailing space-bars (and internally repeating!) with a regexp:
The regexp does the following manipulations:
FROM TO
"A | |" --> "A"
" | | C" --> "C"
" | B | " --> "B"
"A | B | " --> "A | B"
" | | B | C" --> "B | C""
/**
* Convert any spreadsheet value to a date.
* Assumes that numbers are using Epoch (days since 1 Jan 1900, e.g. Excel, Sheets).
* Originally found at http://stackoverflow.com/questions/33809229/how-to-get-a-date-format-string-from-a-sheet-cell/33813783#33813783
* with minor modifications
*
* @param {object} value (optional) Cell value; a date, a number or a date-string
* will be converted to a JavaScript date. If missing or
* an unknown type, will be treated as "today".
*
@brainysmurf
brainysmurf / collatze_sequence.py
Last active March 26, 2016 03:15
Longest Collatz sequence
"""
Requires Python3
Solves this: https://projecteuler.net/problem=14
Illustrates the following concepts:
* Object oriented programming, in particular subclassing int and list
* Generator pattern (Sequence is a generator)
# Properties
To save space, does not store full sequence in results, everything is calculated on demand
Uses up to about 400 MB
// Just a regular timezone string
var TMZ = 'GMT+8'; // 'GMT-10', etc etc
// Refer to here to change for the exact formatting http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
// Single quotes around the %s are for the ordinal, like "3rd" and "4th".
// The single quotes are required, avoids interpretation and are required for the call to formatString
// The '%s' can be deleted as well, without ill effects
var FORMATSTRING = "EE MMM d'%s' yyyy @ hh:mm a"; // Tue Apr 26th 2016 @ 08:43 AM
if (!Date.prototype.formatted) {
// Step 1: Place this in your <script> area of your template
// Step 2: Change 'columns' variable to reflect on line 19 to your desires
// e.g. columns = {'b': 'Column B!', 'c': 'Column C!'}
//
// NOTE: Does NOT refer to the columns in the data source sheet
// Column A here is the first column that appears on the awesometable,
// B the second
var convertColToN = function(val) {
var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', i, j, result = 0;
// To use:
// Put the below in the <script> portion of your template
// Set awesometable config to use that template (see documentation for details)
function main() {
columns = {
1: // first column, not column A in the data sheet, the first column displayed in the table
{
text: ['Yippee'], // changes title to "Yippee"
css: ['width', '10%'] // changes the width
"""
"""
import time # for sleeping
class App:
def __init__(self, stage):
self.stage = stage
def run(self):
@brainysmurf
brainysmurf / Mine.gs
Last active December 9, 2017 13:51
Mine
function Package () {
return {
output: function () { return "works"; }
}
}