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
// Define a trait with a default method implementation. | |
trait Greet { | |
fn greet(&self) { | |
println!("Hello from the default implementation!"); | |
} | |
} | |
// Define a type. | |
struct Person; |
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
{ | |
"security.workspace.trust.untrustedFiles": "open", | |
"editor.unicodeHighlight.nonBasicASCII": false, | |
"python.linting.flake8Enabled": false, | |
"python.linting.enabled": false, | |
"python.linting.pylintEnabled": true, | |
"terminal.integrated.shellArgs.windows": [ | |
"-ExecutionPolicy", | |
"Bypass" | |
], |
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
import os | |
import shutil | |
from PIL import Image | |
def is_image(file_path): | |
try: | |
with Image.open(file_path) as img: | |
return True | |
except (IOError, FileNotFoundError): |
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
import pygments | |
from pygments.lexers import PythonLexer | |
from pygments.formatters import HtmlFormatter | |
import sys | |
def python_to_html(input_file, output_file): | |
# Read the Python code from the input file | |
with open(input_file, 'r', encoding='utf-8') as f: | |
code = f.read() |
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
@dataclass | |
class Pessoa: | |
nome: str | |
idade: int | |
skills: list = field(default_factory=list) | |
data: datetime = field(default_factory=datetime.now) | |
contador: int = field(default=0, init=False, repr=False) | |
def __post_init__(self): | |
Pessoa.contador += 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
import time | |
import functools | |
def log_time(func): | |
"""Decorator to log the execution time of a function.""" | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
start_time = time.time() # Capture the start time | |
result = func(*args, **kwargs) # Execute the function |
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
import random | |
from tqdm import tqdm # instale com pip install tqdm | |
import time | |
def digitar_mensagem(mensagem): | |
for char in mensagem: | |
print(char, end='', flush=True) | |
time.sleep(0.05) | |
print() | |
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 gen_random(a, c, m): | |
seed = 4 | |
def make_random(): | |
nonlocal seed, a, c, m | |
seed = ((seed * a)+c) % m | |
return seed | |
return make_random | |
my_random = gen_random(5, 8, 7) |
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
import os | |
import shutil | |
def main(): | |
# Diretório a ser analisado | |
directory = '.' | |
# Nome do script atual | |
current_script = os.path.basename(__file__) |
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
__author__ = "Nicholas White" | |
# Copyright (c) 2012 Nicholas White -- see LICENSE for details | |
# https://github.com/nickwah | |
import random | |
from PIL import Image | |
# Color mapping gleefully stolen from: | |
# https://github.com/rendro/vintageJS/ by Robert Fleischmann |
NewerOlder