Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@DinoChiesa
DinoChiesa / OAuth2 Client Credentials.postman_collection.json
Created October 15, 2024 03:51
Postman collection for the OAuthV2 Client Credentials example.
{
"info": {
"_postman_id": "ac53fc95-c464-4413-8330-0ae96d1bfd1e",
"name": "OAuth2 Client Credentials",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "22976572"
},
"item": [
{
"name": "Request-for-Token (Client credentials",
@DinoChiesa
DinoChiesa / example-output.txt
Created August 30, 2024 00:02
Get GCP ID Token for a Service Account, using a JSON-encoded Service Account key
$ node ./getIdTokenWithServiceAccount.js --keyfile ./my-service-account-key-a8ef19f432a9.json --audience https://foo-bar/bam
jwt payload: {
"iss": "[email protected]",
"aud": "https://oauth2.googleapis.com/token",
"iat": 1724976008,
"exp": 1724976068,
"target_audience": "https://foo-bar/bam"
}
assertion: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzaGVldC13cml0ZXItMUBkY2hpZXNhLWFyZ29saXMtMi5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsImF1ZCI6Imh0dHBzOi8vb2F1dGgyLmdvb2dsZWFwaXMuY29tL3Rva2VuIiwiaWF0IjoxNzI0OTc2MDA4LCJleHAiOjE3MjQ5NzYwNjgsInRhcmdldF9hdWRpZW5jZSI6Imh0dHBzOi8vZm9vLWJhci9iYW0ifQ.rxVh1-rpXxn67zh94LBDLJm3j2jDqzlXXxV9AqUVtVYDVoKvLy5PH7oBFxrO9RgnhvYkxmbYhMWC5bKmAsaB1J7Y7m3Ch7N2C05kzvle8RHImMsIdW7_nLEISKYgZLmUTQh_oqqgyysmY6C6q0Hadt7yqJ7rZz1W_-wq2fV0hZVTAZLKlUtXefKrwK90Myzo3yZg5tA7GTFUY23b8D4gSEkMxjGR0Ke3PwR4N9SK4FKy8YlYeDsOUGfX2GNmqEIQpD7AfjLBUbnFJeKVL04c8PKXnvUAiffeqfCkwcVpVNoyFexEsB2e9ZUUL2H4A7tRR4cA0DU3OL0dkm3Bhd9qHQ
@DinoChiesa
DinoChiesa / fetch-and-unzip-proxy-apigee.sh
Created April 16, 2024 00:35
Fetch a proxy from Apigee Edge, and unzip the bundle locally
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# Works with Apigee Edge.
#
proxyname="$1"
[[ -z "$proxyname" ]] && printf "specify a proxy name as argument\n" && exit 1
MISSING_ENV_VARS=()
@DinoChiesa
DinoChiesa / fetch-and-unzip-proxy-apigeex.sh
Last active April 16, 2024 00:37
Fetch an API Proxy from Apigee X or hybrid, and unzip the bundle in the local filesystem
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# Works with Apigee X/hybrid.
#
proxyname="$1"
[[ -z "$proxyname" ]] && printf "specify a proxy name as argument\n" && exit 1
MISSING_ENV_VARS=()
@DinoChiesa
DinoChiesa / delete-youtube-shorts-watch-history.user.js
Created April 14, 2024 17:05
Tampermonkey script that removes watch history of youtube shorts
// ==UserScript==
// @name autodelete-Youtube-watch-history-shorts - youtube.com
// @namespace youtube
// @description automatically deletes watch history of shorts.
// @match https://myactivity.google.com/product/youtube/
// @grant none
// @version 0.1.0
// @run-at document-end
// @license Apache 2.0
// ==/UserScript==
@DinoChiesa
DinoChiesa / delete-watch-history-shorts.console.js
Last active July 1, 2025 05:20
Remove video shorts from YT Watch History
// orig: https://gist.github.com/miketromba/334282421c4784d7d9a191ca25095c09
// Paste the script into your console on this page: https://myactivity.google.com/product/youtube
const ENABLED = true;
const MIN_DURATION_MS = 1000 * 60 * 1.5; // 1:30 mins
const CHECK_FOR_CONFIRM_INTERVAL = 2000;
let CYCLE_INTERVAL = 1800; // Amount of time in MS to wait between deletion (more likely to fail with a small number)
let wantCycling = true;
const VERY_LONG_DURATION = MIN_DURATION_MS * 10;
@DinoChiesa
DinoChiesa / Apigee-Condition.pegjs
Last active April 15, 2024 23:07
Peggyjs.org grammar for Apigee Condition
//
// A peggy grammar for the Condition expressions used in Apigee.
//
//
// Copyright 2015 Apigee Corp, 2024 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
@DinoChiesa
DinoChiesa / GCP-Token.postman_collection.json
Created September 27, 2023 16:24
Postman collection to get a GCP access token from a service account key file
{
"info": {
"_postman_id": "9b8ac0ff-cfa9-46da-b8f2-4d133a772ce0",
"name": "GCP Token",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "22976572"
},
"item": [
{
"name": "1. get JS-RSA-sign module",
@DinoChiesa
DinoChiesa / xpath-sample.js
Created September 26, 2023 21:03
use of @xmldom/xmldom in JavaScript to read and update nodes in an XML document
const data = `<Foo>
<Bar baz='17'>textvalue</Bar>
<Baz>hello,world</Baz>
</Foo>`;
const xmldom = require('@xmldom/xmldom'),
DOMParser = xmldom.DOMParser,
xpath = require('xpath'),
doc = new DOMParser().parseFromString(data),
attr = xpath.select('/Foo/Bar/@baz', doc)[0],
// createKeyPair.js
// ------------------------------------------------------------------
//
// created: Thu Feb 28 15:49:15 2019
// last saved: <2023-March-29 14:19:28>
/* jshint esversion:9, node: true */
/* global process, console, Buffer, require */
const crypto = require('crypto');