Skip to content

Instantly share code, notes, and snippets.

View JayGoldberg's full-sized avatar

Jay Goldberg JayGoldberg

View GitHub Profile
@JayGoldberg
JayGoldberg / GCPmakeSpeech.sh
Last active April 16, 2025 18:42
Script to generate audio output from Google Text-to-Speech API
#!/bin/bash
# GCPmakeSpeech.sh
# run in Google Cloud Shell in the Cloud Console
# adapted from https://cloud.google.com/text-to-speech/docs/create-audio-text-command-line
# Check if text argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 \"TEXT_TO_SYNTHESIZE\" [OUTPUT_FILE.mp3]"
exit 1
fi
@JayGoldberg
JayGoldberg / README.md
Last active January 18, 2025 18:55
Apps Script email Google form responses automatically, with the responses inside the email

When someone submits a response to a Google Form, you get an email telling you that someone submitted a response but not what they actually submitted

That suuuucks.

So this project is meant to send you the actual response the person entered, and if you capture their email, the Reply feature in your email client will go back to the respondent.

  1. Insert this code into the Script editor of the Google Form.
  2. Copy the template into an HTML file in the script editor
  3. Install a From form - On form submit trigger to call sendFormResponseByEmail() when someone submits the form.
@JayGoldberg
JayGoldberg / circuitFinder.html
Last active December 24, 2024 00:58
Circuit finder using ESP devices (ESP8266 or ESP32)
<!DOCTYPE html>
<html>
<head>
<title>ESPHome Circuit finder</title>
<style>
.status-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
grid-gap: 10px;
}
@JayGoldberg
JayGoldberg / ytAnalytics.py
Created October 23, 2024 18:19
Accessing youtubeanalytics.googleapis.com API using python
import os
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
API_SERVICE_NAME = 'youtubeAnalytics'
API_VERSION = 'v2'
CLIENT_SECRETS_FILE='ytsecret.json'
@JayGoldberg
JayGoldberg / genAI_noise.sh
Last active October 23, 2024 01:59
adds organic noise to AI generated images
# adds organic noise to AI generated images
# requires ImageMagick `convert` command
function makenoise {
# Get the input extension and use the same one for output
imageName="$1"
basename=$(basename "$imageName")
extension="${imageName##*.}"
# Split the image into channels
convert "$imageName" -separate "channel_%d.png"
@JayGoldberg
JayGoldberg / enumerateDrive.gs
Created May 24, 2024 15:48
Recursive enumeration of all files in a Google Drive folder to text file on Drive
function getAllFiles(folderId) {
const accumulated = [];
const folder = DriveApp.getFolderById(folderId);
// Function to copy a file to GCS, handling file or folder path as argument
function traverseOrReturnItem(item, currentPath) {
const itemName = item.getName(); // Handles file or folder names
const thisPath = `${currentPath}${currentPath ? "/" : ""}${itemName}`; // Construct GCS object key
// if (typeof item === 'object' && item.getMimeType() ? false : true && DriveApp.getFolderById(item.getId()) ? true : false) { // If it's a folder, process contents recursively
@JayGoldberg
JayGoldberg / url-param-stripper.html
Created October 19, 2023 18:02
Strips all the parameters from URLs from one input field and populates the stripped URLs in the other
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>URL Parameter Stripper</title>
</head>
<body>
<h1>URL Parameter Stripper</h1>
@JayGoldberg
JayGoldberg / etl_geojson.py
Last active September 17, 2023 19:37 — forked from lakshmanok/etl_geojson.py
How to load GeoJSON files to BigQuery (supports filename arg)
#!/usr/bin/env python3
# See: https://medium.com/@lakshmanok/how-to-load-geojson-files-into-bigquery-gis-9dc009802fb4
import json
import sys
def convert_geojson(input_file_path):
with open(input_file_path, 'r') as ifp:
with open('to_load.json', 'w') as ofp:
features = json.load(ifp)['features']
@JayGoldberg
JayGoldberg / convertGeoJsonToBq.js
Last active December 19, 2023 18:48
BigQuery requires new-line delimited JSON files where the geometry column is single string.
// https://medium.com/google-cloud/how-to-load-geojson-files-into-bigquery-gis-9dc009802fb4
// Javascript (NodeJS) vs Python
function convertGeoJsonBq() {
const fs = require('fs');
fs.readFile(process.argv[1], 'utf8', (err, data) => {
if (err) throw err;
const geojson = JSON.parse(data);
const features = geojson.features;
@JayGoldberg
JayGoldberg / resolveRedirect.gs
Created January 28, 2023 00:37
Google Sheets function to recursively resolve URLs and get status codes =getStatusCode() and =getRedirects()
const options = {
'muteHttpExceptions': true,
'followRedirects': false
};
function getStatusCode(url) {
const url_trimmed = url.trim();
let cache = CacheService.getScriptCache();
let result = cache.get(url_trimmed);