Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Maxwell Morais MaxMorais

🏠
Working from home
View GitHub Profile
View ler-text.py
from collections import namedtuple
Linha = namedtuple('Linha', ('DAtras'))
novo_conteudo = []
with open('./meu-arquivo.txt') as f:
conteudo = f.readlines()
inicio_encontrado = False
View Maiusculo.py
class Maiusculo(object):
""""Classe que converte qualquer coisa, para texto em maiúsculo"""
def __init__(self, valor):
"""__init__ é o inicializador da instância da classe, é ele que associa
os atributos da instância da classe com os argumentos recebidos"""
   
# Definimos um atributo chamado valor no contexto (self), e convertemos o "valor" do argumento valor
# para uma str em maiúscula (upper)
self.valor = str(valor).upper()
View config.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
BeansBooks
Copyright (C) System76, Inc.
This file is part of BeansBooks.
BeansBooks is free software; you can redistribute it and/or modify
it under the terms of the BeansBooks Public License.
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
View Py Nosso.md

Py nosso

Py nosso, escrito em C

De tipo fortificado seja o vosso __name__

__import__(a nós, o array);

E seja feito assim, todo dict entre {chaves}

View Serial History Timeline.sql
SELECT DISTINCT
SUBSTRING_INDEX(SUBSTRING_INDEX(x.`Serial No:Link/Serial No:150`, '\n', n.i + 1), '\n', -1) as "Serial No:Link/Serial No:150",
x.`DocType:Data:100` as "DocType:Data:100",
x.`DocName:Dynamic Link/DocType:100` as "DocName:Dynamic Link/DocType:100",
x.`Date:Date:75` as "Date:Date:75",
x.`Item Group:Link/Item Group:150` as "Item Group:Link/Item Group:150",
x.`Item:Link/Item:150` as "Item:Link/Item:150",
x.`Item Name:Data:250` as "Item Name:Data:250",
x.`Packed Into:Link/Item:150` as "Packed Into:Link/Item:150",
x.`Stock UOM:Link/UOM:75` as "Stock UOM:Link/UOM:75",
@MaxMorais
MaxMorais / calcular_formula.py
Created Apr 17, 2019 — forked from JuniorPolegato/calcular_formula.py
Exemplo de script para se calcular qualquer fórmula, exemplo com juros compostos
View calcular_formula.py
#!/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
View DocPerm.json
[
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"docstatus": 0,
"doctype": "Custom DocPerm",
"email": 1,
"export": 0,
View sugared_document.py
import frappe
from frappe.model.document import Document
from frappe.utils.nestedset import NestedSet
from six import string_types
from frappe.utils import getdate, nowdate
status_map = {}
class SugaredDocument(Document):
View printnode_on_reports.js
frappe.views.ReportView = frappe.views.ReportView.extend({
setup_print: function(){
this._super();
var me = this;
this.page.add_menu_item(__("Print via Print Node"), function(){
frappe.msgprint("Printing via Print Node");
}, true);
}
});