Skip to content

Instantly share code, notes, and snippets.

View vinicius73's full-sized avatar
🤓
"Those who cannot acknowledge themselves, will eventually fail."

Vinicius Reis vinicius73

🤓
"Those who cannot acknowledge themselves, will eventually fail."
View GitHub Profile
@vinicius73
vinicius73 / Dockerfile
Last active August 15, 2019 22:21
Node project with PM2 and Docker
FROM node:10.15-alpine as base
RUN apk --no-cache --virtual build-dependencies add \
python \
make \
g++ \
&& rm -f /var/cache/apk/* \
&& npm config set unsafe-perm true \
&& npm install --quiet node-gyp -g --cache /tmp/empty-cache
@vinicius73
vinicius73 / main.js
Created February 19, 2019 19:31
Vuex Route Guard DEMO
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import plugins from './plugins';
plugins({
router, store, Vue,
});
import { isEmpty } from 'lodash'
import { makeWatch, makeCallback, parseDump } from './utils'
const extractDump = context => {
const dump = context.$route.query.dump
return dump
? parseDump(dump)
: {}
}
import { PromisePipeFactory } from './p-pipe'
import { isFunction, isArray } from 'lodash'
const w = window
/**
* @type Function
* @param {Function}
* @returns {void}
*/
const subscribe = (() => {
@vinicius73
vinicius73 / index.js
Last active September 21, 2018 22:23
$nextTickInSequence
import $nextTickInSequence from './next-tick-in-sequence'
export const install = Vue => {
Object.defineProperty(Vue.prototype, `$nextTickInSequence`, {
get: () => $nextTickInSequence
})
}
self.addEventListener('notificationclick', function(e) {
// Android doesn't automatically close notifications on click
e.notification.close();
// Focus tab if open
e.waitUntil(clients.matchAll({
type: 'window'
}).then(function(clientList) {
for (var i = 0; i < clientList.length; ++i) {
var client = clientList[i];
function formatTime (timeInMs) {
let date = new Date(timeInMs)
// ${date.getDate()}/${date.getMonth()}/${date.getFullYear()}
return `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}.${date.getMilliseconds()}`
}
function log (type, ...args) {
if (this.$options.debug) {
console[type](`%c[${this.$_id}]${formatTime(Date.now())}>> `,
`background:${type === 'log' ? '#384A5E' : type === 'warn' ? '#F1BF39' : '#FF5370'}; padding: 3px; border-radius: 3px; color: #fff`,
const appName = 'App Web'
const companyName = 'D6'
const version = '1.0.0'
const hasSw = (navigator.serviceWorker && navigator.serviceWorker.controller)
const mode = (window.matchMedia('(display-mode: standalone)').matches)
? 'standalone'
: 'web'
const sw = hasSw
? 'sw-on'
@vinicius73
vinicius73 / Dockerfile
Last active May 11, 2018 21:20
Node + PostgreSQL
FROM node:8.9-alpine
RUN npm install --global yarn && \
yarn global add pm2 && \
yarn