Skip to content

Instantly share code, notes, and snippets.

View allanbatista's full-sized avatar

Allan Batista allanbatista

View GitHub Profile
@allanbatista
allanbatista / dump.sh
Last active December 7, 2017 16:45
Fazer Dump de Indice do Elasticsearch
# https://github.com/taskrabbit/elasticsearch-dump
elasticdump \
--input=http://localhost:9200/index_name \
--output=product_action_results2.json \
--type=data \
--searchBody '{"query":{"query_string": { "query": "sale_system_name:Amazon AND type:error" }}}' \
--limit 1000
@allanbatista
allanbatista / docker-container-utils.sh
Last active December 1, 2017 16:10
Docker Container Utils
#!/bin/bash
# add user to group and log out.
# sudo usermod -a -G docker $USER
docker run -d --restart unless-stopped --name elasticsearch -p 9200:9200 elasticsearch:2.4.6
docker run -d --restart unless-stopped --name kibana -p 5601:5601 --link elasticsearch:elasticsearch kibana:4.6.6
docker run -d --restart unless-stopped --name mongo -p 27017:27017 mongo:3.4.9 --storageEngine mmapv1
docker run -d --restart unless-stopped --name redis -p 6379:6379 redis:4.0.1
docker run -p 3000 -e "DOCKER_HOST=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')" -e TZ=America/Recife -v /home/allanbatista/workspace/containers/skyhub/container:/root -it allanbatista/dev-skyhub:1 bash
@allanbatista
allanbatista / default_template
Last active August 17, 2021 00:28
Criação de Templates no elasticsearch
# POST http://localhost:9200/_template/default_template
{
"template": "*",
"mappings": {
"dynamic_templates": [
{
"timestamp": {
"match": "*_at",
"mapping": {
@allanbatista
allanbatista / default
Created December 18, 2016 19:18
Puma + nginx for rails
# /etc/nginx/sites-enabled/default
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:///var/www/html/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
youtube-dl https://www.youtube.com/playlist?list=PLxEB_CPQhRLtdVGHhYS8mSUuz3kWP6kkB --yes-playlist -v --print-traffic -f bestvideo[ext!=webm]‌​+bestaudio[ext!=webm]‌​/best[ext!=webm]
@allanbatista
allanbatista / gist:c60aa58b4f3b8bf9f620a77c2ed5580f
Created August 19, 2016 12:56
Create nginx path basic authentication
sudo apt-get install apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd sidekiq
senha
sudo vim /etc/nginx/sites-enabled/default
# put this inside server
location /admin/sidekiq {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
sudo service nginx restart
@allanbatista
allanbatista / 0_reuse_code.js
Created August 5, 2016 16:49
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@allanbatista
allanbatista / request_timeout_log.rb
Created July 4, 2016 18:15
Rails MIddleware to track Request Timeout
## app/middleware/request_timeout_log.rb
#
## config/application.rb
# add middleware to cout request time and log them
# config.middleware.use 'RequestTimeoutLog'
#
# http://thread.gmane.org/gmane.comp.lang.ruby.unicorn.general/1265/focus=1269
#
# class RequestTimeoutLog < Struct.new(:app)
# def call(env)
@allanbatista
allanbatista / 00.howto_install_phantomjs.md
Last active March 15, 2016 14:47 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu/Debian

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@allanbatista
allanbatista / mongod.service
Last active March 14, 2016 18:48 — forked from benileo/mongod.service
Systemd Service Script for Mongod On Ubuntu 15.04+
##
# UpStart mongod
# /lib/systemd/system/mongod.service
# sudo systemctl enable mongod.service
# sudo systemctl start mongod.service
[Unit]
Description=High-performance, schema-free document-oriented database
Documentation=man:mongod(1)
After=network.target