Skip to content

Instantly share code, notes, and snippets.

@Totati
Totati / cookie-clicker-auto.js
Last active July 11, 2023 06:47
Cookie clicker
import { nothing } from 'lit';
import { AsyncDirective, directive, ElementPart, PartInfo, ElementPartInfo, PartType } from 'lit/async-directive.js';
/**
* @emits accept - when the user accept the dialog
* @emits decline - when the user declines the dialog
*/
class ConfirmDialogDirective extends AsyncDirective {
private element?: Element;
private config?: ConfirmDialogOptions;
@Totati
Totati / get-magic-number.ts
Last active June 8, 2021 12:22
Read the magic number of a file
export async function getMagicNumber(file: File, signatureLength: number = 4) {
return file
.slice(0, signatureLength)
.arrayBuffer()
.then((buffer) =>
Array.from(new Uint8Array(buffer))
.map((byte) => byte.toString(16).padStart(2, '0'))
.join('')
.toUpperCase()
);