This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module test; | |
| import std.stdio; | |
| import std.traits; | |
| class A {} | |
| class B : A { } | |
| void main() { | |
| alias Bases = BaseClassesTuple!B; | |
| writeln(Bases.stringof); /* prints "(A, Object)" */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def hide_email(email): | |
| m = email.split('@') | |
| return f'{m[0][0]}{"*"*(len(m[0])-2)}{m[0][-1]}@{m[1]}' | |
| # Test | |
| print(hide_email('[email protected]')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from reportlab.pdfgen import canvas | |
| from reportlab.pdfbase import pdfmetrics | |
| from reportlab.pdfbase.ttfonts import TTFont | |
| from reportlab.lib.units import cm | |
| from reportlab.lib.pagesizes import A4 | |
| c = canvas.Canvas("hello.pdf", pagesize=A4) | |
| # auto generated elements | |
| texto = c.drawString(1*cm, 2*cm, "Teste 1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def runprocess(command): | |
| "Executa subprocess multiplataforma sem exibir janela. Retorna o returncode." | |
| startupinfo = None | |
| if os.name == 'nt': | |
| startupinfo = subprocess.STARTUPINFO() | |
| startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW | |
| retcode = subprocess.check_call(command, startupinfo=startupinfo) | |
| return retcode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # controlar o mouse no Windows. | |
| import ctypes | |
| import time # opcional | |
| # see http://msdn.microsoft.com/en-us/library/ms646260(VS.85).aspx for details | |
| def pos(x, y): | |
| ctypes.windll.user32.SetCursorPos(x, y) | |
| def click(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Exemplo pra abrir e fechar porta do driver de CD no windows. Python2: | |
| from ctypes import * | |
| import time | |
| print("opening....") | |
| windll.winmm.mciSendStringA("set cdaudio door open", None, 0, 0) | |
| time.sleep(5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "BA": [ | |
| { | |
| "modulo": 7.0, | |
| "id_ibge": 2919207, | |
| "nome": "Lauro de Freitas" | |
| }, | |
| { | |
| "modulo": 50.0, | |
| "id_ibge": 2921500, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from decimal import Decimal | |
| from math import floor | |
| def parcelas(valor, n, div=True): | |
| formato = Decimal('0.00') | |
| valor = Decimal(valor) | |
| if div: | |
| parcela = Decimal(floor(valor * 100 / n) / 100).quantize(formato) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from urllib.request import Request, urlopen | |
| from urllib.error import URLError | |
| from datetime import datetime | |
| import time | |
| class Url(object): | |
| def __init__(self, url, nome): | |
| self.url = url | |
| self.sucesso = 0 |
NewerOlder