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
| const puppeteer = require('puppeteer'); | |
| const fs = require('fs'); | |
| (async () => { | |
| // Launch headless Chrome | |
| const browser = await puppeteer.launch(); | |
| const page = await browser.newPage(); | |
| // Load the HTML file (Replace 'my_resume.html' with your actual file path) | |
| const html = fs.readFileSync('my_resume.html', 'utf8'); |
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 static class CandidatesEndpoints | |
| { | |
| public static void MapCandidatesEndpoints(this IEndpointRouteBuilder routes) | |
| { | |
| routes.MapGet("/candidates", () => Results.Ok(new GetCandidatesQuery())) | |
| .WithName("GetCandidates") | |
| .WithJsonLdResponse(CandidatesEnricher); | |
| } | |
| static Func<HttpContext, GetCandidatesQueryResult, object> CandidatesEnricher = (context, result) => |
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
| // ?orderid=ORD-12345&lineitems[0]=PRD-123,2&lineitems[1]=PRD-456,3&SomeOtherProperty=IgnoreValue | |
| // routes.MapGet("/orders", (Order myorder) => Results.Ok(myorder)); | |
| // {"orderId":"ORD-12345","items":[{"itemId":"PRD-123","quantity":2},{"itemId":"PRD-456","quantity":3}]} | |
| public class Order | |
| { | |
| public string? OrderId { get; set; } | |
| public List<LineItem> Items { get; set; } = []; |
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
| version: "3" | |
| services: | |
| shorturl.gateway: | |
| container_name: shorturl.gateway | |
| image: haproxytech/haproxy-ubuntu | |
| build: | |
| context: ./shorturl/gateway | |
| env_file: | |
| - ./shorturl/gateway/.env | |
| ports: |
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
| var builder = WebApplication.CreateBuilder(args); | |
| builder.Services.AddOutputCache(options => | |
| { | |
| options.AddPolicy("ManualExpire", builder => | |
| { | |
| builder.Expire(TimeSpan.FromDays(14)); | |
| builder.Tag("StaticCollections"); | |
| }); | |
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 static class RouteHandlerBuilderExtensions | |
| { | |
| public static RouteHandlerBuilder ValidateRequest<TRequest>(this RouteHandlerBuilder builder) => | |
| builder.AddEndpointFilter<ValidationFilter<TRequest>>(); | |
| } | |
| public class ValidationFilter<TRequest>(ILogger<RequestValidationFilter<TRequest>> logger, IValidator<TRequest>? validator = null) : IEndpointFilter | |
| { | |
| public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) | |
| { return await next(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 Garnet; | |
| using Garnet.client; | |
| // Server.Program.cs | |
| using var server = new GarnetServer(args); | |
| server.Start(); | |
| // Client.Program.cs | |
| using var db = new GarnetClient("localhost", 6379, null); | |
| db.Connect(); |
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 enum CardStatus : int | |
| { | |
| Active = 1, | |
| Expired = 2, | |
| PendingVerification = 3 | |
| } | |
| public record CardEntity(CardStatus Status); | |
| public class CardConfiguration : IEntityTypeConfiguration<Card> |
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 CardConfiguration : IEntityTypeConfiguration<Card> | |
| { | |
| public void Configure(EntityTypeBuilder<Card> builder) => | |
| builder.Property(c => c.EntityId) | |
| .HasValueGenerator<CardIdGenerator>() | |
| .HasColumnType("nvarchar") | |
| .HasColumnOrder(1) | |
| .HasMaxLength(30) | |
| .IsRequired(); | |
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 System.Globalization; | |
| var _cache = new Dictionary<string, CacheItem<Transfer>>() { | |
| { "1", new CacheItem<Transfer> { Item = new Transfer { Id = 100, Status = TransferStatus.Completed, LastModified = DateTime.ParseExact("2024-07-16 11:00", "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture) } } }, | |
| { "2", new CacheItem<Transfer> { Item = new Transfer { Id = 200, Status = TransferStatus.Incomplete, LastModified = DateTime.ParseExact("2024-07-16 11:00", "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture) } } }, | |
| { "3", new CacheItem<Transfer> { Item = new Transfer { Id = 300, Status = TransferStatus.Canceled, LastModified = DateTime.ParseExact("2024-07-16 11:00", "yyyy-MM-dd HH:mm", CultureInfo.InvariantCulture) } } }, | |
| }; | |
| // Global method to access and clean up cache. | |
| void CleanUpCache<T>(KeyValuePair<string, CacheItem<T>> entry) => |
NewerOlder