This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const options = { | |
| 'muteHttpExceptions': true, | |
| 'followRedirects': false | |
| }; | |
| function getStatusCode(url) { | |
| const url_trimmed = url.trim(); | |
| let cache = CacheService.getScriptCache(); | |
| let result = cache.get(url_trimmed); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create external table from CSV or Google Sheet, autodetect schema | |
| function bqCreateCsvTable(csvDriveFileId) { | |
| const CONFIG = setConfig(); | |
| let csvFile = DriveApp.getFileById(csvDriveFileId); | |
| let tableId = csvFile.getName(); | |
| let bqConfig = { | |
| "tableReference": { | |
| "projectId": CONFIG.projectId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function doGet(e) { | |
| // Look up the function for the specified endpoint | |
| var handler = getEndpointHandlers[e.parameter.action]; | |
| if (handler) { | |
| // Call the appropriate function for the endpoint | |
| return handler(e); | |
| } else { | |
| // Return an error if the endpoint is not recognized | |
| return ContentService.createTextOutput("Error: Invalid GET endpoint.").setMimeType(ContentService.MimeType.TEXT); | |
| } |