This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Youtube Progress Display |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dice; | |
import java.util.Random; | |
public abstract class Roller { | |
private static Random r = new Random(); | |
public static int d4() { | |
return d(4); | |
} |