Skip to content

Instantly share code, notes, and snippets.

View vis97c's full-sized avatar
🧠
Cogito ergo sum

Victor Saa vis97c

🧠
Cogito ergo sum
View GitHub Profile
@doorgan
doorgan / typed-vuex.ts
Last active March 14, 2021 03:00
Typed vuex mapState
import { mapState as originalMapState } from "vuex";
// Utilities to map the record fields to their function return types
// See https://github.com/microsoft/TypeScript/issues/15763#issuecomment-364205392
type ReturnType<T> = T extends (...args: any[]) => infer R ? R : never;
type MappedOutputs<T> = {
[P in keyof T]: () => ReturnType<T[P]>; // This is a lambda so it fulfills vuex's contract
};
type MapperRecord<S> = Record<string, (store: S) => any>;
@loilo
loilo / readme.md
Last active November 3, 2022 20:31
Async Computed Values for Vue 3

Async Computed Values for Vue 3

This gist provides a useAsyncComputed function which allows to create asynchronous dependencies on reactive values (using Vue 3's Composition API).

Requires at least Vue 3.0 and TypeScript 4.0.

Usage

Basic Usage

<?php
$municipios = array(
"antioaquia" => array(
'CO1' => 'Abejorral - Antioquia',
'CO3' => 'Abriaquí - Antioquia',
'CO23' => 'Alejandría - Antioquia',
'CO33' => 'Amagá - Antioquia',
'CO34' => 'Amalfi - Antioquia',
'CO39' => 'Andes - Antioquia',
@yairEO
yairEO / jsbin.nujus.js
Last active August 30, 2023 17:26
auto-generates month names in any locale
var months = [];
for( var i = 0; i < 12; i++ ){
months.push( new Date(0,i).toLocaleString({},{month:'short'}) );
// you can also pass a local like : "en-US" instead of an empty object `{}`.
// an empty object triggers the system's auto-detection
}
console.log(months);