Skip to content

Instantly share code, notes, and snippets.

View offpepe's full-sized avatar
💫
sei lá oq sei lá oq, sei oq lá

Alan Albuquerque Ferreira Lopes offpepe

💫
sei lá oq sei lá oq, sei oq lá
View GitHub Profile
@offpepe
offpepe / Export md from devto article.js
Created September 3, 2024 18:43 — forked from seokjeon/Export md from devto article.js
Export md from dev.to article
// Copy the code below, and paste it on address bar where you want to export markdown.
javascript:var url=window.location.href.split("/");url.splice(3,0,"api","articles"),fetch(url.join("/")).then(o=>o.json()).then(o=>console.log(o.body_markdown));

Refactoring Kind's switch with ChatSH

(This is a readable version of my ChatSH session. For the full log, click here.)

Taelin: Hello. We're going to refactor an aspect of the implementation of the Kind language. Are you ready? Start by doing 'ls', then 'cat kind-lang.cabal' to get familiar with the repo.

ChatSH: Certainly! I'm ready to help you refactor an aspect of the Kind language implementation. Let's start by examining the repository structure and the contents of the Cabal file.

ls && echo "---" && cat kind-lang.cabal
@offpepe
offpepe / classToCsv.cs
Created June 2, 2023 13:56
class -> csv [c#]
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
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
@offpepe
offpepe / ExampleToInjectClass.cs
Created September 6, 2022 17:48
Configure appsettings into object using microsoft.extensions.dependencyInjection
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

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
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
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();
}