Skip to content

Instantly share code, notes, and snippets.

View gustavohenrique's full-sized avatar

Gustavo Henrique gustavohenrique

View GitHub Profile
@gustavohenrique
gustavohenrique / k8s-lxd.md
Last active March 8, 2023 13:24
Configure kubernetes on LXD containers

Create LXD containers

cat > k8s-profile.yaml <<EOF
config:
  linux.kernel_modules: xt_conntrack,ip_tables,ip6_tables,netlink_diag,nf_nat,overlay
  raw.lxc: "lxc.apparmor.profile=unconfined\nlxc.cap.drop= \nlxc.cgroup.devices.allow=a\nlxc.mount.auto=proc:rw sys:rw\nlxc.mount.entry=/dev/kmsg dev/kmsg none defaults,bind,create=file"
  security.privileged: "true"
  security.nesting: "true"
EOF
@gustavohenrique
gustavohenrique / reverse-shell.md
Created December 17, 2019 16:45
Reverse shell Cheat Sheet

Mac:

sudo killall -HUP mDNSResponder; say dns cleared successfully

Linux:

sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/nscd restart

Run via Docker

docker run -d \
    -e POSTGRES_PASSWORD=mysecretpassword \
    -e POSTGRES_USER=root \
    -e POSTGRES_DB=mydb \
    -e PGDATA=/var/lib/postgresql/data/pgdata \
    -v ${HOME}/pgdata:/var/lib/postgresql/data \
    --name postgres \
@gustavohenrique
gustavohenrique / sendmail.go
Created June 20, 2022 15:18
Send mail using Go stdlib
package main
import (
"fmt"
"bytes"
"crypto/tls"
"encoding/base64"
"fmt"
"net/mail"
"net/smtp"
@gustavohenrique
gustavohenrique / gocache-magento2.md
Last active June 7, 2022 22:58
Estória para desenvolvimento do módulo do Magento 2

Cenário

Utilizamos a GoCache como CDN para fazer cache de arquivos estáticos (imagens, css e javascript) e conteúdo dinâmico, como nome, descrição e preço de um produto.

Todo o tráfego do usuário passa pela CDN antes de chegar no sistema Magento. Então a CDN faz cache do conteúdo e os usuários passam a obter a informação do site à partir do cache, não mais do Magento.

É comum que uma plataforma de ecommerce precise alterar imagens, descrição e preços dos produtos com frequência. Mesmo depois dessa alteração ser feita no Magento, os usuários continuam obtendo as informações desatualizadas do cache. Por isso, precisamos de um módulo no qual consiga limpar o cache da CDN sempre que alguma informação for alterada no Magento.

Solução

@gustavohenrique
gustavohenrique / kops-kubernetes.md
Created May 18, 2022 13:49
Kubernetes in AWS by Kops [2018]

Kubernetes na AWS

1. Criando o cluster com Kops

  1. Crie um grupo kops contendo as rules abaixo, crie também um usuário kops e adicione-o ao grupo:
AmazonEC2FullAccess
AmazonRoute53FullAccess
AmazonS3FullAccess
@gustavohenrique
gustavohenrique / Makefile
Created February 1, 2022 18:15
Auto documentation makefile
.DEFAULT_GOAL := help # Sets default action to be help
define PRINT_HELP_PYSCRIPT # start of Python section
import re, sys
output = []
# Loop through the lines in this file
for line in sys.stdin:
# if the line has a command and a comment start with
# two pound signs, add it to the output
@gustavohenrique
gustavohenrique / pre-sharedkey-aes.py
Created September 13, 2017 17:52
An example using Python3 and AES criptography
import sys
import base64
from Crypto.Cipher import AES
class AESCipher(object):
def __init__(self, key):
self.bs = 16
self.cipher = AES.new(key, AES.MODE_ECB)
@gustavohenrique
gustavohenrique / comodo-ssl.md
Created September 13, 2018 18:15
Configure comodo SSL

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

This gives you two files:

  • example_com.key -- your Private key. You'll need this later to configure ngxinx.