Skip to content

Instantly share code, notes, and snippets.

View jdb8's full-sized avatar
™️
hello world

Joe Bateson jdb8

™️
hello world
View GitHub Profile
@jdb8
jdb8 / auto-pip-youtube.user.js
Created November 28, 2021 07:27
Auto-enable Picture-in-Picture (PiP) mode when scrolling past a YouTube video
// ==UserScript==
// @name Auto PiP for Youtube
// @version 0.1
// @description Auto-enable PiP when scrolling past a YouTube video
// @author Joe Bateson
// @match https://www.youtube.com/watch*
// @icon https://www.google.com/s2/favicons?domain=youtube.com
// @grant none
// ==/UserScript==
@jdb8
jdb8 / tco-remove.user.js
Created February 5, 2021 09:33
simple userscript to auto-remove t.co links for anchor tags. doesn't (yet) work for link embeds
// ==UserScript==
// @name Remove t.co on hover
// @include https://*.twitter.com/*
// @include https://twitter.com/*
// @include http://*.twitter.com/*
// @include http://twitter.com/*
// ==/UserScript==
(function() {
document.addEventListener('mouseover', (e) => {
const t = e.target;
import css from "./styles.css";
function fn() {
return css.foo;
}
console.log(fn);
@jdb8
jdb8 / index.js
Last active March 14, 2020 01:18
The default mini-css-extract-plugin + css-loader, when run with webpack --production, seem to tree-shake css module classname mappings and inline the referenced names directly as strings.
import styles from "./styles.css";
const baz = styles.baz;
console.log("classname for baz", baz);
@jdb8
jdb8 / jbateson-git
Last active October 3, 2019 06:26
Thin wrapper around git, which could be extended to monkeypatch other small parts of git itself where it's not feasible to impose these changes on other devs working on the same repos.
#!/usr/bin/env bash
set -euo pipefail
# Disgusting wrapper around git, which prevents `git clean -fdX` from removing
# any .vscode folder that exists in the repo (by moving it to a different path
# and back again). I don't want to check the
# .vscode folder into git, but I also don't want it to be removed. Apart from that,
# git clean -fdX works well as a `make clean` target!
if [ "$1" = "clean" ]; then
if [ -d ".vscode" ]; then
DATA_DIR=${XDG_DATA_HOME-$HOME/.local/share}
@jdb8
jdb8 / waitForKeyElements.js
Created November 21, 2017 20:36 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);
export const hi = 'foo';
@jdb8
jdb8 / znc_email.sh
Last active August 29, 2015 14:18
A simple hacky script to send an email via sendmail. This can be used as the supplied command for znc-push.
#!/bin/sh
EMAIL="you@example.com"
NEAT_DATE=`date +%Y-%m-%d`
FULL_DATE=`date +%Y-%m-%d:%H:%M:%S`
SUBJECT="New IRC Notification: $NEAT_DATE"
SENDER="ZNC-Push"
FOOTER="Received on $FULL_DATE"
MESSAGE=$(echo "$1" | tr -d '\011\012\015') # Remove tabs, carriage returns and newlines
echo "Emailing $EMAIL..."

Keybase proof

I hereby claim:

  • I am jdb8 on github.
  • I am joebateson (https://keybase.io/joebateson) on keybase.
  • I have a public key whose fingerprint is 7D9D EDB1 0596 5730 4936 6841 76BD 4C11 1C18 6C02

To claim this, I am signing this object:

@jdb8
jdb8 / strfind.c
Created November 24, 2012 20:42
Function to find the first occurence of a string within another
#include <stdio.h>
#include <string.h>
const char *strfind(const char *s, const char *f);
int main(int argc, char **argv){
const char *s = argv[1];
const char *f = argv[2];