Skip to content

Instantly share code, notes, and snippets.

View dunossauro's full-sized avatar
🟣

Eduardo Mendes dunossauro

🟣
View GitHub Profile
@dunossauro
dunossauro / output.txt
Created February 13, 2019 23:46
AST mutation
SURVIVED test_soma_0_0_deve_retornar_0: <class '_ast.Sub'>
SURVIVED test_soma_0_0_deve_retornar_0: <class '_ast.Mult'>
PASSED test_soma_0_0_deve_retornar_0: <class '_ast.Div'>. ERROR: division by zero
PASSED test_soma_1_1_deve_retornar_2: <class '_ast.Sub'>. ERROR:
PASSED test_soma_1_1_deve_retornar_2: <class '_ast.Mult'>. ERROR:
PASSED test_soma_1_1_deve_retornar_2: <class '_ast.Div'>. ERROR:
PASSED test_soma__1__1_deve_retornar__2: <class '_ast.Sub'>. ERROR:
PASSED test_soma__1__1_deve_retornar__2: <class '_ast.Mult'>. ERROR:
PASSED test_soma__1__1_deve_retornar__2: <class '_ast.Div'>. ERROR:
@dunossauro
dunossauro / fake.py
Created February 25, 2019 10:23
Live 80 beta
"""Providers para o faker."""
from random import choice
from faker import Faker
from faker.providers import BaseProvider
class Task(BaseProvider):
"""Model to provide tasks."""
def task_name(self):
@dunossauro
dunossauro / merge_dicts.py
Created February 25, 2019 19:37
Using toolz and dispatcher to merge dicts
from functools import singledispatch
from toolz import merge_with
dict_1 = {
'a': 1,
'b': 1,
'c': [
1, 2, 3, 4
],
'd': {
@dunossauro
dunossauro / junit_merge.py
Last active June 17, 2019 10:57
Merge behave junit rerun file with original report
"""
Behave junit merge.
Merge behave-junit rerun and original file
usage: junit-merge [-h] [--report REPORT] [--rerun_report RERUN_REPORT]
optional arguments:
-h, --help show this help message and exit
--report REPORT junit-file
t1 = ('Eduardo', 'Mendes', 25)
# desempacotamos em variáveis
nome, sobre, idade = t1
t2 = (('Eduardo', 'Mendes'), 25)
# desempacotamos em variáveis compostas
(nome, sobre), idade = t2
l1 = ['Eduardo', 25, 'Martha', 'Cesar']
nome, idade, mae, pai = l1
@dunossauro
dunossauro / tcr.sh
Last active April 8, 2024 00:52
My python test commit revert script - unittest, tox and pytest supported
#! /bin/bash
#===================================================================================
#
# Usage:
# ./tcr.sh -> test && commit || revert
# ./tcr.sh squash "my message" -> get all comits with "TCR" message squash and commit with your message
#
# Variables:
# code_path: production code path, not test path
# test_runner: choosed python test runner unittest, pytest, tox
@dunossauro
dunossauro / login_form.py
Created April 14, 2020 08:09
Código do vídeo sobre Brython - https://youtu.be/HKSUPdcK7OU
from browser import document
from browser.html import INPUT, LABEL, BR, FORM
def login_form():
form = FORM(
Class='form login-form',
id="meu-forme",
action="#",
method="get",
@dunossauro
dunossauro / mouse_events.html
Last active May 18, 2020 01:35
Exemplo de eventos de mouse usando Brython
<html lang="pt-BR">
<head>
<meta charset="utf-8">
<title>Eventos de mouse</title>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js">
</script>
<script type="text/python">
"""
Testando eventos de mouse com Brython.
def soma(x, y):
"""Função que soma dois números."""
return x + y
def subtracao(x, y):
"""Função que subrai dois números."""
...
from sqlite3 import connect
from random import randint
db = connect('database.sqlite')
cursor = db.cursor()
def pergunta():