Skip to content

Instantly share code, notes, and snippets.

View JayGoldberg's full-sized avatar

Jay Goldberg JayGoldberg

  • Google
  • San Francisco, CA, USA
View GitHub Profile
@JayGoldberg
JayGoldberg / driveFolderTagging.gs
Created December 23, 2022 14:47
Writes all the folder names of a file into the file description, so that the file can be found by searching the folder names.
// https://www.labnol.org/code/19721-add-tags-google-drive-files
/*
setDescriptionToFolderNames
Workaround to fake Tags in Google Drive.
Writes all the folder names of a file into the file description, so that the file can be found by searching the folder names.
*/
function setDescriptionToFolderNames() {
var file;
var filename;
@JayGoldberg
JayGoldberg / mouseDraw.js
Last active December 21, 2022 03:17 — forked from brettbartylla/mouseDraw.js
This javascript allows a mouse to draw on an HTML5 Canvas
// Get the canvas and its context
var canvas = document.querySelector('#paint');
var ctx = canvas.getContext('2d');
// Get the parent element of the canvas and its computed style
var sketch = document.querySelector('.sketch');
var sketch_style = getComputedStyle(sketch);
// Set the canvas dimensions to match the parent element
canvas.width = parseInt(sketch_style.getPropertyValue('width'));
@JayGoldberg
JayGoldberg / drawing.js
Created December 21, 2022 03:15 — forked from zachdunn/drawing.js
Canvas mouse drawing for a canvas #sketch plus button #clear.
(function(window){
// Define the Pen object, which handles drawing on the canvas
var Pen = function(context){
// Whether the user is currently drawing
var drawing;
// Reset the pen's drawing style
this.reset = function(){
context.beginPath();
context.lineCap = 'round';
@JayGoldberg
JayGoldberg / spreadsheetIndexfromColumn.js
Created December 20, 2022 04:53
Convert alphabetical spreadsheet column ID to a numeric index (Google Sheets, etc)
// given a column 'A'...'AB' etc, return a numeric index
function columnToIndex(column) {
// Initialize the index to 0
var index = 0;
// Iterate through the characters in the column string
for (var i = 0; i < column.length; i++) {
// Get the character at the current index
var char = column.charAt(i);
@JayGoldberg
JayGoldberg / geo.gs
Created November 29, 2022 03:27
Apps Script Google Maps geocoding using native Maps and API-key based geocode
// JSON geocode returned
function doNativeGeoCode(address) {
var response = Maps.newGeocoder().setBounds(32.85964933715685, -117.32946858722974, 32.70248574032382, -117.0346293702513).geocode(address);
return response;
}
// JSON geocode returned
function doApiGeoCode(address) {
var options = {
muteHttpExceptions: true,
@JayGoldberg
JayGoldberg / geocode.gs
Created September 16, 2022 21:00
Apps Script use Google Maps Javascript API with custom-defined script property API key
// addresses "Exception: Service invoked too many times for one day: geocode" because the built-in Maps App does not support API keys
// you must create an API key in Maps API in the Google Cloud Console for insertion into Script Properties `mapsApiKey`
function doGeoCode(address) {
var serviceUrl = `https://maps.googleapis.com/maps/api/geocode/json?address=${address}&key=${ScriptProperties.getProperty('mapsApiKey')}`;
var response=UrlFetchApp.fetch(serviceUrl, options);
if(response.getResponseCode() == 200) {
var responseJSON = JSON.parse(response.getContentText());
if (responseJSON !== null) { return responseJSON; }
}
#!/bin/sh
# v1.0
wd="/tmp/IPCAM"
mkdir -p $wd
rm -f $wd/*
tar -cf $wd/config.tar -C ./ mnt/mtd
@JayGoldberg
JayGoldberg / ftp_sync.sh
Last active July 25, 2021 12:55 — forked from guerrerocarlos/copy_to_ftp.sh
Script for syncing OUCAM camera videos automatically to FTP
#!/bin/sh
# FTP_COPY version 0.3 by MP77V www.4pda.ru
# ----------------------------
FTP_DEST_DIR="/FTP_directory"
FTP_DEST_HOST="FTP_host"
FTP_DEST_PORT="21"
FTP_DEST_LOGIN="FTP_user"
FTP_DEST_PASS="FTP_password"
# ----------------------------
@JayGoldberg
JayGoldberg / datastore_entity_test_1.py
Created July 5, 2019 18:12
Cloud Datastore single entity read test (usable in Cloud Shell)
import os
from google.cloud import datastore
import google.cloud.exceptions
#https://stackoverflow.com/questions/1593019/is-there-any-simple-way-to-benchmark-python-script
def timereps(reps, func):
from time import time
start = time()
for i in range(0, reps):
func()
@JayGoldberg
JayGoldberg / ispperf.sh
Last active March 8, 2019 19:40 — forked from ianrust/ispperf.sh
Script for logging and monitoring isp ping, latency, and bandwidth. Borrowed from here: https://www.blackhatworld.com/seo/bash-script-to-check-isp-bandwidth-and-latency.257820/
#!/bin/bash
# The MIT License
#
# Copyright (c) 2010, MaDeuce
#
# https://en.wikipedia.org/wiki/MIT_License
#
# ============================================================================
# This command measures latency and bandwidth of an internet connection from the command line.