Skip to content

Instantly share code, notes, and snippets.

View hawkeye64's full-sized avatar

Jeff Galbraith hawkeye64

View GitHub Profile
@IlCallo
IlCallo / injector-factory.ts
Last active January 17, 2022 14:56
Create an injection key and helper function based on a name and an interface describing the injected data. Automatically adds safeguard when the provided data cannot be found
import { inject, InjectionKey, provide } from 'vue';
function getValueFromMaybeFunction<
Args extends unknown[],
Provided,
T = Provided extends (...args: Args) => infer R ? R : Provided
>(params: Args, valueOrFn: Provided): T {
// TS isn't able to narrow down correctly `T | () => T` types as infer `ReturnType<Function>` as any
// See: https://github.com/microsoft/TypeScript/issues/37663
// See: https://github.com/microsoft/TypeScript/issues/37993#issuecomment-615369691
@IlCallo
IlCallo / move.ts
Last active March 14, 2024 16:21
Apply Drag and Drop to QTable rows using SortableJs
// Taken from https://github.com/angular/components/blob/master/src/cdk/drag-drop/drag-utils.ts
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
[
{
"currency": "Albania Lek",
"abbreviation": "ALL",
"symbol": "&#76;&#101;&#107;"
},
{
"currency": "Afghanistan Afghani",
"abbreviation": "AFN",
"symbol": "&#1547;"
@Artaud
Artaud / jobWorker.ts
Last active May 31, 2024 16:47
Basic worker thread pool in Feathers, using threads.js
import { expose } from "threads/worker"
const jobWorker = {
async doMyJob() {
console.log('Hello from worker thread!')
}
}
export type JobWorker = typeof jobWorker
expose(jobWorker)
import { inject, ref, provide } from '@vue/composition-api';
export function useAppBarProviders() {
const title = ref('');
function updateTitle(newTitle: string) {
title.value = newTitle;
}
provide('updateAppBarTitle', updateTitle);
@simibac
simibac / currencies.json
Last active May 4, 2024 21:00
global currencies as list and sql script (157 currencies)
[
{
"code": "EUR",
"name": "Euro",
"name_plural": "euros",
"symbol": "",
"symbol_native": "",
"decimal_digits": 2,
"rounding": 0
},
<template>
<q-dialog v-model="swDialog" persistent ref="myDialog" @show="onShow" @hide="onHide">
<q-card>
<q-bar class="bg-primary text-white" :class="draggable?'cursor-move':''">
<div class="text-h6">{{title}}</div>
<q-space />
<q-btn dense flat icon="close" v-close-popup />
</q-bar>
<slot></slot>
</q-card>
@coenraadhuman
coenraadhuman / inotify.md
Last active September 4, 2024 10:34
Increasing the amount of inotify watchers

Increasing the amount of inotify watchers

Take note this is my personal edited version and the command related to Arch has been changed to work on my Arch system.

Increase inotify watchers

// https://github.com/michael-ciniawsky/postcss-load-config
const purgecss = require('@fullhuman/postcss-purgecss')
const conf = require('./quasar.conf')()
const ie = conf.supportIE ? ['./node_modules/quasar/src/ie-compat/*.js'] : []
const plugins = conf.framework.plugins.map(plug => {
return `./node_modules/quasar/src/plugins/${plug}.js`
})
@acfatah
acfatah / index.js
Last active May 26, 2024 10:59
Quasar Vue Router Middleware Pipeline Example
// router/index.js
import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
import middlewarePipeline from './middleware-pipeline'
Vue.use(VueRouter)