This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a custom network | |
# sudo docker network create --driver bridge mynetwork | |
# Start mongodb | |
# sudo docker run -d --net=mynetwork --name mymongo -v /data/db:/data/db mongo | |
# Command to run the source as a container | |
# sudo docker run --net=mynetwork --name app -d -p 8080:3000 -v (pwd):/var/www -w '/var/www' node npm start | |
version: '3.5' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using mongodb with Persist data into a docker container | |
sudo docker pull mongo | |
sudo docker run -d --name MyMongo -v /data/db:/data/db mongo | |
sudo docker exec -it MyMongo /bin/bash | |
# Running in a custom network | |
sudo docker pull mongo | |
sudo docker network create --driver bridge MyNetwork | |
sudo docker run -d --net=MyNetwork --name MyMongo -v /data/db:/data/db mongo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function randomHash(numberOfChars) { | |
numberOfChars = Math.min(Number(numberOfChars) || 1, 10); | |
return Math.random().toString(36).slice(-numberOfChars); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeAccent(text) { | |
/* | |
Octal representation of letters | |
Execute the above code at browser console to show octal number of the chars | |
for(var i = 300; i < 380; i += 1, console.log(i + ' - ', String.fromCharCode(parseInt(i, 8)))) {} | |
*/ | |
var accent = [ | |
/[\300-\306]/g, /[\340-\346]/g, // A, a | |
/[\310-\313]/g, /[\350-\353]/g, // E, e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function atom-url; | |
curl -s https://api.github.com/repos/atom/atom/releases/latest | awk '/browser_download_url.*deb/ { print $2 }' | sed 's/"//g' | |
end; | |
function atom-download; | |
curl -LOk (atom-url) | |
end; | |
function atom-install; | |
sudo dpkg -i ./atom-amd64.deb | |
end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toRegExp(text) { | |
var flags; | |
var reg; | |
text = typeof text === 'string' ? text : ''; | |
flags = text.replace(/.*\/([igmy]*)$/, '$1'); | |
reg = text.replace(/^\/(.*)\/[igmy]*$/, '$1'); | |
return new RegExp(reg, flags); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'.source.js': | |
'React class': | |
'prefix': 'rclass' | |
'body': """ | |
import React, { Component } from 'react'; | |
class ${1:ClassName} extends Component { | |
constructor(props) { | |
super(props); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function brazilianCurrency(money, decimalEmbeded) { | |
var decimalPart; | |
if (decimalEmbeded) { // example R$72,35 is 7235 | |
money = String(money); | |
money = 'R$ ' + Number(money.slice(0, -2)).toLocaleString().replace(/,/g, '.') + ',' + money.slice(-2); | |
} else { | |
money = 'R$ ' + Number(money).toLocaleString().replace(/,/g, ';').replace(/\./g, ',').replace(/;/g, '.'); | |
if (money.search(',') >= 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function textToSlug(text) { | |
var i; | |
var reg; | |
var from = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŕŕ'; | |
var to = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyybyrr'; | |
if (typeof text !== 'string') { | |
return new TypeError('The parameter must be string'); | |
} | |
text = text.toLowerCase().trim().replace(/\s+/g, '-').replace(/\-{2,}/g, '-'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isEmail(email) { | |
if (typeof email !== 'string') { | |
return false; | |
} | |
return email.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/) ? true : false; | |
} |