Skip to content

Instantly share code, notes, and snippets.

View mastermakrela's full-sized avatar

Christoph mastermakrela

View GitHub Profile
@mastermakrela
mastermakrela / file_handlers.ts
Last active October 18, 2024 14:43
File selector for js/ts
export async function open_file({ accept }: { accept?: string }): Promise<File> {
const input = document.createElement('input');
input.type = 'file';
if (accept) input.accept = accept;
input.click();
return new Promise((resolve, reject) => {
input.onchange = () => {
const file_handle = input.files?.[0];
@mastermakrela
mastermakrela / settings.json
Created October 11, 2024 18:54
VS Code settings to use Deno's TypeScript instead of the default one
{
"deno.enable": true,
"deno.lint": true,
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
},
"typescript.tsserver.experimental.enableProjectDiagnostics": false
}
@mastermakrela
mastermakrela / macbook_tilt.js
Last active September 8, 2025 19:55
Utilities to get the current tilt of an Apple MacBook
/**
* Async generator that yields the MacBook lid tilt angle,
* but only when the angle changes (debounced).
* If the device is unavailable, it yields 0 once and stops.
*
* @returns {AsyncGenerator<number, void, unknown>}
*/
async function* getMacBookTilt() {
/** @type {HIDDevice | undefined} */
let device;
@mastermakrela
mastermakrela / README.md
Last active June 27, 2026 20:29
DialogLayer: SwiftUI-style isPresented dialogs for Flutter, built on OverlayPortal — dialogs that can only dismiss themselves and can never accidentally pop the route behind them.

DialogLayer

SwiftUI-style isPresented dialogs for Flutter, built on OverlayPortal.

The problem

The usual showDialog(...) pushes a route. Closing it means Navigator.of(context).pop() — but pop() removes whatever is on top of that navigator, not "this dialog". Pass the wrong BuildContext (easy with nested dialogs) and you pop the page behind the dialog by accident. Flutter has no