Skip to content

Instantly share code, notes, and snippets.

View lukewarlow's full-sized avatar

Luke Warlow lukewarlow

View GitHub Profile
@lukewarlow
lukewarlow / dialog-requestClose.js
Created February 18, 2025 18:39
Polyfill for HTMLDIalogElement requestClose()
if (!('requestClose' in HTMLDialogElement.prototype)) {
HTMLDialogElement.prototype.requestClose = function (returnValue) {
if (!this.open)
return;
if (this.dispatchEvent(new Event('cancel', {cancelable: true})))
this.close(returnValue);
}
}
@lukewarlow
lukewarlow / WebIDL.g4
Last active August 1, 2024 17:33
A g4 definition file to build a WebIDL parser using Antlr.
grammar WebIDL;
Integer: '-'?( [1-9] [0-9]*|'0'[Xx] [0-9A-Fa-f]+|'0'[0-7]*);
Decimal: '-'?(([0-9]+'.'[0-9]*|[0-9]*'.'[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+);
Identifier: [_-]?[A-Za-z][0-9A-Z_a-z-]*;
String: '"'[^"]*'"';
Whitespace: [\t\n\r ]+ -> skip;
Comment: ('/*' .*? '*/' | '//' ~ [\n]*) -> skip;
Other: [^\t\n\r 0-9A-Za-z];
@lukewarlow
lukewarlow / LibraryTest.go
Created August 12, 2018 18:16
Example of how to use the GoConsoleMenu library
package main
import (
"github.com/lukewarlow/GoConsoleMenu"
"fmt"
)
func main() {
subMenu := GoConsoleMenu.NewMenu("Welcome to the test sub menu")
subMenu.AddMenuItem(GoConsoleMenu.NewActionItem(0, "Exit current menu", func() {}).SetAsExitOption())