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
@JuniorPolegato
JuniorPolegato / calcular_formula.py
Last active May 29, 2020 02:46
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
@BertrandBordage
BertrandBordage / paradox.py
Last active October 6, 2023 10:39
Python Paradox database reader
# coding: utf-8
"""
Converts Paradox databases to Python objects or CSV.
You don't need any dependency (except Python) to make this module work.
This module is incomplete but reads most Paradox `.DB` files.
If this module is not fast or complete enough for you, consider using pxview.
"""
@aliles
aliles / context.py
Created February 17, 2014 11:20
Class switching context object to prevent applications for assigning to protected properties. Uses class swizzling.
"Program execution context"
import warnings
class SwizzleContext(object):
"""Type switching context object base class
Supports the context manager protocol to switch the instance from a
MutableContext to the protected Context.
"""

Sample service script for debianoids

Look at LSB init scripts for more information.

Usage

Copy to /etc/init.d:

# replace "$YOUR_SERVICE_NAME" with your service's name (whenever it's not enough obvious)
@mknln
mknln / gist:7444512
Created November 13, 2013 06:11
Reading JavaScript Patterns I thought of another way to write the decorator pattern. Not yet sure if this has any pitfalls.
SalesOrder.prototype.decorate = function(decorator) {
var override
for (override in decorator) {
if (decorator.hasOwnProperty(override)) {
var oldfunc = this[override]
var decfunc = decorator[override]
var newfunc = function() {
var args = Array.prototype.slice.call(arguments)
@livibetter
livibetter / README.md
Last active February 12, 2020 20:48
Tkinter (Tk/Ttk) Progressbar widget example
@jumbojet
jumbojet / DE.py
Created September 18, 2013 17:18
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")
@pikhovkin
pikhovkin / weasyprint_complex_headers.py
Last active February 3, 2024 17:04
Repeat on each page of complex headers (eg, tables) except the first page
# coding: utf-8
from weasyprint import HTML, CSS
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)
@MaxMorais
MaxMorais / maskedentry.py
Last active October 24, 2023 12:06
Masked Entry Widget for TkinterFormWidget for Tkinter - Like web2py FormWidget, with label, entry and tooltipTo future, ensure validation.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#-------------------------------------------------------------------------------
# Name: maskedit.py
# Purpose:
#
# Author: Maxwell Morais (max.morais.dmm@gmail.com)
#
# Created: 10/04/2013