Skip to content

Instantly share code, notes, and snippets.

Gustavo Henrique gustavohenrique

Block or report user

Report or block gustavohenrique

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lambdas-python.md

ImageResize

import boto3
import uuid


from PIL import Image

S3 = boto3.client("s3")
View dump-restore-postgres.md

Install psql 11

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee  /etc/apt/sources.list.d/postgres.list
sudo apt update
sudo apt -y install postgresql-client-11
View flush-dns.md

Mac:

sudo killall -HUP mDNSResponder; say dns cleared successfully

Linux:

sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/nscd restart
@gustavohenrique
gustavohenrique / parallel-python.py
Created Aug 13, 2019
Example using parallel in Python
View parallel-python.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
# https://github.com/uchidalab/book-dataset/blob/master/scripts/download_images.py
import os
import codecs
import pandas as pd
from argparse import ArgumentParser
from urllib import request
from tqdm import trange
from joblib import Parallel, delayed
View caddyfile-wildcard-certificate.md

Generate self signed wildcard certificate

cat <<EOF | tee certificate.cfg
[ req ]
req_extensions     = req_ext
distinguished_name = req_distinguished_name
prompt             = no

[req_distinguished_name]
@gustavohenrique
gustavohenrique / journalctl.md
Created May 27, 2019
journalctl cheat sheet
View journalctl.md

general

journalctl --utc
journalctl /usr/bin/bash
journalctl -k  # kernel messages
journalctl --no-full  # display some information
journalctl -a  # display all information
journalclt --no-pager  # good for scripts
journalctl -b -u nginx -o json-pretty
journalctl -n  # recent logs
View sendmail-via-aws-ses.md
package mail

import (
	"bytes"
	"crypto/tls"
	"fmt"
	"log"
	"mime/quotedprintable"
	"net/smtp"
@gustavohenrique
gustavohenrique / letsencrypt-dns-challenge-route53.sh
Last active Aug 12, 2019
Generate certificates using certbot + route53 plugin
View letsencrypt-dns-challenge-route53.sh
```
export AWS_PROFILE=myprofile
mkdir letsencrypt
pip install certbot-dns-route53
certbot certonly -d mydomain.com -d '*.mydomain.com' --dns-route53 --logs-dir ./letsencrypt/log/ --config-dir ./letsencrypt/config/ --work-dir ./letsencrypt/work/ -m gustavo.henrique@mydomain.com.br --agree-tos --non-interactive --server https://acme-v02.api.letsencrypt.org/directory
ls letsencrypt/config/archive/mydomain.com
# renew
certbot renew --cert-name mydomain.com --logs-dir ./letsencrypt/log/ --config-dir ./letsencrypt/config/ --work-dir ./letsencrypt/work/
```
@gustavohenrique
gustavohenrique / archlinux-installation.md
Last active Sep 26, 2019
Some steps to install Arch Linux
View archlinux-installation.md

Archlinux Installation

Installation options

  1. Installed with LVM on LUKS encryption, no dual boot.

  2. Using systemd-boot instead of GRUB on UEFI, as it's more lightweight.

Hardware Notes

You can’t perform that action at this time.