Quantcast
Channel: Code – no dogma blog
Browsing latest articles
Browse All 132 View Live

Image may be NSFW.
Clik here to view.

Simmy Chaos Engine for .NET – Part 1, Injecting Faults

Full source code here. For quite a while I have been writing, presenting and making videos about using Polly to make applications more stable. With this post I’m starting a series on how break your...

View Article



Image may be NSFW.
Clik here to view.

Simmy Chaos Engine for .NET – Part 2, Resilience and Injected Faults

Full source code here. I wrote a blog on using a Simmy Fault policy a few days ago, it is very simple to use by itself, but it is far more useful when used in combination with a resilience policy. Take...

View Article

Simmy Chaos Engine for .NET – Part 3, Adding Latency

Full source code here. This is the third in my series on chaos engineering with Simmy. The first two posts dealt with the fault policy throwing exceptions and returning failed responses rather than...

View Article

Accessing the HttpContext from the Constructor of a Controller or a Dependency

Full source code here. There are times when you may need to access the HttpRequest from places that it is not normally available such as the constructor of a controller or the constructor of a service...

View Article

Registering Multiple Implementations of an Interface with Service Collection...

Full source code here. This is a simplistic approach to the problem and assumes that the dependencies created by the factory do not in turn have their own dependencies. This deficiency could be...

View Article


Simmy Chaos Engine for .NET – Part 4, Doing Some Real Damage, Dropping a Table

Full source code here. Up until now the Simmy examples I’ve written have thrown exceptions, changed successes to failures or slowed down a request. None of these did any real damage to your system, and...

View Article

Registering Multiple Implementations of an Interface with Service Collection...

Full source code here. A few weeks ago I wrote a post about using dependency injection to pick between two implementations of an interface. It was a solution I was not very happy with because it meant...

View Article

Simmy Chaos Engine for .NET – Part 5, Breaking Your Own Code

Full source code here. The blog posts I have written so far about Simmy all deal with the scenario where you don’t have control over the source code that you want to break, in these cases Simmy...

View Article


Passing Configuration Options Into Middleware, Services and Controllers in...

Full source code here. I recently hit a problem where I needed to reload configuration settings as they changed, fortunately this is relatively straightforward when using the IOptionsMonitor, in .NET...

View Article


Simmy Chaos Engine for .NET – Part 6, Configuring Policies Dynamically

Full source code here. Simmy chaos policies have configurable options, via these options the polices can be turned on or off, have the rate at which they fire set, and in the case of the latency...

View Article

Simmy Chaos Engine for .NET – Part 7, Using a Random Chaos Policy

Full source code here. This post builds on the previous one where I added chaos policies to a registry and dynamically configured their settings via a config file. In that example the chaos policy used...

View Article

Image may be NSFW.
Clik here to view.

POST with HttpClient and Basic Authorization

Full source code here. A non .NET developer friend asked me to help him write a sample C# application that exercises a POST endpoint he wrote, it requires Basic authorization. After a quick search I...

View Article

Image may be NSFW.
Clik here to view.

Fluent Validation in ASP.NET Core 3.1

Full source code available here. This is an update to a post I wrote in 2017 talking about Fluent Validation in ASP.NET Core. The example is the same but there has been few updates. The first is how...

View Article


Simple Action and Action Examples

Full source code available here. A junior engineer colleague of mine recently asked me “how the f*** do I call this method?”. Seemed like a reasonable question. It was a method that took a complicated...

View Article

Streaming Results from Entity Framework Core and Web API Core – Part 2

Full source code available here. Some time ago I wrote a post showing how to stream results from Entity Framework over Web API. This approach a few benefits – the results would not be materialized in...

View Article


Simple Func and Func Examples

Full source code available here. About a month ago I wrote a post with a simple explanation of how to use methods that take Action or Action<T> as parameters. Actions themselves take 0 to 16...

View Article

AutoMapper, ProjectTo() – Static Version

Full source code available here. I’ve been using AutoMapper for quite a few years, but one of the features that I like the most is the ProjectTo method. When using Entity Framework it lets me reduce...

View Article


Image may be NSFW.
Clik here to view.

AutoMapper, ProjectTo() – Instance Version

Full source code available here. In my previous post I showed how to use the wonderful AutoMapper ProjectTo() feature, the demo code shown worked with AutoMapper up to v8.1.1. It looked like this –...

View Article

Executing a Method on All Implementations of an Interface

Full source code available here. Have you ever wanted to execute a method on all implementations of an interface? Say you have an interface called IGenerator and four implementations of it –...

View Article

Dependency Inject a Service from Startup back to Program in .Net Core 3.1

Full source code available here. Over the past couple of years I wrote a few posts about Dependency Injection in .Net Core 2.1, and this week I received comments from a reader telling me that some of...

View Article

DynamoDb, Reading and Writing Data with .Net Core – Part 1

Full source code available here. A few weeks ago I started playing with DynamoDb in a .NET application. I read through the AWS documentation but felt it was incomplete and a little out of date. This...

View Article


Enum ToString(), Caching for Performance

Full source code available here. A while ago I was working on a program that had to convert enums values to strings as it saved data. When I removed the enum value from the data that was saved it went...

View Article


Synchronous For Loop in Node.js

Full source code available here. In C# it is very easy to avoid doing something asynchronously, but I found out that this is not the case with JavaScript and Node.js. I wanted to load a large amount of...

View Article

DynamoDb, Reading and Writing Data with .Net Core – Part 2

Full source code available here. A few weeks ago I posted about reading and writing data to DynamoDb. I gave instruction on how to get create tables on localstack and how to use the AWS Document Model...

View Article

Getting Started with ElasticSearch, Part 1 – Seeding

Full source code available here. This is the first in a short series of blog posts that will get you started with ElasticSearch. In this you will deploy seed and query ElasticSearch from your own...

View Article


Getting Started with ElasticSearch, Part 2 – Searching with a HttpClient

Full source code available here. In the previous blog post I showed how to setup ElasticSearch, create and index and seed the index with some sample documents. That is not a lot of use without the...

View Article

Image may be NSFW.
Clik here to view.

Entity Framework Core 3.1 Bug vs 2.2, Speed and Memory During Streaming

Full source code available here. A while ago I wrote a blog post about the advantages of streaming results from Entity Framework Core as opposed to materializing them inside a controller and the...

View Article

The Simplest Hello World in Node.js

Full source code available here. I am learning Node.js and have found it a bit of a struggle to locate good, simple documentation. It feels like most people writing in the space assume a lot of...

View Article

Image may be NSFW.
Clik here to view.

Getting Started with ElasticSearch, Part 3 – Deploying to AWS with Pulumi

Full source code available here. This is part 3 of my short introduction to ElasticSearch. In the first part I showed how to create an ElasticSearch index, mapping, and seeded it with data. In the...

View Article



Working with JSON in .NET, a better way?

Full source code available here. Two recent experiences with C# and JSON frustrated me with how difficult it is to work JSON inside an application. I have also been learning Node.js and contrasting the...

View Article

Working with JSON in .NET, Infrastructure as Code with Pulumi

Full source code available here. This is a follow up to my previous post where I used dynamic and JSON files to make querying ElasticSearch with a HttpClient much easier. To deploy my ElasticSearch...

View Article

Reading CSV Files into Objects with Node.js

Full source code available here. As I am learning Node.Js I am constantly surprised by how easy it is to do some things, and how difficult to do others, and how poor the examples out there are. Case in...

View Article

Image may be NSFW.
Clik here to view.

VS Code Bug – Interpolation and Commented Lines, Workaround

This is a quick post with a workaround to a bug in VS Code that occurs when you use string with @$ – the verbatim character and the interpolation characters. If you have a piece of code that looks like...

View Article


Indexing the Works of Shakespeare in ElasticSearch – Part 1, Infrastructure...

Full source code available here. WARNING – be careful when using this, Kinesis costs money and is not on the AWS free tier. At time of writing a couple ElasticSearch instance types are included with...

View Article

Indexing the Works of Shakespeare in ElasticSearch – Part 2, Bulk Indexing

Full source code available here, look inside the lambda folder. This is part two of my series on indexing the works of Shakespeare in ElasticSearch. In part one I setup the infrastructure as code where...

View Article

Indexing the Works of Shakespeare in ElasticSearch – Part 3, Sending the...

Full source code available here. In this, the third part of the series, I show how to read from the Shakespeare CSV file where each row represents a line from a play, (download here), and send these...

View Article


Indexing the Works of Shakespeare in ElasticSearch – Part 4, Searching via...

Full source code available here. This is part four of my four part series on indexing the works of Shakespeare in ElasticSearch. In this I’ll show how to use the ElasticSearch “low level client” to...

View Article


Polly and Blazor, Part 1 – Simple Wait and Retry

Full source code available here. A few weeks ago I gave a talk on Polly at Dotnetconf (you can check it out here), at the end I got many questions about using Polly with Blazor, I had never tried it,...

View Article

Image may be NSFW.
Clik here to view.

Blazor, Updating or Refreshing the Display During a Method Call

Full source code available BlazorUpdatingUIEverySecondWasm. This is a quick post to show how to show how to refresh or update components on a Blazor page asynchronously, for example in response to a...

View Article

Image may be NSFW.
Clik here to view.

Logging to DataDog with Serliog and .Net 5

Full source code available here. This is a quick post to showing how to setup a .Net 5 Web Api application with logging to DataDog from your local computer. Getting Datadog up and running First step is...

View Article

Polly and Blazor, Part 2 – Using the Context

Full source code available here. This post is a short follow up to the one where I used Polly Wait and Retry in Blazor. In that post I used variables defined in my C# method to pass information back to...

View Article


Polly and Blazor, Part 3 – Dependency Injection

Full source code available here. This post continues to build on the two previous on using Polly with Blazor. The first was a simple example of using a Wait and Retry while updating the display as the...

View Article

Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 1 – Hello World

Full source code available here. This is the first in a series of posts on using .NET with AWS Lambdas. It will start with the simplest example that converts a lowercase string to an uppercase string,...

View Article


Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 2 – Web API and an API Gateway

Full source code available here. In the previous post I created a lambda that executed a C# console application. In this post I walkthrough creating a .NET 3.1 Web API application inside a lambda and...

View Article

Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 3 – Pulumi IaC for Web API and an API Gateway

Full source code available here. In this the third in a series of posts on using .NET in AWS lambdas I build on the previous where I connected a Http Gateway to a lambda running a Web API application....

View Article


C# and AWS Lambdas, Part 4 – Storing the Zip in S3, Setup with Pulumi IaC

Full source code available here. In the previous post I showed how to use Pulumi to create a lambda, API gateway and upload a zip of Web API application directly to the lambda. In the post I’m going to...

View Article

Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 5 – Updating the Zip in S3 and Updating the Running...

Full source code available here. This post pulls together a few threads I’ve been working on – creation of lambda to run .NET, storing the zip in S3, and updating the .NET lambda when the zip in S3 is...

View Article

Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 6 – .NET 5 inside a Container inside a Lambda

Full source code available here. A few months ago AWS released a feature allowing Lambdas to run container images, for larger applications this is easier to work with than a zip file or set of layers,...

View Article

Image may be NSFW.
Clik here to view.

C# and AWS Lambdas, Part 7 – .NET 5 Web API inside a Container inside a...

Full source code available here. In my previous post I showed how to build a .NET 5 library inside a docker image and deploy it to an AWS Lambda. This post is a small extension on that. I’m going to...

View Article


C# and AWS Lambdas, Part 8 – .NET 6, inside a Container, inside a Lambda

Full source code available here. After playing with .NET 5 libraries and Web API applications inside Lambda containers I wanted to see if I could get a .NET 6 library running too. I cloned...

View Article

Browsing latest articles
Browse All 132 View Live




Latest Images