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

Sete Atitudes para Hackear a Indústria de Software

By Klaus Wuestefeld

1) Torne-se excelente.

Seja realmente bom em alguma coisa. Não fique só choramingando ou querendo progredir às custas dos outros. Não pense q pq vc sentou 4 anos numa faculdade ouvindo um professor falar sobre software q vc sabe alguma coisa. Jogador de futebol não aprende a jogar bola tendo

@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
// 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: {
from functools import wraps
from flask import Flask, request, Response
app = Flask(__name__)
def check_auth(username, password):
"""This function is called to check if a username /
password combination is valid.
"""
return username == 'username' and password == 'pass'
# coding: utf-8
from weasyprint import HTML, CSS
from weasyprint.document import _prepare
def get_page_body(boxes):
for box in boxes:
if box.element_tag == 'body':
return box
from webclient import *
server = "http://myaccount.erpnext.com/server.py"
user = "your user name"
password = "your password"
login()
customer = get_doc("Customer", customer_name)
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from StringIO import StringIO
font = ImageFont.load_default()
input = StringIO(self.request.get("img"))
img = Image.open(input)
draw = ImageDraw.Draw(img)
from PIL import Image
def get_white_noise_image(width, height):
pil_map = Image.new("RGBA", (width, height), 255)
random_grid = map(lambda x: (
int(random.random() * 256),
int(random.random() * 256),
int(random.random() * 256)
), [0] * width * height)
pil_map.putdata(random_grid)