Skip to content

Instantly share code, notes, and snippets.

@conundrumer
conundrumer / yt-ad-buster.js
Last active May 13, 2020 16:26
yt-ad-buster.js: Prevents a YouTube video from being used as an ad by toggling visibility when views from ad are detected.
/* yt-ad-buster.js: Prevents a YouTube video from being used as an ad by toggling visibility when views from ad are detected.
Usage:
Go to video "Details" page and run this script.
To stop, focus on main page and press Escape.
When running, the main page header should turn RED.
When stopped, the header should turn light blue.
If the main page is hidden in a tab, the automation may run slower.
If it runs too fast, YouTube will rate limit with 429 RESOURCE_EXHAUSTED errors.
*/
class AdBusterRunner {
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function run() {
return _run.apply(this, arguments);
}
function _run() {
_run = _asyncToGenerator(function* () {
@conundrumer
conundrumer / yt-autotoggler.js
Last active April 16, 2020 16:54
Periodically toggles visibility of a YouTube video.
/* yt-autotoggler.js: Periodically toggles visibility of a YouTube video.
Usage:
Go to video "Details" page and run this script. Requires pop-ups.
To stop, focus on main page and press Escape.
When running, the main page header should turn violet.
When stopped, the headers should turn light blue.
If the main page is hidden in a tab, the automation may run slower.
If `baseInterval` is less than 4 seconds, YouTube will rate limit with 429 RESOURCE_EXHAUSTED errors.
*/
async function run() {
<b>test</b>
function cf (ps) {
ps = [...ps].reverse()
let x0 = 1
let i = 0
while (i++ < 10000000) {
let x1 = x0
for (let p of ps) {
x1 = p + 1 / x1
@conundrumer
conundrumer / lr-dragon-curve.js
Created August 7, 2018 01:02
generate a dragon curve
function* dragonCurveGen(startPoint, endPoint, maxIterations, left) {
const M = {
mult: (m, v) => [
m[0][0] * v[0] + m[0][1] * v[1],
m[1][0] * v[0] + m[1][1] * v[1]
],
minus: (u, v) => [u[0] - v[0], u[1] - v[1]],
plus: (u, v) => [u[0] + v[0], u[1] + v[1]],
left: [[0.5, -0.5], [0.5, 0.5]],
function sumNaive (n, acc = 0) {
if (n === 0) {
return acc
}
return sumNaive(n - 1, acc + n)
}
// console.log(sumNaive(1000))
// console.log(sumNaive(100000))
@conundrumer
conundrumer / speedometer.jsx
Created January 2, 2018 02:17
lrjs speedometer
import React from 'react'
import Vector from 'core/Vector'
function angleTo (u, v) {
return Math.atan2(u.cross(v), u.dot(v))
}
export default function Speedometer ({rider, prevRider, toolbarsOpen}) {
let style = {position: 'absolute', top: toolbarsOpen ? 40 : 0, right: 0, padding: 8, textAlign: 'right', fontFamily: 'monospace', backgroundColor: 'rgba(255,255,255,0.8)'}
let avgPos = rider.points.reduce((acc, {pos}) => acc.add(pos), new Vector(0, 0)).divS(rider.points.length)
/*
* float.js
* fromHex: takes a 64-bit number encoded as a hex string (eg 34F5CA0157FF00FF)
* and returns a float whose binary representation is this number
* toHex: takes a number and returns the binary encoding as a hex string
*/
/*eslint-env node */
'use strict';
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style type="text/css">
html, body {
width: 100%;
height: 100%;
}
</style>