Skip to content

Instantly share code, notes, and snippets.

// Don't ask about this one. I have no idea what this magic is.
// Copied from https://github.com/microsoft/TypeScript/issues/13298#issuecomment-724542300.
type UnionToIntersection<U> =
(U extends any ? (arg: U) => any : never) extends (arg: infer I) => void
? I
: never;
// Continuation of above.
type UnionToTuple<T> =
UnionToIntersection<(T extends any ? (t: T) => T : never)> extends (_: any) => infer W
console.delayLog = function(delayMs, message) {
var style =
"color: rgb(249, 162, 34);" +
"font-size: 60px;" +
"font-weight: bold;" +
"text-shadow: 1px 1px 5px rgb(249, 162, 34);" +
"filter: dropshadow(color=rgb(249, 162, 34), offx=1, offy=1);";
setTimeout(function() {
console.log(message, style);
}, delayMs);
@disco0
disco0 / metamethods.md
Last active December 1, 2020 04:10 — forked from thibaultcha/metamethods.txt
Lua metamethods Compatibility

via Sean Conner on lua-l

Metamethod 5.1 5.2 5.3 Syntax Notes
__add ✔️ ✔️ ✔️ a + b
__sub ✔️ ✔️ ✔️ a - b
__mul ✔️ ✔️ ✔️ a * b
__div ✔️ ✔️ ✔️ a / b
__mod ✔️ ✔️ ✔️ a % b
__pow ✔️ ✔️ ✔️ a ^ b
@disco0
disco0 / index.pug
Last active November 17, 2020 06:00 — forked from zeddash/index.pug
Footer blobs #codepen
-
var base = 2,
exp = 8,
listEnts = false;
div.main
div.footer
div.bubbles
-
for (var i = 0; i < Math.pow(base, exp); i++) //Small numbers looks nice too
@disco0
disco0 / GM_download_emu.user.js
Last active October 21, 2020 12:27 — forked from derjanb/GM_download_emu.user.js
GM_download Alternate
// ==UserScript==
// @name GM_download emulation
// @namespace http://tampermonkey.net/
// @version 0.1
// @description emulate GM_download functionality
// @require https://github.com/eligrey/FileSaver.js/blob/master/dist/FileSaver.min.js
// @grant GM_xmlhttpRequest
// @copyright 2014, Jan Biniok
// ==/UserScript==
@disco0
disco0 / OldReddit.user.js
Last active October 21, 2020 12:12 — forked from simshaun/Reddit.user.js
Userscript - Redirect all reddit pages through old.reddit.com
// ==UserScript==
// @name Old Reddit, Forever
// @namespace gitlab.com/disk0/userscript/reddit/old
// @version 0.1.0
// @author disk0
// @include /^https?:\/\/((?!old)[a-z][a-z\d_]*\.)?reddit\.com.*/
// @grant none
// @run-at document-start
// ==/UserScript==
@disco0
disco0 / function-iterator.js
Created October 15, 2020 02:01 — forked from nicholasguyett/function-iterator.js
Functional Iterator
/* This class wraps an iterator/iterable and allows the map/filter/reduce methods
* to be used without being forced to make intermediate temporary arrays.
* I've also implemented the flatten and flatmap functions for convenience
*/
class FunctionalIterator {
constructor(source) {
// Get iterator from source, if present. Otherwise, assume that the source is an iterator
this.source = source[Symbol.iterator] ? source[Symbol.iterator]() : source;
}
@disco0
disco0 / virtualizing-problem.ts
Created October 15, 2020 02:00 — forked from mmichlin66/virtualizing-problem.ts
Virtualizing TypeScript Properties with Proxy and Decorator - listing 1
class Base
{
first = { v: 1 };
second = this.first;
}
class Derived extends Base
{
first = { v: 2 };
}
@disco0
disco0 / virtualizing-with-function.ts
Created October 15, 2020 02:00 — forked from mmichlin66/virtualizing-with-function.ts
Virtualizing TypesScript Class Properties with Proxy and Decorator - listing 2
class Base
{
first = { v: 1 };
second = () => this.first;
}
class Derived extends Base
{
first = { v: 2 };
}
@disco0
disco0 / virtualizing-with-proxy.ts
Created October 15, 2020 02:00 — forked from mmichlin66/virtualizing-with-proxy.ts
Virtualizing TypeScript Properties with Proxy and Decorator - listing 3
class VirtHandler
{
target: any;
get( t: any, p: PropertyKey, r: any): any
{
return this.target[p];
}
}