Skip to content

Instantly share code, notes, and snippets.

View joshuatz's full-sized avatar

Joshua Tzucker joshuatz

View GitHub Profile
@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 = [
@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 / 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 / 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\\."))
/**
* @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 / 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

@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 / 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 / AndroidManifest.xml
Created January 4, 2020 18:39
TP-Link Kasa Android Manifest
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="29" android:compileSdkVersionCodename="10" package="com.tplink.kasa_android" platformBuildVersionCode="900" platformBuildVersionName="2.18.0.900">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
@joshuatz
joshuatz / PowerBI_JS_API_Reset_All_Slicers_Filters.js
Created May 17, 2019 02:18
Reset all Slicers (visual filter widgets) within a Power BI Javascript Embed
async function resetAllSlicers() {
// This will target first embed on page, you can easily change
let report = powerbi.embeds[0];
let pages = await report.getPages();
for (let x = 0; x < pages.length; x++) {
let visuals = await pages[x].getVisuals();
for (let x = 0; x < visuals.length; x++) {
if (visuals[x].type === 'slicer') {
// Clear state, but wait before moving on to next one, since clearing a filter can have a cascade effect
try {