Skip to content

Instantly share code, notes, and snippets.

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 / messageBroker.js
Last active May 14, 2020
Vue.js EventBus approach
View messageBroker.js
const listeners = ctx => {
if (!ctx.$options.on) {
return
}
const listeners = {}
Object.entries(ctx.$options.on)
.forEach(([event, callback]) => {
listeners[event] = callback.bind(ctx)
@vinicius73
vinicius73 / Makefile
Last active Mar 29, 2020
Terraform + Digital Ocean Spaces
View Makefile
init:
@read -p "SPACES_ACCESS_TOKEN=" SPACES_ACCESS_TOKEN; \
read -p "SPACES_SECRET_KEY=" SPACES_SECRET_KEY; \
read -e -p "SPACE_BUCKET_NAME=" -i "space-name" SPACE_BUCKET_NAME; \
terraform init \
-backend-config="access_key=$$SPACES_ACCESS_TOKEN" \
-backend-config="secret_key=$$SPACES_SECRET_KEY" \
-backend-config="bucket=$$SPACE_BUCKET_NAME"
plan:
View Deferrer.kt
package xx
class Deferrer {
private val actions = arrayListOf<() -> Unit>()
fun defer(f: () -> Unit) {
actions.add(f)
}
fun done() {
@vinicius73
vinicius73 / Dockerfile
Last active Mar 22, 2020
Docker - Front-end APP
View Dockerfile
FROM node:12-alpine as build-stage
RUN apk add --no-cache curl gnupg libstdc++
WORKDIR /app
COPY package*.json ./
COPY yarn.lock ./
RUN yarn install
COPY . .
ARG MODE=production
@vinicius73
vinicius73 / .dockerignore
Created Mar 22, 2020
Docker + PM2 - Node Backend APP
View .dockerignore
node_modules/
dist/
.git/
View logger.js
const pino = require('pino')
const dest = pino.destination()
const logger = pino({
name: process.env.APPLICATION_NAME || 'my-app',
level: process.env.LOG_LEVEL || 'info',
useLevelLabels: true,
base: {
}
}, dest)
View 99-vidas-bonus-downloader.js
const fs = require('fs')
const path = require('path')
const slug = require('slug')
const axios = require('axios')
const progress = require('progress')
const urlRegx = /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/gi;
const readList = async () => {
console.info('Loading file data')
@vinicius73
vinicius73 / index.js
Created Dec 1, 2019
Script de sorteio inimigo/amigo oculto
View index.js
const { shuffle, map } = require('lodash')
const { sendMessages } = require('./send-email')
const input = shuffle(require('./input.json'))
function assign (array) {
return map(array, (person, index, array) => {
const friend = array[index + 1] || array[0]
return {
person,
@vinicius73
vinicius73 / Dockerfile
Created Oct 25, 2019
jupyter - docker compose
View Dockerfile
FROM continuumio/anaconda3
RUN /opt/conda/bin/conda install jupyter
RUN mkdir -p /opt/notebooks/notebook
EXPOSE 8888
CMD /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root
@vinicius73
vinicius73 / Dockerfile
Last active Aug 15, 2019
Node project with PM2 and Docker
View Dockerfile
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
You can’t perform that action at this time.