This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Delete old Cloud Workstation Disks | |
WARNING: This script will delete disks and all data on them. It should be | |
considered "proof of concept" quality and should be customized to fit your | |
environmental needs, checked for logic errors and monitored. I am not | |
responsible for data loss by using this script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create your own client id/secret | |
# https://developers.google.com/identity/protocols/OAuth2InstalledApp#creatingcred | |
client_id='978969553067-73svibj9j7d5sbq6c5587qorl7qouesh.apps.googleusercontent.com' | |
client_secret='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' | |
token_endpoint="https://oauth2.googleapis.com/token" | |
# WARNING - DOES NOT VALIDATE AUTHENTICITY OF JWT | |
decode_jwt() { | |
local jwt_body=$(echo -n $1 | cut -d "." -f 2 | tr '_-' '/+') | |
echo $(echo "$jwt_body" | openssl enc -d -base64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python311 | |
handlers: | |
- url: / | |
secure: always | |
script: auto | |
redirect_http_response_code: 301 | |
- url: /debug | |
secure: always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
### This script requires a service account private key JSON credentials file. | |
### The service account should be granted an admin role in your domain that | |
### authorizes it to create users. See: | |
### | |
### https://support.google.com/a/answer/9807615?hl=en&ref_topic=9832445&fl=1#zippy=%2Cassign-a-role-to-a-service-account | |
### | |
### This script requires PyJWT and requests. Install it by running: | |
### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
runtime: python310 | |
handlers: | |
- url: /.* | |
script: auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function myFunction() { | |
// connect to sheet | |
var ss = SpreadsheetApp.openById("1_6HeCZ_KEFyJIRD73joTYBwj6xKdJHXudaAfH-Apwto"); | |
var sheet = ss.getSheets()[0]; | |
// determine if weekly auto-reply is enabled | |
var range = sheet.getRange(11,2); | |
var weekly_autoreply_enabled = range.getValue(); | |
if (! weekly_autoreply_enabled) { | |
Logger.log("Weekly auto-reply is disabled"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
''' | |
Set user's Gmail vacation message | |
''' | |
import argparse | |
import http.client | |
from json import dumps | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### Shell script to use update a user's away message for the next week. | |
### Utilizes Google domain-wide delegation (DwD). | |
### | |
### Example to turn on vacation message for a user: | |
### | |
### bash vacation.sh --credentials-file oauth2service.json \ | |
### --user jdoe@acme.com \ | |
### --autoreply 'I am out of the office this week" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onFormSubmit(e) { | |
var response = e.response; | |
var user = response.getRespondentEmail(); | |
var manager = getManagerEmail(user); | |
// New title is our first (and only) form response | |
new_title = response.getItemResponses()[0].getResponse(); | |
emailManager(manager, user, new_title); | |
} | |
function getManagerEmail(user) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
### | |
### Shell script to use Google service account and optionally | |
### domain-wide delegation (DwD). | |
### | |
### This script will ultimately output an access token that can be used to | |
### call Google APIs as the service account or the Workspace user in DwD. | |
### | |
### Example to show a Workspace user's IMAP settings: | |
### |
NewerOlder