Skip to content

Instantly share code, notes, and snippets.

View lucrib's full-sized avatar

Lucas Ribeiro lucrib

View GitHub Profile
@lucrib
lucrib / megasena-game-test.py
Created October 14, 2022 14:45
A simplistic mega-sena lottery game simulator
import functools
import random
import time
from collections import defaultdict
from threading import Thread
class Timer(Thread):
def __init__(self, interval, func, *args, **kwargs):
super().__init__()
@pytest.fixture
def step():
from allure_commons import plugin_manager
hook = plugin_manager.hook
def report_step(title):
_uuid = uuid4()
hook.start_step(uuid=_uuid, title=title, params={})
hook.stop_step(uuid=_uuid, title=title, exc_type=None, exc_val=None, exc_tb=None)
@lucrib
lucrib / list_files.py
Created March 21, 2017 17:50
A small script that receives a folder path and a extension and list all files of that extension recursively starting in the folder informed
import os
import sys
def list_files_in(path, ext=None):
for root, subdirs, files in os.walk(path):
# print('\n\nroot = ' + root)
for subdir in subdirs:
list_files_in(subdir)
from random import randint
from PIL import Image
import numpy as np
W, H, = 1920, 1080
def shades_of(color):
if color == 'red':
return rand_rgb(0, 255, 0, 0, 0, 0)
@lucrib
lucrib / grep_tips_tricks
Created April 16, 2015 13:37
Grep for multiple words
grep -E "(word1|word2|wordn)"
@lucrib
lucrib / py_execption_handling
Created November 3, 2014 17:37
Python Exception Handling
try:
You do your operations here;
......................
except ExceptionI:
If there is ExceptionI, then execute this block.
except ExceptionII:
If there is ExceptionII, then execute this block.
......................
else:
If there is no exception then execute this block.