Skip to content

Instantly share code, notes, and snippets.

View fboaventura's full-sized avatar
📚
Always learning

Frederico Freire Boaventura fboaventura

📚
Always learning
View GitHub Profile
@fboaventura
fboaventura / haproxy.cfg
Created May 5, 2017 12:56 — forked from tikenn/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@fboaventura
fboaventura / Postfix: sender-dependent SASL authentication.md
Created May 5, 2017 13:03 — forked from zmwangx/Postfix: sender-dependent SASL authentication.md
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)

This is a sequel to "Postfix: relay to authenticated SMTP".

I would like to send mail from two different Gmail accounts using Postfix. Here is the relevant section in the Postfix documentation: Configuring Sender-Dependent SASL authentication.

As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):

/etc/postfix/main.cf:
    # sender-dependent sasl authentication
    smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

@fboaventura
fboaventura / web-servers.md
Created October 27, 2017 17:12 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@fboaventura
fboaventura / argparse_with_custom_action.py
Created April 26, 2018 14:31 — forked from verbalhanglider/argparse_with_custom_action.py
A tutorial example of A CLI module using an argparse.Action class instance to find all files in a directory tree
"""a tutorial example of A CLI module using an argparse.Action class instance to find all files in a directory tree
"""
from argparse import Action, ArgumentParser
from sys import argv, stderr, stdout
from os import _exit, scandir
from os.path import exists, isdir
__VERSION__ = "1.0.0"
@fboaventura
fboaventura / fw_block.sh
Created May 24, 2018 10:29 — forked from toke/fw_block.sh
Simple spamhaus ipset firewall block
#!/usr/bin/bash
## Run every 24h via cron
## Old entries will time out later automatically
(
cd /var/lib/firewall
wget -qN 'http://www.spamhaus.org/drop/drop.txt'
ipset create -exist spamhaus_drop hash:net counters timeout 90000 comment
@fboaventura
fboaventura / py3whois.py
Created May 24, 2018 10:57 — forked from carmaa/py3whois.py
Python 3 whois client
"""
Whois client for python
transliteration of:
http://www.opensource.apple.com/source/adv_cmds/adv_cmds-138.1/whois/whois.c
Copyright (c) 2010 Chris Wolf
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@fboaventura
fboaventura / mozlz4a.py
Created June 29, 2018 12:30 — forked from Tblue/mozlz4a.py
MozLz4a compression/decompression utility
#!/usr/bin/env python
#
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
#
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and
# uncompressed file size [4 bytes, little endian]).
#
# This Python 3 script requires the LZ4 bindings for Python, see: https://pypi.python.org/pypi/lz4
#
@fboaventura
fboaventura / nginx.conf
Created July 18, 2018 20:26 — forked from somebox/nginx.conf
Nginx error page handling
# The following recipe works with upstream rails proxy for custom 404s and 500s.
# Errors are usually handled via rails except if proxy is really down, in which case
# nginx needs a bit more configration.
server {
# ...
location / {
error_page 404 = @rails; # let rails show a page with suggestions
try_files maintenance.html @rails;
@fboaventura
fboaventura / sysctl.conf
Created January 24, 2019 21:48 — forked from techgaun/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@fboaventura
fboaventura / flat_to_mongo.py
Created February 4, 2019 23:32 — forked from gartenfeld/flat_to_mongo.py
Import data from a flat file into MongoDB.
import sys
import re
import codecs # UniCode support
from pymongo import Connection # For DB Connection
from pymongo.errors import ConnectionFailure # For catching exeptions
def main():
# MongoDB connection
try: