Skip to content

Instantly share code, notes, and snippets.

View pedro108's full-sized avatar

Pedro Henrique Pereira de Jesus pedro108

  • London, United Kingdom
View GitHub Profile
@pedro108
pedro108 / deploy.rb
Last active December 11, 2015 03:39 — forked from bkutil/deploy.rb
Script para rodar restart de processos Resque via Capistrano
after "deploy:create_symlink", "resque:restart_workers"
after "resque:restart_workers", "resque:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@pedro108
pedro108 / solr_cap.rb
Last active December 22, 2015 09:18 — forked from doitian/solr_cap.rb
namespace :deploy do
task :setup_solr, roles: :app do
run "mkdir -p #{shared_path}/solr/data"
put File.read('config/sunspot.yml'), "#{shared_path}/config/sunspot.yml"
end
end
namespace :solr do
def solr_config
/* Foca no código!
.---.
/o o\
__(= " =)__
//\'-=-'/\\
) (_
/ `"=-._
/ \ ``"=.
@pedro108
pedro108 / blowfish.rb
Last active May 27, 2020 02:04 — forked from nono/blowfish.rb
Ruby class to use the Blowfish encryption / decryption algorithm in a Rails environment. Based on https://gist.github.com/nono/2995118
#!/usr/bin/env ruby
require 'openssl'
class Blowfish
def self.key
Rails.application.secrets.secret_key_base
end
def self.encrypt(decrypted_string, salt=nil)
@pedro108
pedro108 / nginx.conf
Created June 26, 2015 13:57 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@pedro108
pedro108 / bundle_exec.sh
Created March 2, 2016 14:11
Runs RVM startup script, and execute a bundle exec task for Monit
#!/bin/bash
export rvm_path=/home/ubuntu/.rvm;
. $rvm_path/scripts/rvm;
eval "su - ubuntu -c 'cd #{absolute_path_to_rails_app_root}; RAILS_ENV=production bundle exec $@'"
password="#{database_password}"
database_name="#{database_name}"
file_name=Dump_${database_name}_$(date +%d%m%Y_%H%M)
mkdir -p ~/backups && cd ~/backups
mysqldump -u root -p$password $database_name > $file_name.sql
tar czfv $file_name.tar.gz $file_name.sql
rm $file_name.sql
upstream unicorn {
server unix:#{path_to_rails_app_current_root}/tmp/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server #{application.domain.name};
keepalive_timeout 300;
client_max_body_size 4G;
@pedro108
pedro108 / monit_configs.conf
Last active March 2, 2016 18:45
Config files for Monit, specifically for Rails Applications using MySQL
httpd.monitrc
set httpd port 2815 and
allow #{client_ip}
allow admin:#{password}
mail.monitrc
set mailserver smtp.gmail.com port 587 username "#{smtp_user}" password "#{smtp_passw}" using tlsv1
@pedro108
pedro108 / medium_monitrc
Last active June 16, 2016 21:16
Snippet de código para o artigo "Como instalar e configurar o Monit para gerenciar os processos de sua aplicação Web em produção."
##
# Regra para inicializar o Monit como um daemon (processo background), e o tempo em segundos, de um ciclo de monitoramento.
#
set daemon 60 # check services at 1-minute intervals
##
# Regra para definir o caminho do arquivo de log do monit
#
set logfile /var/log/monit.log