Skip to content

Instantly share code, notes, and snippets.

View pixraw's full-sized avatar

Pixraw pixraw

View GitHub Profile
@pixraw
pixraw / GA-script-scroll_vertically_to_todays_date.gs
Created July 7, 2017 11:34 — forked from dDondero/GA-script-scroll_vertically_to_todays_date.gs
This Google sheets / Google Apps script searches through all columns in a certain row to find the date matching today, then document automatically scrolls to today's date so you can continue working on the correct spot. Ment to be set up with a trigger On open document. Some other customizing set up here.
function onOpen() { // find where date maches today, then scroll to the end of sheet, then scroll back to matched date
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
var values = sheet.getSheetValues(1,1,1,sheet.getMaxColumns());
var objvalues = Transpose(values);
var today = new Date().setHours(0,0,0,0); // change date format to numbers
for(var n=0;n<objvalues.length;++n){ // for each objvalues object run command
@pixraw
pixraw / hideCols.js
Created July 6, 2017 15:09 — forked from cwallen/hideCols.js
Google Apps Script to hide every other column.
function onOpen() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [ {name: "Hide", functionName: "myFunction"} ];
ss.addMenu("Scripts", menuEntries);
}
function myFunction() {
var sheet = SpreadsheetApp.getActiveSheet();
var colCount = sheet.getMaxColumns();
var x = 1;
@pixraw
pixraw / GCalUtils.md
Created July 5, 2017 13:20 — forked from mogsdad/GCalUtils.md
Collection of Google Calendar related utility functions for Google Apps Script.

Google Calendar Utilities

getEventsWithGuest

Gets all events that occur within a given time range, and that include the specified guest email in the guest list.

###Parameters:###

@pixraw
pixraw / GMailReminder.gs
Created July 5, 2017 12:54 — forked from kshwetabh/GMailReminder.gs
Reminder script for GMail: A simple Google Apps Script to create a Google Calendar event (reminder) for any mail (with a specific label). You can then setup ("timed") triggers in Apps Script... (public version of the GMailReminder gist)
/**
* Reminder script for GMail: A simple Google Apps Script to create a Google Calendar event (reminder) for any mail (with a
* specific label). You can then setup ("timed") triggers in Apps Script (hourly, etc) to monitor your Inbox.
* How to Use:
* 1. Log into Google Drive account and create a Google Script.
* 2. Copy and paste the below snippet into the gs file.
* 3. Make sure to update the 'reminderLabel', 'calendarName' and 'reminderDuration' as per your preference.
* 4. Test the script to make sure it is working properly.
* 5. Setup a time-driven Project Trigger (hourly, etc) to automatically run this script and create calendar events.
*
@pixraw
pixraw / google-script-add-fonts.gs
Created June 30, 2017 14:32 — forked from ociredefz/google-script-add-fonts.gs
Google apps script to set different fonts in the sheets.
/**
* Google Script - Add Fonts.
* Add other fonts in Google Spreadsheet.
*
* a) Open 'Script editor'
* b) Add this script
* c) Save and run 'onOpen'
* d) Go to some 'Spreadsheet' project
* e) Click to 'Font Editor' and then to 'Change Font'
*/

Google Apps Script Document Utilities

  • getAllLinks.js

  • getAllLinks(element) - returns array of all UrlLinks in Document

  • findAndReplaceLinks(searchPattern,replacement) - changes all matching links in Document

  • changeCase.js - Document add-in, provides case-change operations in the add-in Menu.

  • onOpen - installs "Change Case" menu

  • _changeCase - worker function to locate selected text and change text case. Case conversion is managed via callback to a function that accepts a string as a parameter and returns the converted string.

  • helper functions for five cases

@pixraw
pixraw / Code.gs
Created June 21, 2017 11:59 — forked from hlecuanda/Code.gs
Custom formula in Google Apps Script (GAS) to extract the formula used in a cell (G Suite Sheets)
/**
* Extract formula from a cell
*
* @param {reference} a cell reference from which to extract the formula
* @return a string representation of the formula in {reference}
* @customfunction
*/
function CELLFORMULA(reference) {
var ss = SpreadsheetApp;
@pixraw
pixraw / pullJSON.js
Created June 20, 2017 10:30 — forked from varun-raj/pullJSON.js
Google App Script To Fetch Data From JSON Webservice and Write them to google spreadsheet.
function pullJSON() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheets = ss.getSheets();
var sheet = ss.getActiveSheet();
var url="http://example.com/feeds?type=json"; // Paste your JSON URL here
var response = UrlFetchApp.fetch(url); // get feed
var dataAll = JSON.parse(response.getContentText()); //
@pixraw
pixraw / dialog.html
Created June 20, 2017 05:57 — forked from arthurattwell/dialog.html
Google Sheets script to allow multi-select in cells with data-validation (adapted from https://www.youtube.com/watch?v=dm4z9l26O0I)
<div style="font-family: sans-serif;">
<? var data = valid(); ?>
<form id="form" name="form">
<? if(Object.prototype.toString.call(data) === '[object Array]') { ?>
<? for (var i = 0; i < data.length; i++) { ?>
<? for (var j = 0; j < data[i].length; j++) { ?>
<input type="checkbox" id="ch<?= '' + i + j ?>" name="ch<?= '' + i + j ?>" value="<?= data[i][j] ?>"><?= data[i][j] ?><br>
<? } ?>
<? } ?>
<? } else { ?>
@pixraw
pixraw / gist:95835f413bd367dfce160a455e9da493
Created June 19, 2017 15:23 — forked from mhawksey/gist:1723943
Core Google Apps Script functions I use a lot of (From http://code.google.com/googleapps/appsscript/articles.html (c) Google Inc.)
// The rest of this code is currently (c) Google Inc.
// setRowsData fills in one row of data per object defined in the objects Array.
// For every Column, it checks if data objects define a value for it.
// Arguments:
// - sheet: the Sheet Object where the data will be written
// - objects: an Array of Objects, each of which contains data for a row
// - optHeadersRange: a Range of cells where the column headers are defined. This
// defaults to the entire first row in sheet.
// - optFirstDataRowIndex: index of the first row where data should be written. This