Skip to content

Instantly share code, notes, and snippets.

View joshuatz's full-sized avatar

Joshua Tzucker joshuatz

View GitHub Profile
@joshuatz
joshuatz / objectToConsoleGroup.js
Created November 27, 2017 01:48
Spaghetti code to turn an object into a nice console.group() print out
function objectToConsoleGroup(myObject,OPT_Name){
var outerName = (OPT_Name||"Results");
var done = false;
function main(prop,val){
if (typeof(val)==="object" && !Array.isArray(val)){
var thingObj = val;
if (typeof(prop)!=="undefined" && prop!==null){
console.group("Object: " + prop);
}
@joshuatz
joshuatz / CreateAsciiKeyTable.sql
Created February 12, 2019 14:54
Create a table of ASCII keys and values generated from https://www.ascii-code.com/
CREATE TABLE IF NOT EXISTS `keys` (
`DEC` INTEGER NOT NULL UNIQUE,
`OCT` TEXT NOT NULL UNIQUE,
`HEX` TEXT NOT NULL UNIQUE,
`BIN` TEXT NOT NULL UNIQUE,
`Symbol` TEXT,
`HtmlNumber` TEXT,
`HtmlName` TEXT,
`Description` TEXT,
PRIMARY KEY(`DEC`)
@joshuatz
joshuatz / automagic_flow-toggl_start_stop_resume.xml
Last active February 26, 2019 09:16
Automagic flow for starting / stopping / resuming a Toggl timer. See https://joshuatz.com/posts/2018/flic-automagic-toggl-api-button/
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<data version="1.36.0">
<trigger type="general_broadcast">
<useDefaultName>true</useDefaultName>
<name>General Broadcast: on globalflicintent-home</name>
<enabled>true</enabled>
<action>globalflicintent-home</action>
<categoryList></categoryList>
<dataSchemeList></dataSchemeList>
<dataAuthorityList></dataAuthorityList>
var checkboxes = document.querySelectorAll('form[name="f"][method="POST"] table td > input[type="checkbox"]').forEach(function(c){
c.checked = true;
});
var deleteAllForever = document.querySelector('input[type="submit"][value="Delete Forever"]');
var deleteAll = document.querySelector('input[type="submit"][value="Delete"]');
deleteAllForever ? deleteAllForever.click() : deleteAll.click();
<!-- Use this to set the list of IP addresses you DONT want your tags loading for -->
<?php $blockTagsFor = array('216.3.128.12','19.117.63.126','2001:0db8:85a3:0000:0000:8a2e:0370:7334'); ?>
<?php if (in_array($_SERVER['REMOTE_ADDR'],$blockTagsFor,false)==false): ?>
<!-- Put all the tags you want to conditionally load here. GA example below: -->
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
(function(){
function httpFetchVanilla(url,method,callback,OPT_failCallback){method="string"==typeof method&&""!==method?method:"GET",callback="function"==typeof callback?callback:function(){},failCallback="function"==typeof OPT_failCallback?OPT_failCallback:function(){console.warn("httpFetchVanilla failed")};var t=new XMLHttpRequest;t.onreadystatechange=function(){4==t.readyState&&(200==t.status?callback(t.responseText):failCallback())},t.open(method,url,!0),t.send()}
function setCookie(name, value, days) {
var d = new Date;
d.setTime(d.getTime() + 24*60*60*1000*days);
document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
}
@joshuatz
joshuatz / restart_dropbox.bat
Created May 11, 2019 23:58
Restart the Dropbox client by running a Windows Batch Script. Searches in both Program Files directories for exe to start back up.
@echo off
cls
REM # Find and kill the dropbox process
taskkill /FI "IMAGENAME eq Dropbox.exe" /F
REM # Wait a little
@echo on
cls
echo "Please wait while restarting Dropbox"
@echo off
SLEEP 5
@joshuatz
joshuatz / node_file_downloader.js
Created May 12, 2019 07:13
File downloader that you can call with Node and pass a URL, that has options for checking file integrity after download
/**
* @author Joshua Tzucker
* @file A reusable script to download a remote file, usually to have as a dependency, that for some reason can't be fetched through NPM
*/
/**
* File should be called with arguments:
* file_downloader.js remote_file local_folder_to_save_to [newFileName="foobar.js"][forceReDownload=FALSE] [fileHash="sha256-adsfasfd"]
* fileHash should be base64 - follow rule of SRI - https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity
* Example:
@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