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
| public class StudentsController : ControllerBase | |
| { | |
| private readonly YourDbContext _context; | |
| public StudentsController(YourDbContext context) | |
| { | |
| _context = context; |
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
| using Microsoft.AspNetCore.Identity; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Microsoft.Extensions.Configuration; | |
| using Microsoft.IdentityModel.Tokens; | |
| using System.IdentityModel.Tokens.Jwt; | |
| using System.Security.Claims; | |
| using System.Text; | |
| namespace SeuProjeto.Controllers | |
| { |
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
| // ... Seção HTML/Razor Markup Omitida ... | |
| @code { | |
| // Modelo de credenciais (usado para Login/Registro) | |
| private SeuProjeto.Controllers.AuthController.CredenciaisModel model = new(); | |
| private List<SeuProjeto.Controllers.GamesController.Game> _games = new(); | |
| private string? _authMessage; // Mensagem de feedback de autenticação | |
| private bool _authSuccess; | |
| private bool _isLoading; | |
| private string? _fetchMessage; // Mensagem de feedback da API protegida |
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
| // Autenticação de Usuários com Identity | |
| builder.Services.AddDefaultIdentity<IdentityUser>( | |
| options => options.SignIn.RequireConfirmedAccount = true | |
| ) | |
| .AddEntityFrameworkStores<ApplicationDbContext>(); | |
| // API Controllers | |
| builder.Services.AddControllers(); |
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 datetime import datetime, timedelta | |
| from django.utils import timezone | |
| # Calculando a data de 15 dias atrás | |
| data_inicio = timezone.now() - timedelta(days=15) | |
| data_fim = timezone.now() | |
| # Filtrando e ordenando os registros | |
| pastas_modificadas = PastaAluno.objects.filter( | |
| data_modificacao__range=(data_inicio, data_fim) |
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
| # Model | |
| class Funcionario(models.Model): | |
| matricula = models.CharField(max_length=7, default="0000000") | |
| nome = models.CharField(max_length=200) | |
| # ... | |
| assuncao = models.DateField(auto_now=False, auto_now_add= False, null=True, blank=True, default= None) | |
| admissao = models.DateField(auto_now=False, auto_now_add= False, null=True, blank=True, default= None) | |
| encerramento = models.DateField(auto_now=False, auto_now_add= False, null=True, blank=True, default= None) | |
| """ |
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
| class Funcionario(models.Model): | |
| SEXO_CHOICES = [ | |
| ("NAOINFORMADO", "Não Informado"), | |
| ("FEM", "Feminino"), | |
| ("MAS", "Masculino") | |
| ] | |
| genero = models.CharField(max_length=50, choices=SEXO_CHOICES, default = ("NAOINFORMADO", "Não Informado")) | |
| CONTRATACAO_CHOICES = [ | |
| ("ESTATUTARIO", "Servidor Estatutário"), | |
| ("CLT", "Servidor CLT"), |
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 sounddevice as sd | |
| import numpy as np | |
| # Define as configurações do microfone (ajuste conforme necessário) | |
| sample_rate = 44100 # Taxa de amostragem padrão | |
| channels = 1 # 1 para mono, 2 para estéreo |
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 cv2 | |
| import numpy as np | |
| # Camera indices | |
| camera_indices = [0, 1] | |
| # Create capture objects |
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
| /* | |
| Em Blazor, rate limit (limitação de taxa) é a prática de restringir a frequência com que uma ação pode ser repetida dentro de um determinado período. É usado para proteger contra uso excessivo e ataques de força bruta, limitando o número de solicitações ou ações que um usuário (ou um cliente) pode fazer num determinado período de tempo. | |
| Exemplos e Implementação: | |
| 1. Limitar o número de tentativas de login: | |
| Se um usuário tenta fazer login muitas vezes com uma combinação incorreta de nome de utilizador/senha, o sistema pode bloquear temporariamente o acesso daquele utilizador. | |
| Em Blazor, isso pode ser implementado verificando o número de tentativas de login recentes para um determinado endereço IP ou utilizador e bloqueando se exceder o limite. | |
| 2. Limitar o número de chamadas API: | |
| Se um usuário está fazendo muitas chamadas a uma API, o sistema pode estar a ser sobrecarregado. | |
| Para evitar isso, pode-se configurar um limite de chamadas por segundo, minuto ou hora. |
NewerOlder