Skip to content

Instantly share code, notes, and snippets.

View mastermakrela's full-sized avatar

Christoph mastermakrela

View GitHub Profile
@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 / 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 / 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];