Skip to content

Instantly share code, notes, and snippets.

View maninak's full-sized avatar
🧐
Scanning for my next big challenge. Hiring? Mail me at [email protected] .

Kostis Maninakis maninak

🧐
Scanning for my next big challenge. Hiring? Mail me at [email protected] .
View GitHub Profile
@maninak
maninak / useModifiedSlot.ts
Last active January 22, 2022 18:13
A composable to modify/change attributes/props (e.g. `class` or `style`) of slotted elements when using v-slot in vue.js [wip]. Only to be used in render (aka `h()`) functions.
import type { SetupFunction } from '@nuxtjs/composition-api'
import type { CreateElement, VNode } from 'vue'
function useModifiedSlot(
slotName: string,
dataToAppend: Required<Parameters<CreateElement>>['1'],
) {
const slot = getCurrentInstance()?.slots[slotName]
const slotVnode = Array.isArray(slot) && slot[0].data
@maninak
maninak / tw-color-classes.scss
Created December 8, 2021 19:40
A handy SASS mixin allowing using one-off color classes and @apply from Tailwind CSS the familiar way without needing to add them in the global config.
@tailwind base;
@mixin tw-base-layer-wrap {
@layer base {
@content;
}
@content;
}
@maninak
maninak / presentation-joycon.js
Last active February 5, 2021 12:45
Change presentation slides with a Nintendo Switch Joycon controller with the power of the web's native Gamepad API. The joycon must already be connected with your computer (pc/mac/linux) via bluetooth (hold connect button on controller until "searching" mode). Only left and right buttons implemented. Any button could easily be mapped differenly..
// connect the left joycon to any computer via bluetooth and paste the following script in the console of a webpage
(() => {
const VENDOR_ID = '057e';
const DEVICE_ID = '2006';
const [LEFT_BUTTON, RIGHT_BUTTON] = [0, 3];
const [LEFT_ARROW_KEY_CODE, RIGHT_ARROW_KEY_CODE] = [37, 39];
let gamepadIndex, intervalID, isPressing = false;
function pressKey(keyCode) {
/**
* Debounces (postpones) executing `func` until _at least_ `msWait` seconds have elapsed
* since the last time the same function had again been requested to execute.
*
* Example:
* const repaintElem = setRandomBgColorToElem(elem);
* document.addEventListener('resize', debounce(repaintElem, 10, true));
*
* @param {function} func The function to be debounced
* @param {number} [msWait=50] The minimum amount of time in miliseconds to wait before executing `func`
@maninak
maninak / optimalWoodCut.js
Last active February 23, 2020 18:16
Wanted to cut planks of wood. The size of the possible cuts was fixed. Wanted to utilize as much of the wooden planks as possible. Like any other engineer I took this to the editor :P .
// CONSTANTS
// =====================
const a = 210; // length of a possible cut
const b = 156; // length of another possible cut
const c = 138; // length of another possible cut
const K = 590; // length of the wood plank to be cut in pieces of the above lengths
@maninak
maninak / heapSort-people-by-age.js
Created July 7, 2017 18:49
A javascript implementation of Heap Sort algorithm that sorts an array of objects {age: number, string: name} in ascending order of age.
/* ------ Input Data ---------------------------*/
let people = [
{
"age": 34,
"name": "Malone Warren"
},
{
"age": 50,
@maninak
maninak / History|-11ca93da|entries.json
Last active August 5, 2022 10:16
Visual Studio Code Sync Settings GIST
{"version":1,"resource":"file:///mnt/Kinder/work/Codica/code/gentwo.com/composables/useClassesInBody.ts","entries":[{"id":"r6zN.ts","timestamp":1652182261912},{"id":"Uarg.ts","source":"Fix all ESLint auto-fixable problems","timestamp":1654880390400},{"id":"dvfh.ts","source":"Fix all ESLint auto-fixable problems","timestamp":1654880536159},{"id":"ntrZ.ts","timestamp":1654881076174},{"id":"YDXZ.ts","source":"Fix all ESLint auto-fixable problems","timestamp":1654881334709},{"id":"hY0c.ts","source":"Fix all ESLint auto-fixable problems","timestamp":1654881400556},{"id":"GigS.ts","timestamp":1654881678684},{"id":"Keo4.ts","timestamp":1654881728721},{"id":"mQ0I.ts","timestamp":1654881885787}]}
@maninak
maninak / .gitconfig
Last active February 20, 2024 10:01
My git-config & aliases. Place this file in your home folder (e.g.: /home/maninak/.gitconfig). Learn more: https://medium.com/@maninak/git-fancy-with-your-version-control-a3a895d1dede
[user]
email = [email protected]
name = Firstname Lastname
[merge]
# delete if you don't use meld
tool = meld # sudo apt-get install meld
conflictStyle = diff3
[init]