Skip to content

Instantly share code, notes, and snippets.

View MaxMorais's full-sized avatar
🏢
Building TechMax Soluções

Maxwell Morais MaxMorais

🏢
Building TechMax Soluções
View GitHub Profile
@MaxMorais
MaxMorais / calcular_formula.py
Created April 17, 2019 12:58 — forked from JuniorPolegato/calcular_formula.py
Exemplo de script para se calcular qualquer fórmula, exemplo com juros compostos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math
import re
# dado um título e lista de listas no formato
# ('<variável>', '<tipo>', '<descricao>', '<fórmula>')
# pede-se qual variável calcular, pede os valores e dá o resultado
# qualquer valor vazio saida da função

OAuth 2 Authorization Code Flow For Use With Google Actions

This flow provides a "fake" OAuth 2 implementation for use with the Google Actions API.

Exposes three endpoints:

  1. /google/oauth-auth - Main auth endpoint that Google will call to initialize an OAuth 2 handshake. Checks "client" and "client secret", and returns a login form.
  2. /google/oauth-login - Processes login form, verifies "auth key" provided and generates a new OAuth auth code that the caller (Google) can then exchange for a real OAuth 2 ticket via the last endpoint.
  3. /google/oauth-token - Allows the caller to exchange an "auth key" for a valid OAuth 2 token, or request a new token via refresh token.
@MaxMorais
MaxMorais / salary_structure_report.py
Last active March 3, 2017 13:14
Report for Salary Structure for ERPNext which would EVAL the formula based Salary as well.
# Copyright (c) 2013, Rohit Industries Ltd. and contributors
# For license information, please see license.txt
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import frappe
from frappe import msgprint, _
from frappe.utils import flt, cstr
from erpnext.hr.doctype.salary_slip.salary_slip import SalarySlip
@MaxMorais
MaxMorais / flatten_wsdl.py
Created October 29, 2015 16:00 — forked from pavelpatrin/flatten_wsdl.py
Нерабочий вариант функции для схлопывания wsdl-схем
def _get_flatten_wsdl(self, url):
"""
Выполняет загрузку wsdl-схемы и зависимых файлов и объединяет их
в единый файл.
Ускоряет загрузку wsdl-схемы для клиента.
TODO: реализовать.
:type url: unicode
@MaxMorais
MaxMorais / gist:a066b2350ed2f7c28c2b
Created October 3, 2015 04:16 — forked from nanonyme/gist:6268358
brainstorming on suds + python-requests thinamabob, MIT-licensed
from suds.transport import Transport, Reply
from suds.client import Client
import requests
from StringIO import StringIO
class RequestsTransport(Transport):
def open(self, request):
""" suds assumes urllib2 which doesn't have keepalives so things can go royally wrong if it doesn't
read the entire request. Hence, read it all up and give a StringIO object instead.
@MaxMorais
MaxMorais / DE.py
Last active August 29, 2015 14:26 — forked from jumbojet/DE.py
Dynamic Expression Parsing
''' expressionString = IF Variable_3 > 1000 RETURN VARIABLE_3* VARIABLE_1 END IF Variable_3 < 1000 RETURN VARIABLE_3* VARIABLE_2 END '''
def parse_expression(expressionString):
expressionStringArray = filter(None,expressionString.split("END"))
''' expressionStringArray[0] = IF Variable_3 > 1000 RETURN VARIABLE_3* VARIABLE_1
expressionStringArray[1] = IF Variable_3 < 1000 RETURN VARIABLE_3* VARIABLE_2 '''
for expression in expressionStringArray:
expConditionResult = expression.strip().split("RETURN")
// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
var colorbrewer = {YlGn: {
3: ["#f7fcb9","#addd8e","#31a354"],
4: ["#ffffcc","#c2e699","#78c679","#238443"],
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
},YlGnBu: {
{%- macro add_header(page_num, max_pages, doc) -%}
{%- if doc.meta.is_submittable and doc.docstatus==2-%}
<div class="alert alert-danger text-center">
<h4 style="margin: 0px;">{{ _("CANCELLED") }}</h4></div>
{%- endif -%}
{% if max_pages > 1 %}
<p class="text-right">{{ _("Page #{0} of {1}").format(page_num, max_pages) }}</p>
{% endif %}
{%- endmacro -%}
<style>
table.black {
background-color: #000 !important;
height: 1px;
width: 100%;
}
table.black > tr > td {
color: white;
def gera_boleto():
import datetime
import pyboleto
from pyboleto.bank.caixa import BoletoCaixa
from pyboleto.pdf import BoletoPDF
import os
listaDadosCaixa = []
for i in range(2):
d = BoletoCaixa()