Skip to content

Instantly share code, notes, and snippets.

Working from home

Phellipe Andrade phellipeandrade

Working from home
  • São Paulo - Brazil
View GitHub Profile
View show_ip_ubuntu_linux.txt
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
View Docker_ElasticSearch_Kibana.txt
Correct, your host can access elasticsearch via localhost since you forwarded the ports with -p 9200:9200 -p 9300:9300, but kibana has its own network interface and localhost in the kibana container is just kibana, not your host.
You need to either give the ip of your elasticsearch container to kibana:
$ docker run -d -v "$PWD/esdata":/usr/share/elasticsearch/data -p 9200:9200 -p 9300:9300 --name elastic elasticsearch
$ ip="$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' elastic)"
$ docker run -e ELASTICSEARCH_URL="http://$ip:9200" -p 5601:5601 -d --name kib kibana
or use linking dns so that kibana can resolve a name to elasticsearch:
phellipeandrade /
Created Dec 20, 2017 — forked from bastman/
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see:

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

phellipeandrade /
Created Jan 12, 2018 — forked from eladnava/
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
# Make sure to:
# 1) Name this file `` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x
# 7) Test it out via ./
phellipeandrade /
Created Feb 6, 2018 — forked from heiswayi/
GitHub - Delete commits history with git commands

First Method

Deleting the .git folder may cause problems in our git repository. If we want to delete all of our commits history, but keep the code in its current state, try this:

# Check out to a temporary branch:
git checkout --orphan TEMP_BRANCH

# Add all the files:
git add -A
phellipeandrade / async-foreach.js
Created Feb 25, 2018 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
View async-foreach.js
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
phellipeandrade /
Created Feb 27, 2018 — forked from yoavniran/
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies

View gist:895718ea5679532ac2195d687a6b1421
var mongoObjectId = function () {
var timestamp = (new Date().getTime() / 1000 | 0).toString(16);
return timestamp + 'xxxxxxxxxxxxxxxx'.replace(/[x]/g, function() {
return (Math.random() * 16 | 0).toString(16);
phellipeandrade /
Created Jun 18, 2018 — forked from yetanotherchris/
RabbitMQ on Docker with admin UI
# AWS specific install of Docker
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# exit the SSH session, login again
# Docker
docker run -d --hostname my-rabbit --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq