Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@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 / 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 / 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 / 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 April 14, 2024 17:06
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 / 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],
@DinoChiesa
DinoChiesa / convert.Java
Created October 8, 2021 17:16
Java: convert between ASN.1 and P1363 Encoding of Signature
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import java.math.BigInteger;
private static byte[] toP1363(byte[] asn1EncodedSignature) throws Exception {
ASN1Sequence seq = ASN1Sequence.getInstance(asn1EncodedSignature);
BigInteger r = ((ASN1Integer) seq.getObjectAt(0)).getValue();
BigInteger s = ((ASN1Integer) seq.getObjectAt(1)).getValue();
@DinoChiesa
DinoChiesa / fixupScreenshotName.sh
Created July 8, 2015 16:04
Rename screenshots on Mac OSX to something sane
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# fixupScreenshotName.sh
#
# The MIT License (MIT)
#
# Copyright (c) 2014 by Dino Chiesa
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@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",
// invokeCallsWithLimit.js
// ------------------------------------------------------------------
//
/* jshint esversion:6, node:false, strict:implied */
/* global properties, httpClient, context, Request */
// Specify the limit of concurrent outbound requests
const ASYNC_LIMIT = 3;