Skip to content

Instantly share code, notes, and snippets.

View offpepe's full-sized avatar
👾
rinha e código

Alan Albuquerque Ferreira Lopes offpepe

👾
rinha e código
View GitHub Profile
@offpepe
offpepe / classToCsv.cs
Created June 2, 2023 13:56
class -> csv [c#]
View classToCsv.cs
public static string ConvertToCommaSeparatedValues<T>(this IEnumerable<T> objects) where T : class
{
var builder = new StringBuilder();
var properties = typeof(T).GetProperties();
builder.Append(string.Join(",", properties.Select(p => p.Name)));
builder.Append('\n');
foreach (var obj in objects)
{
var objValues = obj.GetType().GetProperties()
.Select(op => op.GetValue(obj));
@offpepe
offpepe / repository.cs
Created March 31, 2023 13:20 — forked from Guifgr/repository.cs
MultiThread save changes
View repository.cs
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);
}
@offpepe
offpepe / woovi_job.md
Created March 3, 2023 21:24 — forked from sibelius/woovi_job.md
Woovi Job Description
View woovi_job.md
@offpepe
offpepe / ExampleToInjectClass.cs
Created September 6, 2022 17:48
Configure appsettings into object using microsoft.extensions.dependencyInjection
View ExampleToInjectClass.cs
using Microsoft.Extensions.Options;
using Offpepe.Gists.Configurations;
namespace Offpepe.Gists.Business;
// Injecting config
public class ExampleClassToInject {
private readonly ConfigObject _configObject;
public ExampleClassToInject(IOptions<ConfigObject> configObject) {
_configObject = configObject.Value;
@offpepe
offpepe / commit-types.md
Last active March 17, 2022 14:24
commit types
View commit-types.md

commit types

  • build: Alterações que afetam o sistema de construção ou dependências externas (escopos de exemplo: gulp, broccoli, npm),

  • ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs);

  • docs: referem-se a inclusão ou alteração somente de arquivos de documentação;

  • feat: Tratam adições de novas funcionalidades ou de quaisquer outras novas implantações ao código;

@offpepe
offpepe / ValidationExample.cs
Created February 25, 2022 15:07
Abstract validator example to viewModel/DTO validation
View ValidationExample.cs
public class CustomValidation : AbstractValidator<ToValidateViewModel>
{
public EditarCursoValidation()
{
RuleFor(example => example).SetValidator(new Validator());
}
}
public class Validator : AbstractValidator<ToValidateViewModel>
@offpepe
offpepe / update1.cs
Last active February 24, 2022 17:38
update models
View update1.cs
public async Task updateT1 (T update) {
db.Table.Attach(updatedUser);
var entry = db.Entry(updatedUser);
entry.Property(e => e.Field).IsModified = true;
await db.SaveChangesAsync();
}