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 / 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()}
@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 / 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 / component-wrapper.js
Created June 2, 2020 16:19
Quasar Component Wrapper
import Vue from 'vue';
import {quasarInit} from './quasar';
// props are required if you want to be able to do `vm.$data.myProp = 'xyz'` later
export function createComponent(component, elementOrSelector, props = {}) {
const el = resolveElement(elementOrSelector);
let origHtml = el.innerHTML;
Vue.config.productionTip = false;
quasarInit();
@larvanitis
larvanitis / index.html
Created June 2, 2020 16:05
Quasar Component Outside Vue
<!-- assuming you have placed this outside `dist` dir -->
<html>
<head>
<meta charset="utf-8">
<title>Quasar Component Demo</title>
<link rel="stylesheet" href="./dist/myComponent.css">
</head>
<body>
<div id="my-component-selector"></div>
/*
* Maximizes the height of an element, using flex laytout,
* by applying classes to the element and it's parents.
* Warning: It breaks a lot of layouts and it is not a substitute for proper,
* hand-crafted code. Also, it is not really tested!
*/
/** Shorthand for `toggleMaxHeightElem(..., isMaximize = true)` */
function maximizeElemHeight(elem, topParent = 'html') {
toggleMaxHeightElem(elem, topParent, true);
@larvanitis
larvanitis / howto.sh
Last active September 20, 2017 10:00
Encrypted file container
#!/bin/sh
echo "Not a script..." >&2 && exit 1
# This is more or less a TL;DR; procedure to create and use an encrypted volume contained in a file instead of a physical drive/partition.
# The encryption options are set to sane (and IMHO secure) values. The device will be (un)locked using a password.
# The mounting is done manually by the root and all users can access the mounted filesystem.
################
# REQUIREMENTS #
@larvanitis
larvanitis / jquery.semantic-ui.d.ts
Created May 21, 2017 16:48
Custom SemanticUI typescript definitions
// tslint:disable:max-file-line-count
declare namespace SemanticUI {
type JQuerySelectorOrElement = string | Element | JQuery;
type AnimationDuration = string | number; // '500ms'
type AnimationName = 'scale' | 'scale in' | 'scale out'
| 'fade' | 'fade up' | 'fade down' | 'fade left' | 'fade right'
| 'fade in' | 'fade up in' | 'fade down in' | 'fade left in' | 'fade right in'
# Maintainer: Leonidas Arvanitis <l.arvanitis gmail com>
# Contributor: Marius Nestor <marius softpedia com>
pkgname=musictube
pkgver=1.6
pkgrel=1
pkgdesc="YouTube streaming music player"
arch=('x86_64')
url="http://flavio.tordini.org/musictube"
license=('Proprietary')