Skip to content

Instantly share code, notes, and snippets.

View larvanitis's full-sized avatar

Leonidas Arvanitis larvanitis

  • Athens, Greece
View GitHub Profile
@larvanitis
larvanitis / machine.js
Last active August 5, 2020 08:08
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// see: https://gist.github.com/grindpride/e436290d359b6da878b320b8ebf33446
declare module 'tiptap-extensions' {
import { Extension, Node, Mark, Editor } from 'tiptap';
import { Plugin } from 'prosemirror-state';
export class Blockquote extends Node {}
export class BulletList extends Node {}
export class Code extends Node {}
@larvanitis
larvanitis / ts_enum_objects.ts
Created July 26, 2023 15:27
TypeScript enum-like objects and util functions
// utils
type EnumValue<T> = T[keyof T];
type EnumKey<T> = keyof T;
export function isEnumValue<T extends Record<string, unknown>>(
enm: T,
value: unknown
): value is EnumValue<T> {
return Object.values(enm).includes(value as any);
@larvanitis
larvanitis / convert.py
Last active August 16, 2023 15:54
Covert miss-typed EN <-> EL text | tags: keyboard, layout
def make_uppercase_variants(dictionary: dict[str, str]):
upper = {}
for key, value in dictionary.items():
upper[key.upper()] = value.upper()
return upper
def reverse_dictionary(dictionary: dict[str, str]):
return {value: key for key, value in dictionary.items()}