Skip to content

Instantly share code, notes, and snippets.

View bobbigmac's full-sized avatar

Bob Davies bobbigmac

View GitHub Profile
@bobbigmac
bobbigmac / base.js
Created March 29, 2022 16:48
Very simple base custom element for 'reactish' rendering
export default class BaseElement extends HTMLElement {
constructor() {
super();
this.attachShadow({mode: 'open'});
}
connectedCallback() {
this.setupTemplate();
this.render()
}
@bobbigmac
bobbigmac / redirect-from-twitter.user.js
Created October 11, 2021 05:12
Will take you to a random nice or interesting site, any time you reflexively navigate to twitter.
// ==UserScript==
// @name Random Twitter Redirect
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Go do something nice instead
// @author Me
// @match https://twitter.com/*
// @grant none
// ==/UserScript==
@bobbigmac
bobbigmac / test-freqs.sh
Last active September 29, 2021 19:14
Generate a sample preview video for each of the win_func, ascale and fscale (and others) options in ffmpegs showfreqs filter, given in input audio file
trap 'exit 130' INT
soundfile=$1
if [ ! -f "${soundfile}" ]; then
echo "Pass sound file as first parameter"
exit
fi
@bobbigmac
bobbigmac / rip_dvd
Last active August 19, 2021 12:26 — forked from postmodern/rip_dvd
Script to automate ripping DVDs using Handbrake-CLI and mkvmerge
#!/usr/bin/env bash
#
# Author: postmodern
# This fork: bobbigmac
# Description:
# Rips a DVD to one H.264 MKV file for each title.
# Ignores any bad blocks or sectors on the DVD.
# Unlike original, does not write tags
# Dependencies:
# * gddrescue
@bobbigmac
bobbigmac / perf-test.js
Created April 28, 2021 20:12
Reads a js file by filename, then executes it a given number of times, updating timings function for each executed LOC. Hacky af.
const args = process.argv || [];
const fs = require('fs');
const vm = require('vm');
// Execute as
// node perf-test.js test.js
const filename = args[2];
const runs = 100;
// ==UserScript==
// @name Delete facebook posts
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.facebook.com/bobdavies
// @icon https://www.google.com/s2/favicons?domain=facebook.com
// @grant none
// ==/UserScript==
@bobbigmac
bobbigmac / tweets-deleter.user.js
Created November 7, 2020 04:11
User script to quickly delete your own tweets by search
// ==UserScript==
// @name Delete your tweets by search
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://twitter.com/search?q=*
// @grant none
// ==/UserScript==
let sharedContext = false;
const getContext = (context) => {
if(!sharedContext) {
sharedContext = context || document.createElement("canvas").getContext("2d");;
}
return sharedContext;
}
@bobbigmac
bobbigmac / greasemonkey-utils.js
Created May 8, 2019 20:31
Some handy greasemonkey/tampermonkey util functions for reference.
function whenSelectorReady(selector, func) {
window.setTimeout(function() {
var titleEl = document.querySelector(selector);
if(titleEl) {
func(false, titleEl);
} else {
whenSelectorReady(selector, func);
}
}, 300);
@bobbigmac
bobbigmac / observable-object.js
Last active August 15, 2017 10:30
Simple Proxy-based Javascript Observable Object
// Simple proxy-based observable
// Supports myObject.on('set', 'mykey', doMyFunc)
class ObservableObject extends Object {
ensure(type) {
this.events = this.events || {};
this.events[type] = this.events[type] || [];
}
on(type, key, handler) {
this.ensure(type);