Skip to content

Instantly share code, notes, and snippets.

View MichaelFedora's full-sized avatar
🍱
Always Tinkering

Michael C. MichaelFedora

🍱
Always Tinkering
  • East Coast, USA
View GitHub Profile
@MichaelFedora
MichaelFedora / express-router-util.ts
Last active June 13, 2023 21:30
Parse router layers into something usable
/**
* Parse Express Router Layers into something usable, with
* formatted paths, parameters lists, and ancestry tracking.
*/
/**
* A "reduced layer", the output of `reduceStack`. Has
* simplified information in it.
*/
export interface ReducedLayer {
@MichaelFedora
MichaelFedora / wrapped-storage.ts
Last active February 4, 2022 15:48
Wrap a web storage with a prefix
/**
* Wrap a web storage with a prefix.
* @author Michael Fedora
* @link https://gist.github.com/MichaelFedora/031e1ec7a3df736b2b004d6b437e526e
*/
export class WrappedStorage implements Storage {
#store: Storage;
#prefix: string;
#key(k: string): string { return `${this.#prefix}_${k}`; }
@MichaelFedora
MichaelFedora / api-types.ts
Created January 27, 2022 18:26
Another tiny express-like http router thing
export interface TinyRequest {
// CORE (std)
url: string;
method: string;
headers: Headers;
json<T = unknown>(): Promise<T>;
text(): Promise<string>;
<template>
<transition name='fade'>
<div v-if='active'
class='modal is-active'
:class='{ [type]: true }'
role='dialog'
aria-modal='true'>
<div class='modal-background' @click='cancel()'></div>
<div class='modal-card'>
<header v-show='title'>
@MichaelFedora
MichaelFedora / temdata.json
Created February 2, 2020 21:12
Some Temtem Data, in JSON
[
{
"id": 2,
"name": "Oree",
"type": ["Digital"],
"stats": {
"hp": 0,
"sta": 0,
"spd": 0,
"atk": 0,
@MichaelFedora
MichaelFedora / rethink-session-store.ts
Created July 18, 2019 21:58
An Express-Session store for use with rethinkdb-ts.
import { r, RTable } from 'rethinkdb-ts';
import { Store } from 'express-session';
import { getLogger, Logger } from '@log4js-node/log4js-api';
export class SessionEntry {
id: string;
expires: Date;
session: Express.SessionData;
}
@MichaelFedora
MichaelFedora / fs-extra-size.js
Created June 8, 2019 15:56
fs-extra-size proposal
const fs = require('fs-extra');
const path = require('path');
/**
* Get's the size of a file or directory.
*
* @param {string} p The path to the file or directory
* @returns {number}
*/
function sizeSync(p) {
@MichaelFedora
MichaelFedora / playcanvas-stable.d.ts
Last active December 29, 2017 14:20
PlayCanvas Engine Typings (wip). Use it by downloading and placing both this and `playcanvas-stable.js` in the same directory.
/**
* PlayCanvas Engine Typings
*
* Use it by downloading and placing both this and `playcanvas-stable.js` in the same directory.
*
* (c) 2017 Michael Fedora (michaelfedora.github.io)
* Licensed under MIT.
*/
type DomKeyboardEvent = KeyboardEvent;
@MichaelFedora
MichaelFedora / main.ts
Created July 29, 2017 16:26
dynamic import test
(async () => {
let foo = (i: number): [number, Promise<any>] => {
switch(i) {
case 0: return [4, import('./test')];
default: return [0, Promise.resolve(null)];
}
}
const res = foo(0);
console.log(res[0], await res[1]);
// should output `4 { default: { greeting: 'Hello World!' } }`
@MichaelFedora
MichaelFedora / nbt_error.log
Last active March 13, 2016 03:34
DataAPI writing error, Sponge v4.1.0-SNAPSHOT (currently 4.0.3)
/*
This happens after writing to the sign, though the DataTransactionResult says it succeeds, I don't think it does (have to double-check).
The first one happens when secondary(right)-clicking the sign.
The second one then happens every so often afterwards.
After restarting the server, there is no sign-text anymore.
This is my plugin, Fedora's Market, built off of Sponge 4.1.0-SNAPSHOT, JDK 1.8.0_77.
The server is running on Forge 1764, Sponge 4.0.3.
*/
[17:27:03] [Server thread/FATAL]: Error executing task