Skip to content

Instantly share code, notes, and snippets.

View OtavioBraga's full-sized avatar

Otavio Braga OtavioBraga

View GitHub Profile
@OtavioBraga
OtavioBraga / app.py
Last active May 10, 2017 18:12
Basic flask hello world
from flask import Flask
meu_web_app = Flask('meu_web_app')
@meu_web_app.route('/')
def pagina_inicial():
return "ok"
@OtavioBraga
OtavioBraga / script.sh
Created May 10, 2017 19:31
Virtualenv instalattion with python3
sudo apt install python3-pip python-dev build-essential
sudo pip3 install virtualenv virtualenvwrapper
@OtavioBraga
OtavioBraga / script.sh
Created May 10, 2017 19:37
Virtualenv wrapper .bashrc
# virtualenvwrapper
# Diretório onde os ambientes virtuais serão armazenados
export WORKON_HOME=$HOME/.virtualenvs
# Adicionamos os comandos virtualenvwrapper no bash
source ~/.local/bin/virtualenvwrapper.sh
@OtavioBraga
OtavioBraga / script.sh
Created May 10, 2017 19:44
Edit .bashrc
sudo nano ~/.bashrc
@OtavioBraga
OtavioBraga / script.sh
Last active May 10, 2017 19:56
Update .bashrc
source ~/.bashrc
mkdir -p $WORKON_HOME
# Se estiver usando o zsh
# source ~/.zshrc
@OtavioBraga
OtavioBraga / script.sh
Last active May 11, 2017 14:02
Create a new venv with virtualenvwrapper
# Cria um venv com uma versão específica do python
mkvirtualenv flask --python=python3
# Cria um venv com um módulo pré-instalado
mkvirtualenv flask --python=python3 -i flask
# Remove um venv
mkvirtualenv flask
@OtavioBraga
OtavioBraga / script.sh
Created May 12, 2017 20:37
Remove old docker installations
sudo apt-get remove docker docker-engine
@OtavioBraga
OtavioBraga / script.sh
Created May 12, 2017 20:44
Install linux-image-extra
sudo apt-get update
sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
import smtplib
smtp_server = smtplib.SMTP('smtp.gmail.com', 587)
smtp_server.ehlo()
smtp_server.starttls()
smtp_server.login('[email protected]', '<App Password>')
smtp_server.sendmail('[email protected]', '[email protected]', 'Subject: Happy Australia Day!\nHi Everyone! Happy Australia Day! Cheers, Julian')
smtp_server.quit()
@OtavioBraga
OtavioBraga / axios_interceptor.js
Created March 28, 2018 16:54
Axios interceptor to add Bearer header and jwt refresh validation
axios.interceptors.request.use(async (config) => {
if (
!config.url.endsWith('login') ||
!config.url.endsWith('refresh') ||
!config.url.endsWith('signup')
) {
const userTokenExpiration = new Date(await AsyncStorage.getItem('userTokenExpiration'));
const today = new Date();
if (today > userTokenExpiration) {
// refresh the token here