Skip to content

Instantly share code, notes, and snippets.

View joshuatz's full-sized avatar

Joshua Tzucker joshuatz

View GitHub Profile
@joshuatz
joshuatz / kasa.gas.js
Last active June 16, 2023 16:33
Google Apps Script Wrapper around Kasa API
/**
* @file Google Apps Script Wrapper around Kasa API
* @license MIT
* @see https://gist.github.com/joshuatz/5266d8cc85ef3e0e67561de3573a1ff5
* @author Joshua Tzucker
* @see
* - https://joshuatz.com/posts/2020/scripting-my-morning-wake-up-alarm-and-lights-with-android-and-kasa/
* - https://cheatsheets.joshuatz.com/random/tp-link-kasa/
*/
// @ts-check
@joshuatz
joshuatz / vid_popper.js
Last active August 22, 2020 04:35
Video Popper for PiP - Override Disabled PiP Support
let vidPopped = false;
document.querySelectorAll('video').forEach(vid => {
// Override disabling features
vid.removeAttribute('disablepictureinpicture');
vid.disablePictureInPicture = false;
// Only pop right away if video is playing, or on Hulu
if ((!vid.paused || vid.id === 'content-video-player') && !vidPopped) {
if (typeof vid.requestPictureInPicture === 'function') {
vid.requestPictureInPicture()
.then(() => {
@joshuatz
joshuatz / README.md
Last active September 9, 2020 08:06
Disable ChromeDriver messages to stdout with Selenium WebDriver & NodeJS

Make sure you have the minimum dependencies (e.g. you have run yarn add selenium-webdriver), and edit the file with your chromedriver bin info.

Here is a full writeup

/**
* @file Mini-API to export data from a Google Sheet, created for fun
* @author Joshua Tzucker
* @see https://joshuatz.com/posts/2021/google-sheets-faster-data-export-options
* @license MIT
* @see https://gist.github.com/ronaldsmartin/47f5239ab1834c47088e (alternative)
*/
// @ts-check
/// <reference path="/yarn-global/@types/google-apps-script/index.d.ts" />
@joshuatz
joshuatz / Android_WebView_Blocking.kt
Last active December 27, 2022 22:25
Example of how to intercept and block request with Android WebView
package com.joshuatz.webviewblock
import android.os.Bundle
import android.util.Log
import android.webkit.*
import androidx.appcompat.app.AppCompatActivity
// Leave off www.
val BannedDomains: Array<String> = arrayOf("facebook.com", "connect.facebook.net")
val BannedUrlPatterns: Array<Regex> = arrayOf(Regex("\\.taboola\\."))
@joshuatz
joshuatz / README.md
Created January 1, 2022 01:44
Patching dist static files for subdirectory deployment

Stashing this here in case I need it in the future - used this to patch build output from a vite based Svelte project (non-svelte-kit) to be able to be deployed from a sub-directory with plain HTML serving.

Requires walkdir and fs-extra.

@joshuatz
joshuatz / README.md
Last active January 11, 2022 07:12
Bulk Folder Runner - Batch Script

If you want to run this and capture the results to a log file, you should make sure to also capture stderr. You can use something like:

./bulk_folder_runner.bat > log.txt 2>&1

If running via Task Scheduler, please note that Task Scheduler does not properly record exit error codes.

@joshuatz
joshuatz / run_examples.js
Last active April 11, 2024 11:08
Script to clean up YouTube history and bulk-delete videos that mess up the recommendation algorithm
(() => {
// With default shorts filter - dry run mode
new YouTubeHistoryCleaner(undefined, true);
// dryRunMode = off (actually delete stuff)
new YouTubeHistoryCleaner(undefined, false);
// With custom filter, preserving history for certain accounts
const approvedAuthors = [