Skip to content

Instantly share code, notes, and snippets.

View mstraughan86's full-sized avatar
🔥
Motivated for change.

Michael Straughan mstraughan86

🔥
Motivated for change.
View GitHub Profile
@mstraughan86
mstraughan86 / Code.gs
Last active July 29, 2017 00:04
Google App Script - Google Form - Insert Default Date and Time
function defaultDateAndTime() {
// This gscript didn't work for a little bit.
// I renamed the function. I was also messing with the triggers and which functions they were referencing.
// I thought I got them all matched up, but it still didn't work right.
// Tried one last time. Deleted all triggers. Renamed this function. Recreated Trigger. Works.
var sheet = SpreadsheetApp.getActiveSheet();
var lastRow = sheet.getLastRow();
var dateColumn = 4; // Type this in manually if you know it.
var timeColumn = 5; // This as well.
@mstraughan86
mstraughan86 / gist:41139268e4fed8814e981b719bcec67d
Last active September 8, 2017 03:54
OAuth 2.0 Playground - GTM Scripts
- Temporary development location, simply copy and paste the stuff you need to do for the moment.
- Eventual plan is to have a master script to copy into g.spreadsheet and have all commands in a menu.
https://developers.google.com/oauthplayground/
- I find these in the url when I am logged in. Don't know where else to look.
Account ID = *****
Container ID = *****
//////////
Create Variables:
@mstraughan86
mstraughan86 / json-pretty-output.js
Created August 8, 2017 08:38
Json Output with Syntax Highlighting
function syntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
@mstraughan86
mstraughan86 / gapi-in-gapps.md
Last active November 3, 2017 07:57
How to make Google API calls from inside Google Apps Scripts

How to make Google API calls from inside Google Apps Scripts: https://developers.google.com/sheets/api/quickstart/apps-script

Step 1: Create the script

  1. Open Google Drive in your web browser.
  2. Click New > More > Google Apps Script.
  3. If Google Apps Script isn't listed, you can install it by clicking the Connect more apps option instead. Search for "Google Apps Script" and click the +CONNECT button. Click the OK button in the popup, click the X icon to close the dialog, and repeat the step above.
  4. If you are presented with a welcome screen, click Blank Project.
  5. Replace the contents of the script editor with the code at the end of this gist.
@mstraughan86
mstraughan86 / gapi-in-chrome.gist
Created August 9, 2017 08:51
How to make Google API calls from inside Google Chrome Extension
How to make Google API calls from inside Google Chrome Extension:
https://developers.google.com/identity/protocols/OAuth2UserAgent
https://developers.google.com/identity/protocols/googlescopes#tagmanagerv2
https://developers.google.com/api-client-library/javascript/features/authentication
WIP
@mstraughan86
mstraughan86 / custom-menu-for-gsheets.gist
Created August 10, 2017 08:50
How to add Custom Menus to Google Sheets (also Docs and Forms)
https://developers.google.com/apps-script/guides/menus#menus_for_add-ons_in_google_sheets_docs_or_forms
https://developers.google.com/apps-script/guides/bound
https://developers.google.com/apps-script/guides/standalone
WIP
@mstraughan86
mstraughan86 / Chrome.setup
Last active September 19, 2017 23:58
Development Workstation Setup
Ubuntu 16.04 Terminal Installation Commands:
sudo chmod 777 /etc/apt/sources.list
sudo printf "\ndeb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list
wget https://dl.google.com/linux/linux_signing_key.pub
sudo apt-key add linux_signing_key.pub
sudo apt update
sudo apt install -y google-chrome-stable
* There is a bug that I encountered... And I fixed it at home but I forgot how.
@mstraughan86
mstraughan86 / FAQ.md
Last active December 9, 2017 19:11
Git Utility Shelf

Sometimes contributions don't count. Why?

How do you upload a file to GitHub, then lock it so that git will no longer check for and push updates on that file, to preserve a local customized copy?

Source

git update-index --skip-worktree FILE_NAME
git update-index --no-skip-worktree FILE_NAME
@mstraughan86
mstraughan86 / 0_reuse_code.js
Created September 11, 2017 08:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console