Skip to content

Instantly share code, notes, and snippets.

View tacionery's full-sized avatar

Tácio Nery tacionery

View GitHub Profile
@tacionery
tacionery / rack_attack.rb
Created June 3, 2016 19:18
rack attack config
class Rack::Attack
# se um IP estiver fazendo uma série de requests, ele provavelmente
# é malicioso. então não vamos deixar ele derrubar nossa CPU
throttle('req/ip', limit: 300, period: 5.minutes) do |req|
req.ip
end
# o caso mais comum talvez seja o de forçar o login com uma série de
# logins e senhas até encontrar algum que bata
@tacionery
tacionery / nginx.conf
Created June 1, 2016 00:52
nginx config
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /home/deploy/.rbenv/shims/ruby; # If you use rbenv
@tacionery
tacionery / nginxinstall.sh
Last active June 1, 2016 00:49
nginx ubuntu
# o nginx precisa de um certificado para ser instalado,
# com esse comando adicionamos o certificado
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
# adiciona o repositório do passenger, necessário para
# rodar apps rails no nginx
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
@tacionery
tacionery / config - puma.rb
Last active May 30, 2016 21:58
puma config
# config/puma.rb
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 6)
workers Integer(ENV['WORKERS'] || 2)
port ENV['PORT'] || 3000
environment ENV['RAILS_ENV'] || 'development'
preload_app!
on_worker_boot do
@tacionery
tacionery / postgres_guide
Last active January 25, 2019 22:05
install postgresql on antergos
# uninstall postgresql if necessary
$ sudo pacman -R postgresql postgresql-libs
# remove postgres files
$ sudo rm -rfv /var/lib/postgres
# proceed with the installation
$ sudo pacman -S postgresql postgresql-libs
# setup password for postgres
$ sudo passwd postgres
@tacionery
tacionery / nginxtemplate.conf
Last active June 1, 2016 01:07
nginx template
server {
listen 80 default_server;
server_name IP_DO_SEU_VPS;
root /home/beer/beer_on_rails/public;
passenger_enabled on;
rails_env production;
# responsável por carregar os assets
location ^~ /assets/ {