Skip to content

Instantly share code, notes, and snippets.

View Guifgr's full-sized avatar
:shipit:
LoFi and Coffe

Guilherme FGR Guifgr

:shipit:
LoFi and Coffe
View GitHub Profile
@Guifgr
Guifgr / Makefile
Created October 18, 2022 19:34
makefile 4 ef
add-migration-linux:
@read -p "Nome da migration (ex: TipoTabelaMotivo) : " table \
&& dotnet ef --startup-project ../Sln.projetoBase migrations add $${table}
remove-migration-linux:
dotnet ef --startup-project ../Sln.projetoBase migrations remove
update-database:
@echo "Você revisou a migration antes de enviar?"
@read -p "[Enter para confimar || CTRL + C para cancelar]" reponse;
@Guifgr
Guifgr / api.js
Created October 10, 2022 14:18
intercept errors react axios
import axios from 'axios'
import { getToken, logout } from './auth'
import config from '../Constants'
export const hub = config.url.Hub
const api = axios.create({
baseURL: config.url.route,
})
Você sabe como recuperar uma branch que você apagou local e tinha código que não podia perder no GIT?
quando você dá 𝗴𝗶𝘁 𝗿𝗲𝗳𝗹𝗼𝗴 𝘀𝗵𝗼𝘄, vai mostrar o histórico com últimos commits, lá você vai achar o código SHA do seu commit, ou caso o terminal esteja aberto e o comando de deletar a branch ainda esteja no histórico do lado ele vai ter o código SHA
Depois basta copiar esse código SHA
e dar:
𝗴𝗶𝘁 𝗯𝗿𝗮𝗻𝗰𝗵 𝗯𝗿𝗮𝗻𝗰𝗵𝗡𝗮𝗺𝗲 <𝗦𝗛𝗔𝟭>
using Domain.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.Extensions.Configuration;
namespace Infrastructure.Database.Context
{
public class MssqlContext : DbContext
{
public MssqlContext()
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
namespace Domain.Models
{
[Keyless]
[Table ("NOME_VIEW", Schema ="SCHEMA")]
public class ProgramacaoDoGasView
{
@Guifgr
Guifgr / repository.cs
Created March 18, 2022 12:14
MultiThread save changes
public void SaveChangesParallel(List<objeto> objetos)
{
var saveList = new List<List<objeto>>();
var count = 0;
while (count < objetos.Count)
{
var partialSaves = objetos.Skip(count).Take(250).ToList();
count += partialSaves.Count;
saveList.Add(partialSaves);
}
@Guifgr
Guifgr / Program.cs
Last active March 24, 2022 14:47
Verify database connection entity
try
{
using var dbContext = new Context();
Console.WriteLine($"Connected {dbContext.Database.CanConnectAsync().Result}");
}
catch (Exception e)
{
Console.WriteLine($"Error {e.Message}");
}
@Guifgr
Guifgr / SwaggerApi.csproj
Last active February 19, 2024 13:58 — forked from yanandrey/SwaggerApi.csproj
Swagger Configuration
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
@Guifgr
Guifgr / program.cs
Last active February 24, 2022 22:17
Make dabase convention in snake_case
.UseNpgsql(...)
.UseSnakeCaseNamingConvention();
@Guifgr
Guifgr / .gitignore
Created January 13, 2022 13:08
GitIgnore .NET
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache