Skip to content

Instantly share code, notes, and snippets.

View CristalT's full-sized avatar

Marcelo Forclaz CristalT

View GitHub Profile
import axios from 'axios'
const axiosInstance = axios.create({
baseURL: process.env.API
})
export default ({ Vue }) => {
Vue.prototype.$axios = axiosInstance
}
@CristalT
CristalT / transaccion.js
Created June 13, 2019 02:49
Ejemplo de cómo buscar la numeración del próximo cliente y crearlo en la Firestore.
const data = this.cliente
const counterRef = this.$firestore.collection('contadores').doc('clientes_motos')
const clientesRef = this.$firestore.collection('clientes/motos/activos')
return this.$firestore.runTransaction(transaction => {
return transaction.get(counterRef).then(counterDoc => {
if (!counterDoc.exists) {
throw new Error('No se encontró el contador de clientes')
}
<template>
<q-table
row-key="key"
:data="table.data"
:columns="table.columns"
:pagination.sync="table.pagination"
>
<q-tr
slot="body"
slot-scope="props"
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
@CristalT
CristalT / QUploaderFirebaseExtension.js
Created April 12, 2019 04:38
Extension for QUploader component making it able to upload files throw Firebase Storage
import { QUploaderBase } from 'quasar'
export default {
props: ['refStorage'],
name: 'FirebaseUploader',
data () {
return {
uploading: '',
uploadTask: {}
// hypothetical undefined value
const name = undefined
// Way 1:
const firstName1 = name || 'Marcelo'
console.log(firstName1)
// Way 2:
const firstName2 = name ? name : 'Marcelo'
console.log(firstName2)
// Two ways to filter an Array of Objects
const heros = [
{ label: 'Batman' },
{ label: 'Iron Man' },
{ label: 'Superman' },
{ label: 'Green Lantern' }
]
const token = 'Superman'
// Two ways to remove array duplicates
const array = [1, 2, 3, 4, 4, 4, 5]
// Way 1
let uniq = array.filter((el, index) => array.indexOf(el) === index)
console.log(uniq)
// Way 2
uniq = [...new Set(array)]
console.log(uniq)
// Two Ways To round a number at 2 decimals
const number = 19.5862365
// Way one
let result = Math.round(number * 100) / 100
console.log(result)
// Way two
result = parseFloat(number.toFixed(2)) // parseFloat() to keep number type
console.log(result)
// replicate an object excepting some items
const hero = {
name: 'Bruno',
alterego: 'Batman',
superpowers: false,
couching: 8
}
// Way one
const { couching, name, ...collection } = hero