Skip to content

Instantly share code, notes, and snippets.

View solarshado's full-sized avatar

Adrian Todd solarshado

View GitHub Profile
@solarshado
solarshado / YouTube Video Page Button Hider
Last active April 28, 2022 00:45
yet another small browser extension to tailor youtube more to my liking
YouTube Video Page Button Hider
(this is a dummy file to set this gist's name)
@solarshado
solarshado / YouTube Player Button Hider
Last active October 24, 2023 01:41
another small browser extension to tailor youtube more to my liking
YouTube Player Button Hider
(this is a dummy file to set this gist's name)
@solarshado
solarshado / rook traversal.js
Created November 25, 2020 08:53
some messy tinkering around "optimizing" a graph-traversal question found on stack overflow by caching sub-paths
"use strict";
function memoize(f) {
const cache = {};
const ret = function (a) {
return (a in cache) ?
cache[a] :
(cache[a] = f(a));
}
ret.cache = cache; // expose cache for debugging
@solarshado
solarshado / mkcd.sh
Last active October 29, 2020 11:08
a bash function enabling "cd -f" to create non-pre-existent directories
function mkcd {
local CD_ARGS DIR MKDIR=0
while (($#)); do
if [[ $1 == "-f" ]]; then
MKDIR=1;
else
CD_ARGS+=("$1")
if [[ "$1" == "${1##-}" ]]; then
DIR+=("$1")
fi
@solarshado
solarshado / Youtube Progress Display
Last active November 18, 2023 07:59
time remaining for youtube taking playbackRate into account
Youtube Progress Display
@solarshado
solarshado / Makefile
Created May 1, 2020 15:12
Silly code for a reddit thread
# a makefile becasue I've got too much time on my hands
# .exe becasue I'm on Windows using MSYS2
a.exe: calc.c
gcc -o a.exe test.c
calc.c:
python gen.py > calc.c
@solarshado
solarshado / volumeSetter.js
Created November 1, 2017 02:57
JS one-liner/bookmarklet to set volume of audio/video controls
/* gets value between 0-1 or 2-100 with prompt() and sets volume of all <audio> and <video> tags to that fraction */
(function(n){if(n>1) n/=100; if(n>1) n=1; if(!n) return; var g=t=>Array.from(document.getElementsByTagName(t)); var e=g("audio").concat(g("video")); e.forEach(p=>p.volume=n);})(+prompt("enter volume"))
@solarshado
solarshado / snippet.cs
Created March 16, 2017 19:19
some C# using reflection and LINQ to find common properties and generate corresponding interfaces
public void Whatever()
{
var itemTypes = typeof(IItemBase).Assembly.GetTypes()
.Where(t => t.IsClass && typeof(IItemBase).IsAssignableFrom(t))
.ToArray();
var propertyMap = itemTypes.ToDictionary(t => t, t => t.GetProperties().Select(p => new { p.Name, p.PropertyType }).OrderBy(p => p.Name).ToArray());
var distinctNames = propertyMap.Values.SelectMany(_ => _).Select(p => p.Name).Distinct();
@solarshado
solarshado / matrix
Created October 15, 2012 01:19
Animated Matrix 'wallpaper'
#!/bin/bash
# toggle animating Matrix 'rain' desktop background
# requires xscreensaver and pidof
CMD="/usr/lib/xscreensaver/glmatrix" #adjust as needed for your install of xscreensaver
CMDOPS="-root"
RESTORE=". ~/.fehbg"
PID=$(pidof $CMD)
@solarshado
solarshado / Roller.java
Created June 10, 2012 19:55
DiceRoller
package dice;
import java.util.Random;
public abstract class Roller {
private static Random r = new Random();
public static int d4() {
return d(4);
}