Skip to content

Instantly share code, notes, and snippets.

View Eder87rh's full-sized avatar

Eder Ramírez Hernández Eder87rh

View GitHub Profile
@Eder87rh
Eder87rh / pivot-helper.js
Created July 30, 2019 23:26
pivot-helper.js
function pivot(arr, start=0, end=arr.length + 1) {
function swap(array, i, j) {
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
var pivot = arr[start];
var swapIdx = start;
@Eder87rh
Eder87rh / wesbos-array cardio.js
Created July 6, 2019 15:33
wesbos-array cardio.js
const inventors = [
{ first: 'Albert', last: 'Einstein', year: 1879, passed: 1955 },
{ first: 'Isaac', last: 'Newton', year: 1643, passed: 1727 },
{ first: 'Galileo', last: 'Galilei', year: 1564, passed: 1642 },
{ first: 'Marie', last: 'Curie', year: 1867, passed: 1934 },
{ first: 'Johannes', last: 'Kepler', year: 1571, passed: 1630 },
{ first: 'Nicolaus', last: 'Copernicus', year: 1473, passed: 1543 },
{ first: 'Max', last: 'Planck', year: 1858, passed: 1947 },
{ first: 'Katherine', last: 'Blodgett', year: 1898, passed: 1979 },
{ first: 'Ada', last: 'Lovelace', year: 1815, passed: 1852 },
@Eder87rh
Eder87rh / 5 -cropchien - createDog - index.js
Created April 13, 2019 17:20
5 -cropchien - createDog - index.js
exports.createDog = functions.firestore
.document('dogs/{dogId}')
.onCreate(event => {
var dog = event.data();
console.log(dog.comment);
axios.post(`https://fcm.googleapis.com/fcm/send`,{
"to" : "/topics/general",
"priority" : "high",
@Eder87rh
Eder87rh / 5 - cropchien - vue.config.vue
Created April 13, 2019 16:09
5 - cropchien - vue.config.vue
module.exports = {
pwa: {
// configure the workbox plugin
workboxPluginMode: 'InjectManifest',
workboxOptions: {
swSrc: "src/firebase-messaging-sw.js"
}
}
}
@Eder87rh
Eder87rh / 5 - cropchien - firebase-messaging-sw.js
Last active April 13, 2019 16:20
5 - cropchien - firebase-messaging-sw.js
importScripts('https://www.gstatic.com/firebasejs/5.6.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/5.6.0/firebase-messaging.js');
self.__precacheManifest = [].concat(self.__precacheManifest || []);
workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
workbox.routing.registerRoute(
new RegExp('https://firebasestorage.googleapis.com/v0/b/cropchien.appspot.com/.*'),
workbox.strategies.staleWhileRevalidate()
@Eder87rh
Eder87rh / 5 - cropchien - postmanNotifiction.json
Last active April 6, 2019 18:10
5 - cropchien - postmanNotifiction.json
{
"to" : "/topics/general",
"priority" : "high",
"notification" : {
"title" : "Cropchien",
"body" : "Notification test :)",
"click_action": "http://localhost:8081",
"icon": "http://localhost:8081/chrome/chrome-installprocess-128-128.png"
}
}
@Eder87rh
Eder87rh / 5 - cropchien App.vue
Created March 31, 2019 23:58
5 - cropchien App.vue
<template>
<v-app>
<v-toolbar app>
<v-btn
icon v-if="$route.name !== 'home'"
@click="$router.go(-1) "
>
<v-icon>arrow_back</v-icon>
</v-btn>
<v-toolbar-title >
@Eder87rh
Eder87rh / 5 - cropchien - configFirebase.js
Created March 30, 2019 15:47
5 - cropchien - configFirebase.js
import firebase from 'firebase/app'
import 'firebase/firestore';
import 'firebase/messaging';
import 'firebase/storage';
const config = {
apiKey: "####",
authDomain: "####",
databaseURL: "####",
projectId: "####",
@Eder87rh
Eder87rh / 5 - cropchien - serverKey.js
Created March 23, 2019 17:48
5 - cropchien - serverKey.js
module.exports = "[PASTE_YOUR_SERVER_KEY_HERE]";
@Eder87rh
Eder87rh / 5 - cropchien - GeneralSubscription - index.js
Last active April 6, 2019 15:32
5 - cropchien - GeneralSubscription - index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const axios = require('axios');
var cors = require('cors') ({origin:true});
const serverKey = require('./serverKey');
admin.initializeApp(functions.config().firebase);
let firestore = admin.firestore()
exports.GeneralSubscription = functions.https.onRequest((request, response) => {