Skip to content

Instantly share code, notes, and snippets.

View jonathanborges's full-sized avatar

Jonathan Borges jonathanborges

  • Brazil, Minas Gerais
View GitHub Profile
const MongoClient = require('mongodb').MongoClient
const url = `mongodb://root:mo1542653!@localhost:27017/?authMechanism=SCRAM-SHA-1&authSource=admin`
var _connInstance
const getInstance = async () => {
if (!_connInstance) {
_connInstance = await getConnection()
}
return _connInstance
export const currency = (value, decimalPlaces = 2, symbol = true) => {
let formatedValue = parseFloat(value).toFixed(decimalPlaces)
.replace('.', ',')
.replace(/\d(?=(\d{3})+,)/g, '$&.')
return (symbol) ? `R$ ${formatedValue}` : formatedValue
}
const { DateTime } = require('luxon')
function eachDays(d1, d2, response = 'DateTime') {
let parse = (date) => {
switch(date.constructor) {
case Date:
return DateTime.fromJSDate(date).startOf('day')
case String:
return DateTime.fromSQL(date).startOf('day')
function toMoney(value) {
value += '';
x = value.split('.');
x1 = x[0];
x2 = '';
if (x.length > 1 ) {
if (x[1].length < 2) {
x[1] = x[1]+'0';
} else {
const ms = require('ms');
const c = require('colors');
class Debugger {
debug(description) {
let prevTime = this.prevTime;
let curr = +new Date();
let milliseconds = curr - (prevTime || curr);
{
"apps": [
{
"name": "server",
"script": "/app/node-server/server.js",
"exec_mode" : "cluster",
"instances" : 3,
"watch": ["./"],
"ignore_watch": ["node_modules", "./websocket.js", ".git"]
},
FROM node:carbon
RUN groupadd -r docker && usermod -aG docker node
RUN chown -R node:docker /usr/local/lib/node_modules
RUN chown -R node:docker /usr/local/bin
RUN npm install --quiet -g pm2
WORKDIR /ai/esta
@jonathanborges
jonathanborges / config.toml
Created February 6, 2018 17:03
Gitlab Runner Config
[[runners]]
name = "rdponline-docker"
url = "https://gitlab.com/"
token = "152d782cda979eff7b7f30ee4ce67d"
executor = "docker"
builds_dir = "/apptest/builds"
[runners.docker]
tls_verify = false
image = "node:carbon"
privileged = false
const callbackFunc = (name, callback) => {
setTimeout(() => {
return callback(name + '123');
}, 3000);
}
const qCallbackFunc = (name) => {
return new Promise((resolve, reject) => {
callbackFunc(name, (result) => {
console.log(result);
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial main restricted
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial universe
deb-src http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial universe
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-updates universe
deb-src http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-updates universe
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial multiverse
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-updates multiverse
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-backports main restricted universe multiverse
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-security main restricted
deb http://ubuntu.c3sl.ufpr.br/ubuntu/ xenial-security universe