Skip to content

Instantly share code, notes, and snippets.

View danbailo's full-sized avatar
🏠
Working from home

Daniel Bailo danbailo

🏠
Working from home
View GitHub Profile
@danbailo
danbailo / main.py
Last active February 17, 2024 16:25
Encrypt/decrypt CryptoJS in Python 3.11
#
# Encryption with AES-CBC
#
# Python 3.11.3
# pkcs7==0.1.0
# pycryptodome==3.20.0
# Adapted from https://gist.github.com/adrianlzt/d5c9657e205b57f687f528a5ac59fe0e
import binascii
import struct
@danbailo
danbailo / gist:42aa9a22882e93fa8c8f647e1b677889
Created April 21, 2023 20:06
Init EC2 instance with docker/docker compose
# 1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg
# 2. Add Docker’s official GPG key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
@danbailo
danbailo / selenium_proxy_auth.py
Created October 19, 2022 13:20
Setting a proxy selenium(docker) with auth
from selenium.webdriver import Remote, ChromeOptions
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import zipfile
PROXY_HOST = '192.168.3.2' # rotating proxy or host
PROXY_PORT = 8080 # port
PROXY_USER = 'proxy-user' # username
PROXY_PASS = 'proxy-password' # password
@danbailo
danbailo / example_decorator_iterator.py
Created July 10, 2022 14:36
Simple decorator with iterators usage.
def is_admin(func):
def wrapper(*args, **kwargs):
for item in args:
if item['is_admin']:
yield item
return wrapper
@is_admin
def foo(user):

Descrição do que motivou a fazer o commit.

  • fix - Indica que o código commitado está solucionando um problema.
  • hotfix - Indica que teve uma modificação rápida e o código commitado está solucionando um problema (Ex. Mudança de usuário para login, proxy...).
  • feat- Indica que o código está incluindo um novo recurso.
  • refactor - Indica que teve mudanças devido a refatoração, mas que não alterou a sua funcionalidade.
  • build - Indica que teve modificações em arquivos de build e dependências.
  • test - Indica quando são realizadas alterações em testes, seja criando, alterando ou excluindo testes unitários. (Não inclui alterações em código)
  • chore - Indica atualizações de tarefas de build, configurações de administrador, pacotes... como por exemplo adicionar um pacote no gitignore. (Não inclui alterações em código)
  • docs - Indica que houveram mudanças/adição na documentação, como por exemplo no Readme do seu repositório. (Não inclui alterações em código).
@danbailo
danbailo / README.md
Last active November 17, 2022 17:26
Deploying Flask APP with gunicorn + nginx + supervisor

Tutorial to deploy Flask application to AWS (Free) / Tested in 2022 | Working! (Ubuntu 22.04)

Can works fine in others clouds, but I've test only in AWS.

Tested in EC2, Ubuntu 18.04

Sending project to your server

scp -i "{your_key.pem}" -r {project_folder} {your_user}@{your_public_server_ip}:~/

Connecting in your server

@danbailo
danbailo / scraper.py
Created June 4, 2020 16:35
Get info about the `https://github.com/{user}` pinned items of GitHub.
import json
import re
from bs4 import BeautifulSoup
import requests
def get_pinned_items(url):
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
@danbailo
danbailo / settings.json
Created May 30, 2020 19:18
VSCode settings
{
"workbench.colorTheme": "Monokai",
"window.zoomLevel": 0,
"editor.insertSpaces": true,
"editor.tabSize": 4,
"explorer.confirmDelete": false,
"workbench.startupEditor": "newUntitledFile",
"latex-workshop.view.pdf.viewer": "external",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,