Skip to content

Instantly share code, notes, and snippets.

View DinoChiesa's full-sized avatar

Dino Chiesa DinoChiesa

View GitHub Profile
@DinoChiesa
DinoChiesa / my-path-helper.el
Created May 25, 2025 02:09
Emacs lisp helper code for setting the path just right on Windows
;; ====================================================================
;; For tools like apheleia and flycheck, other tools that might invoke shell
;; commands (like csslint, csharpier, etc), We need to set the path
;; properly. The following functions help with that. I had some problems
;; getting it just right, so it now verbosely logs everything.
(defun my/reorder-list (list predicate)
"Reorders LIST so that elements satisfying PREDICATE come first.
Returns a new list with elements reordered according to PREDICATE.
The original list is not modified.
@DinoChiesa
DinoChiesa / deploy-with-shasum.sh
Created May 18, 2025 16:57
Deploy Apigee bundle with sha-256 checksum in the Description
#!/bin/bash
# -*- mode:shell-script; coding:utf-8; -*-
#
# Copyright © 2025 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
#
# https://www.apache.org/licenses/LICENSE-2.0
@DinoChiesa
DinoChiesa / dired-additions.el
Created May 8, 2025 04:35
Copy or move files or directories from one dired buffer to another
(defun mode-for-buffer (&optional buffer-or-string)
"Returns the major mode associated with a buffer."
(with-current-buffer (or buffer-or-string (current-buffer))
major-mode))
(defun my-dired-copy-or-move-other-window (operation)
"Copy or move the marked files to another directory.
OPERATION is a symbol, either `COPY' or `MOVE' .
This works with files or directories."
(unless (eq major-mode 'dired-mode)
@DinoChiesa
DinoChiesa / csharp-ts-mode-navigation.el
Created December 29, 2024 01:10
Navigation helpers for csharp-ts-mode in emacs 29
;;; csharp-ts-mode-navigation.el --- define some helpers for navigating in csharp-ts-mode
;;
;; Author: Dino Chiesa
;; Created: Sunday, 29 December 2024, 00:34
;; Package-Requires: (csharp-ts-mode.el)
;; URL:
;; X-URL:
;; Version: 2024.12.29
;; Keywords: csharp treesit
;; License: Apache 2.0
Instructions for running peloton-to-garmin (https://github.com/philosowaffle/peloton-to-garmin) in Cloud Run, assuming you're doing this from Windows Powershell v7.4.6:
$env:PROJECT_ID="your-gcp-project-id"
$env:REGION="us-west1"
$env:JOB_NAME="peloton-to-garmin"
gcloud config set core/project $env:PROJECT_ID
# create two GCS buckets - https://cloud.google.com/sdk/gcloud/reference/storage/buckets/create
# one for the output, one for the configuration file
<style type='text/css'>
/* https://stackoverflow.com/a/63574369/48082 */
body, body #index .main-content .home-page .home-page-cta h1.home-page-cta-title {
font-family: 'SF Pro Text',-apple-system,BlinkMacSystemFont,Roboto,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';
}
body #index > .main-content {
padding: 0;
background-color: #7d7d7d;
background-image: revert;
@DinoChiesa
DinoChiesa / getTokenWithRetry.js
Created October 21, 2024 17:33
Apigee JS httpClient with retry
// getTokenWithRetry.js
// ------------------------------------------------------------------
//
// Example JS policy configuration:
//
// Note: you need the authUrl Property.
//
// <Javascript name='JS-Retrieve-Token' timeLimit='12000' >
// <Properties>
// <Property name='authUrl'>https://url-for-token-endpoint/token</Property>
@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=()