Skip to content

Instantly share code, notes, and snippets.

Avatar

Radek Maziarka rmaziarka

View GitHub Profile
View gist:764ed0b37e62c34f14299d41b53ae92b
let queryRUChargeData = AzureDiagnostics
| where Category == "DataPlaneRequests"
| where OperationName == "Query"
| project requestCharge_s, operationType_s, activityId_g, databaseName_s, collectionName_s, requestResourceType_s, requestResourceId_s, OperationName, TimeGenerated, callerId_s, clientIpAddress_s, userAgent_s;
AzureDiagnostics
| where Category == "QueryRuntimeStatistics"
| join queryRUChargeData on $left.activityId_g == $right.activityId_g
| summarize SumRU = sum(todouble(requestCharge_s1)), Count = count(requestCharge_s1) by collectionname_s
View wordpress-to-hugo-migrator.js
// it was easier to describe this file on my blog that here:
// https://radekmaziarka.pl/2020/04/12/markdown-generation
'use strict';
const fs = require('fs');
const path = require('path');
const xml2js = require('xml2js');
const TurndownService = require('turndown');
var moment = require('moment');
View Program.cs
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Hello World!");
try
{
await CreateTableAsync("tags");
@rmaziarka
rmaziarka / Category.cs
Last active Apr 8, 2018
Product Entities
View Category.cs
public class Category
{
public int Id { get; set; }
public string Name { get; set; }
public List<Field> Fields { get; set; }
}
View ProductReadModel.cs
public class ProductReadModel
{
public ProductReadModel(ProductAddedEvent @event)
{
Id = @event.Id;
Name = @event.Name;
CategoryId = @event.CategoryId;
OrderAmount = 0;
Review = new ReviewReadModel();
View ProductReadModelCreation.sql
INSERT INTO ProductReadModel
SELECT
P.[Id],
P.[Name],
P.[CategoryId],
(
SELECT
COUNT(O.Id)
FROM
OrderItems AS O
View EventHandlers.cs
public class ProductAddedEventHandler: INotificationHandler<ProductAddedEvent>
{
private readonly IProductReadModelRepository _repo;
public ProductAddedEventHandler(IProductReadModelRepository repo)
{
_repo = repo;
}
public void Handle(ProductAddedEvent @event)
View CommandHandlers.cs
public class AddProductCommandHandler : IRequestHandler<AddProductCommand>
{
private readonly ProductDatabase _database;
private readonly IMediator _mediator;
public AddProductCommandHandler(ProductDatabase database, IMediator mediator)
{
_database = database;
_mediator = mediator;
}
View Events.cs
public class ProductAddedEvent : INotification
{
public ProductAddedEvent(int id, string name, int categoryId)
{
Id = id;
Name = name;
CategoryId = categoryId;
}
public int Id { get; }
View Product.cs
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public decimal Price { get; set; }
public DateTime CreationDate { get; set; }