Skip to content

Instantly share code, notes, and snippets.

View megamvb's full-sized avatar

Marcos V Bohrer megamvb

View GitHub Profile
@megamvb
megamvb / SSH: Self Sign Postfix
Created October 24, 2024 12:59 — forked from volure/SSH: Self Sign Postfix
Create a Self Signed Postfix Certificate
# copied from https://www.e-rave.nl/create-a-self-signed-ssl-key-for-postfix
openssl genrsa -des3 -out mail.domain.tld.key 2048
chmod 600 mail.domain.tld.key
openssl req -new -key mail.domain.tld.key -out mail.domain.tld.csr
openssl x509 -req -days 365 -in mail.domain.tld.csr -signkey mail.domain.tld.key -out mail.domain.tld.crt
openssl rsa -in mail.domain.tld.key -out mail.domain.tld.key.nopass
mv mail.domain.tld.key.nopass mail.domain.tld.key
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650
chmod 600 mail.domain.tld.key
@megamvb
megamvb / SSL.md
Created May 26, 2022 13:02 — forked from gangsta/SSL.md
How to Setting Up a Comodo SSL Cert

How to Setting Up a Comodo SSL Cert

  • I advice you to buy SSL Certs from officially Comodo only , or some SSL reseller whose you trust.

These are the steps I went through to set up an SSL cert. Purchase the cert

Prior to purchasing a cert, you need to generate a private key, and a CSR file (Certificate Signing Request). You’ll be asked for the content of the CSR file when ordering the certificate:

openssl req -new -newkey rsa:2048 -nodes -keyout example_com.key -out example_com.csr
PING 10.25.207.243 (10.25.207.243): 32 bytes de dados
40 bytes de 10.25.207.243: icmp_seq=0 ttl=64 Hora=1.0 ms
40 bytes de 10.25.207.243: icmp_seq=1 ttl=64 Hora=0.7 ms
40 bytes de 10.25.207.243: icmp_seq=2 ttl=64 Hora=0.6 ms
40 bytes de 10.25.207.243: icmp_seq=3 ttl=64 Hora=0.6 ms
@megamvb
megamvb / gem-mysql2.sh
Last active January 3, 2022 12:40
Gem MySQL2 in Mac M1
bundle config --local build.mysql2 "--with-opt-dir="$(brew --prefix openssl) --with-ldflags=-L/opt/homebrew/Cellar/zstd/1.5.0/lib""
# https://stackoverflow.com/questions/67840691/ld-library-not-found-for-lzstd-while-bundle-install-for-mysql2-gem-ruby-on-mac
@megamvb
megamvb / nginx-tuning.md
Created January 21, 2021 12:51 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@megamvb
megamvb / gist:0b5bbb826f18aac2ef429bd64f8da1c3
Created November 9, 2017 15:35
find in files on FreeBSD
grep -Flr --include "*.txt" 'searchstring' /some/dir
@megamvb
megamvb / email_header_parser.rb
Created October 29, 2017 20:55 — forked from pmarreck/email_header_parser.rb
Superfast email header parser in Ruby, using regular expressions. This solution is 250 times faster than using the "Mail" gem. :O Time with my regex: 0.063965 seconds Time with Mail gem: 16.327161 seconds Note that I included some encoding-fix code. YMMV and encoding fixes are all debatable or fail in some corner case.
require 'ap'
require 'mail'
# String monkeypatch
# This is one of many possible "encoding problem" solutions. It's actually an intractable problem
# but you'd have to read "Gödel, Escher, Bach" to understand why...
class String
def clean_utf8
# self.force_encoding("UTF-8").encode("UTF-16BE", :invalid=>:replace, :replace=>"?").encode("UTF-8")
unpack('C*').pack('U*') if !valid_encoding?
@megamvb
megamvb / gist:b8a52e26e530b16b0421860059be9de9
Created October 7, 2017 19:45
sources.list - Ubuntu 16.04
------------------------------------------------------------------------------#
# OFFICIAL UBUNTU REPOS #
#------------------------------------------------------------------------------#
###### Ubuntu Main Repos
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiverse
###### Ubuntu Update Repos
@megamvb
megamvb / mysql.sh
Last active August 11, 2016 14:34
MySQL export and import commands
### exportar
$ mysqldump -u nome_do_usuario -p nome_do_banco > nome-temporario.sql
# (vai solicitar a senha do banco de dados a ser exportado)
### importar
$ mysql -u nome_do_usuario -p nome_do_banco_para_IMPORTACAO-do_backup < nome-temporario.sql
@megamvb
megamvb / rsync.sh
Created April 6, 2016 20:37
rsync restart after crash connection
$ rsync --partial --progress --rsh=ssh --bwlimit=15 SRC DEST