Skip to content

Instantly share code, notes, and snippets.

View igorbpf's full-sized avatar

Igor Santos igorbpf

View GitHub Profile
@igorbpf
igorbpf / token_auth.py
Created December 14, 2018 05:11 — forked from rluts/token_auth.py
Token authorization middleware for Django Channels 2
from channels.auth import AuthMiddlewareStack
from rest_framework.authtoken.models import Token
from django.contrib.auth.models import AnonymousUser
from django.db import close_old_connections
class TokenAuthMiddleware:
"""
Token authorization middleware for Django Channels 2
"""
import functools
from channels.handler import AsgiRequest
from rest_framework.exceptions import AuthenticationFailed
from rest_framework.settings import api_settings
authenticators = [auth() for auth in api_settings.DEFAULT_AUTHENTICATION_CLASSES]
@igorbpf
igorbpf / boto_auth_requests.py
Created December 13, 2018 02:43 — forked from LegoStormtroopr/boto_auth_requests.py
Connecting Django/Haystack to AWS ElasticSearch using IAM rotating credentials
import boto3
import os
import requests
from botocore.auth import SigV4Auth
from requests_aws4auth import AWS4Auth
from elasticsearch import RequestsHttpConnection
class AWSRequestsHttpConnection(RequestsHttpConnection):
@igorbpf
igorbpf / build-tag-push.py
Created November 21, 2018 00:56 — forked from peatiscoding/build-tag-push.py
a script to convert your docker-compose.yml (version 2) with build node to image node; this script required DOCKERHUB_USER environment available.
#!/usr/bin/python
import os
import subprocess
import time
import yaml
import re
user_name = os.environ.get("DOCKERHUB_USER")
@igorbpf
igorbpf / .block
Created July 5, 2018 17:50 — forked from ruliana/.block
Brazilian States Topojson (Estados do Brasil)
license: mit
height: 600
@igorbpf
igorbpf / API.md
Created April 17, 2018 19:16 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.reset-element {
import React, { Component } from 'react';
import axios from 'axios';
class App extends Component {
state = {
coins: null,
stocks: null,
funds: null,
@igorbpf
igorbpf / app.py
Created July 20, 2017 16:42 — forked from maccman/app.py
Stripe Flask Example
import os
from flask import Flask, render_template, request
import stripe
stripe_keys = {
'secret_key': os.environ['SECRET_KEY'],
'publishable_key': os.environ['PUBLISHABLE_KEY']
}
stripe.api_key = stripe_keys['secret_key']
@igorbpf
igorbpf / app.py
Created June 17, 2017 06:39 — forked from imwilsonxu/app.py
Demo: Flask + Wtforms + Select2
# -*- coding: utf-8 -*-
from flask import Flask, request, render_template, current_app
from flask_wtf import Form
from wtforms.validators import DataRequired
from wtforms import SelectField, SelectMultipleField, SubmitField
app = Flask(__name__)