Programming

.NET Core Entity Framework Migrations

Posted on

When you don’t want to script out your own database, Entity Framework Core has your back. When you change your database context or the models it uses, you can use a couple of commands to create and update your database to keep it in sync with your model. These examples run in the Package Manager […]

Programming

Removing Special Characters and Diacritic Marks in C#

Posted on

I did this trick in JavaScript to remove diacritic marks a while back and the need to perform a similar transformation in C# came up this week. The following method simplifies strings such as “façade” into simple string like “façade”. private static string Simplify(string input) { string normalizedString = input.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(); […]

Programming

Avoid Expensive innerHTML Manipulation with insertAdjacentHTML

Posted on

It is pretty well known these days that fiddling with innerHTML is terribly inefficient. It triggers serialization, and it can result in invalid markup. Nevertheless, you’ll still find this being done in many applications. elem.innerHTML = elem.innerHTML + ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; // or elem.innerHTML += ‘<a href=”https://www.example.com”>Visit Example Dot Com</a>’; You can avoid […]

Programming

HTML Challenge: Toggle Switch vs Checkbox

Posted on

The toggle switch has very suddenly become a ubiquitous feature of web user interfaces. You can’t hardly fill in an HTML form these days without finding one; especially as 99% of forms we now fill in are concerned with “cookie consent”. Why isn’t the toggle switch a first-class citizen of HTML, you may ask… to […]

Programming

Set a Minimum Font Size

Posted on

This is just a little script I needed to use to increase text size conditionally. It only increases text below a minimum size and leaves everything else. (function () { var minFontSize = function () { $(“.content-zone *”).each(function () { var $this = $(this); if (parseInt($this.css(“fontSize”), 10) < 16) { $this.css({ “font-size”: “16px” }); } […]

Automation

Manipulating Variables in JMeter

Posted on

There are many reasons for manipulating variables in JMeter, especially when you are loading data from a CSV data set config element. You might want to trim a JMeter variable, or grab just a substring. In all of these cases, your existing knowledge of JavaScript can come to the rescue. Wherever you were about to […]

Programming

Make HAProxy Strip Spaces From a Request Header

Posted on

There is some shared code out in the wild that browser extensions are using to make requests, which might cause problems if you parse the Referer header in your website. The issue is with the following request header, which you might see in your logs as Referer: http://+www.example.com: Referer: http:// www.example.com That space between the […]

Programming

The Microservices vs Conway Test

Posted on

Following on from my article on Mescoservices back in 2015, this article expands on an idea I had in September on how monoliths, mescoservices, and microservices fit into organisation design. The microservices vs Conway test encodes a common piece of advice into a first-draft formula for testing your architecture against your organisation. Microservice Advice Microservices […]