Skip to content

Instantly share code, notes, and snippets.

karlkranich / cft-bucket-policy-conditional.json
Last active July 15, 2021 21:43
CloudFormation templates (json and yml) that conditionally include a user and a statement
View cft-bucket-policy-conditional.json
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Bucket policy testing",
"Parameters": {
"ReadWriteUser": {
"Type": "String",
"Default": "",
"Description": "arn of read-write user to add to bucket policy"
"ReadOnlyUser": {
karlkranich / multisheet-duplicate-finder.js
Last active May 30, 2021 13:52
Find duplicates across Google Sheets
View multisheet-duplicate-finder.js
/** Multisheet Duplicate Finder **
To use, paste this code into a Google Spreadsheets Apps Script (Tools - Script editor)
Loops through all of the sheets in the current spreadsheet.
Identifies duplicates in the chosen column.
Skips the chosen number of header rows.
Creates and alert box listing the duplicates, and colors the duplicate cells red.
The directive below limits the script to only be able to access this spreadsheet.
* @OnlyCurrentDoc
karlkranich / index.php
Created March 7, 2017 01:27
Google's PHP Quickstart adapted to use a service account
View index.php
require_once __DIR__.'/vendor/autoload.php';
define('SCOPES', implode(' ', array(
View apitest-cells.php
require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
include_once "google-api-php-client/examples/templates/base.php";
$client = new Google_Client();
ATTENTION: Fill in these values, or make sure you
karlkranich / apitest.php
Last active July 17, 2018 14:49
Updated PHP code to use the Google Sheets API. See usage instructions at More examples at
View apitest.php
// apitest.php
// by Karl Kranich -
// version 3.1 - edited query section
require_once realpath(dirname(__FILE__) . '/vendor/autoload.php');
include_once "google-api-php-client/examples/templates/base.php";
$client = new Google_Client();
karlkranich / sheets-api-test-part2.php
Last active February 2, 2023 21:39
(obsolete due to Google changes) PHP code to use the Google Spreadsheets API with an OAuth Service Account. For more info, see
View sheets-api-test-part2.php
// Section 5: edit a row
// You'll need to get the etag and row ID, and send a PUT request to the edit URL
$rowid = 'cre1l'; // got this and the etag from the table data output from section 3
$etag = 'NQ8VCRBLVCt7ImA.';
$url = "$fileId/od6/private/full/$rowid";
$method = 'PUT';
$headers = ["Authorization" => "Bearer $accessToken", 'Content-Type' => 'application/atom+xml', 'GData-Version' => '3.0'];
$postBody = "<entry xmlns=\"\" xmlns:gsx=\"\" xmlns:gd=\"\" gd:etag='&quot;$etag&quot;'><id>$fileid/od6/$rowid</id><gsx:gear>phones</gsx:gear><gsx:quantity>6</gsx:quantity></entry>";
$req = new Google_Http_Request($url, $method, $headers, $postBody);