Skip to content

Instantly share code, notes, and snippets.

View phellipeandrade's full-sized avatar
🏡
Working from home

Phellipe Andrade phellipeandrade

🏡
Working from home
  • São Paulo - Brazil
View GitHub Profile
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
sudo kill $(sudo lsof -t -i:3000)
https://github.com/docker-library/kibana/issues/65
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
phellipeandrade / docker-cleanup-resources.md
Created December 20, 2017 13:35 — forked from bastman/docker-cleanup-resources.md
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: https://github.com/chadoe/docker-cleanup-volumes

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

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

@phellipeandrade
phellipeandrade / mongodb-s3-backup.sh
Created January 12, 2018 14:40 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` 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 backup.sh
# 7) Test it out via ./backup.sh
@phellipeandrade
phellipeandrade / repo-reset.md
Created February 6, 2018 14:58 — forked from heiswayi/repo-reset.md
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
phellipeandrade / async-foreach.js
Created February 25, 2018 04:35 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
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
phellipeandrade / ultimate-ut-cheat-sheet.md
Created February 27, 2018 04:34 — forked from yoavniran/ultimate-ut-cheat-sheet.md
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


@phellipeandrade
phellipeandrade / gist:895718ea5679532ac2195d687a6b1421
Created March 14, 2018 21:45 — forked from solenoid/gist:1372386
javascript ObjectId generator
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);
}).toLowerCase();
};
@phellipeandrade
phellipeandrade / install-rabbitmq.sh
Created June 18, 2018 18:58 — forked from yetanotherchris/install-rabbitmq.sh
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