Skip to content

Instantly share code, notes, and snippets.

View ricardochaves's full-sized avatar

Ricardo Baltazar Chaves ricardochaves

View GitHub Profile
from string import Template
class MyOtherTemplate(Template):
delimiter = "#"
data = dict(id = 1, name = "Ricardo")
t = MyOtherTemplate("My name is #name and I have the id: #id")
print(t.substitute(data))
@ricardochaves
ricardochaves / Dockerfile
Created June 1, 2017 01:40
ricardobchaves6/myubuntu16-10
FROM ubuntu:16.10
MAINTAINER Ricardo Baltazar Chaves <ricardobchaves6@gmail.com>
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get install -y python3.6 python-pip
#https://hub.docker.com/r/ricardobchaves6/myubuntu16-10/
@ricardochaves
ricardochaves / exemple_integration_test.py
Last active July 22, 2018 00:11
exemple_integration_test
expected_result = {
"name": "Ricardo",
"image": "https://www.ricardobaltazar.com/static/principal/images/profilepic-new.jpg",
"age": 37,
"birth_date": "1981-06-21T12:42:31+00:32"
}
result = client.get("/user/info")
self.assertDictEqual(result.json, expected_result)
from jsonschema import validate
from jsonschema import FormatChecker
data = {
"name": "Ricardo",
"image": "https://www.ricardobaltazar.com/static/principal/images/profilepic-new.jpg",
"age": 37,
"birth_date": "1981-06-21T12:42:31+00:32"
}
@ricardochaves
ricardochaves / simple_schema.json
Created July 22, 2018 00:45
Simple json schema
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [ "name" ]
}
@ricardochaves
ricardochaves / app.py
Created August 22, 2018 22:16
API flask
from flask import Flask
from flask import jsonify
from time import sleep
from datetime import datetime
app = Flask(__name__)
@app.route("/")
def hello():
@ricardochaves
ricardochaves / docker-compose.yml
Created August 22, 2018 22:45
nginx and flask api
version: "3.5"
services:
nginx1:
image: nginx:1.13.3
volumes:
- ./nginx/local.nginx.conf:/etc/nginx/nginx.conf
depends_on:
- api
links:
- api:api
dist: trusty
sudo: false
cache:
directories:
- "$HOME/google-cloud-sdk/"
services:
- docker
#!/bin/bash
set -e
docker build -t gcr.io/${PROJECT_DEV}/${IMAGE_NAME}:$TRAVIS_COMMIT .
echo $GCLOUD_SERVICE_KEY_DEV | base64 --decode -i > ${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
gcloud --quiet config set project $PROJECT_DEV
@app.route("/login")
def login():
auth_state = str(uuid.uuid4())
flask.session["state"] = auth_state
authorization_url = TEMPLATE_AUTHZ_URL.format(
config.TENANT, config.CLIENT_ID, REDIRECT_URI, auth_state, config.RESOURCE
)
resp = flask.Response(status=307)
resp.headers["location"] = authorization_url
return resp