Skip to content

Instantly share code, notes, and snippets.

Avatar
🏡
Working from home

Phellipe Andrade phellipeandrade

🏡
Working from home
  • São Paulo - Brazil
View GitHub Profile
View Docker_ElasticSearch_Kibana.txt
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:
View show_ip_ubuntu_linux.txt
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
View comoNaoDeixarNoVaucoNoWhatsapp.js
/*
Hoje não deixaremos mais ninguém no vácuo no whatsapp
Para utilizar:
- Abra o web.whatsapp.com;
- Abra o console e cole o código que está no gist;
- Aguarde e verá uma mensagem sendo enviada a cada momento que alguém te enviar alguma mensagem.
Confira também como ser chato no whatsapp: https://gist.github.com/mathloureiro/4c74d60f051ed59650cc76d1da0d32da
View closest_number_of_array.js
// Based on: https://stackoverflow.com/questions/8584902/get-closest-number-out-of-array
const arr = [360, 375, 414, 768, 1024];
// ES6
const closest = (num, arr) => {
let curr = arr[0];
let diff = Math.abs(num - curr);
for (let i of arr) {
const newDiff = Math.abs(num - i);
@phellipeandrade
phellipeandrade / mongo_backup.sh
Created Sep 1, 2017 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
View mongo_backup.sh
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
@phellipeandrade
phellipeandrade / nginxproxy.md
Created May 30, 2017 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?
View nginxproxy.md

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

View remote-branches-to-folder.sh
#!/bin/bash
# Fetch the latest branches
git fetch
# Get the repository path
repoPath=$(git config --get remote.origin.url)
dir=$(pwd)
# Loop through each branch
@phellipeandrade
phellipeandrade / mongodb_drop_all_databases.txt
Last active Jan 22, 2017
MongoDB drop ALL databases - console
View mongodb_drop_all_databases.txt
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})'
View probability_AB.js
//The sum of 'weights' elements should be equal 1.
let weights = [0.1, 0.9]; // probabilities
//The possible results
let results = [0, 1]; // values to return
function getRandom () {
let num = Math.random(),
s = 0,
lastIndex = weights.length - 1;