RSSAmplifier

Blog

Dusted Codes

Programming, Coffee and Indie Hacking

dusted.codesRSS feed ↗63 posts

Latest posts

.NET Blazor


 .NET Blazor has been touted as a revolutionary framework that allows .NET developers to build interactive web applications using C# instead of JavaScript. It's mainly aimed at ASP.NET Core developers who want to build SPA-like apps leveraging the .NET ecosystem and a wealth of existing libraries and tools available via NuGet. It's Microsoft's latest instalment in an attempt to gain traction…

Creating a pretty console logger using Go's slog package

I had the privilege of attending GopherCon UK last week, and among the many captivating talks, one that stood out to me was "Structured Logging for the Standard Library" presented by Jonathan Amsterdam . 
 The presentation provided an insightful dive into Go's log/slog package . This talk couldn't have come at a better time given that I've just started on a new Go project, where I was eager to…

How fast is ASP.NET Core?

In recent years the .NET Team has been heavily advertising ASP.NET Core as one of the fastest web frameworks on the market. The source of those claims has always been the TechEmpower Framework Benchmarks . 
 Take this slide from BUILD 2021 , which Scott Hunter - Director of Program Management .NET, presented last year: 
 
 According to him .NET is more than 10 times faster than…

The type system is a programmer's best friend

I am tired of primitive obsession and the excessive use of primitive types to model a domain. 
 A string value is not a great type to convey a user's email address or their country of origin. These values deserve much richer and dedicated types. I want a data type called EmailAddress which cannot be null. I want a single point of entry to create a new object of that type. It should get…

Using Go generics to pass struct slices for interface slices

Have you ever tried to pass a struct slice into a function which accepts a slice of interfaces? In Go this won't work. 
 Let's have a quick look at an example. Let's assume we have an interface called Human and a function called GreetHumans which accepts a slice of humans and prints their names: 
 package main
 
 import 'fmt' 
 
 type Human interface {
 	 Name ()…

Building a secure note sharing service in Go

Welcome to my first Go related article which I am releasing on my blog. 
 In this blog post I’ll be using Go to develop a super small web service which can be used by people or organisations to share secrets in a slightly more private way. We all have the occasional need to share a secret with a co-worker or another person. It may be an API key, a password or even some confidential data from a…

Fund OSS through package managers

Open source software has become an integral part of our lives. Personally I don’t know a single app, website or other digital product which doesn’t make use of at least one open source project in their stack. We all know the value and importance of open source software and yet many open source maintainers struggle with its sustainability. A big part of that struggle is the inability to cover the…

Can we trust Microsoft with Open Source?

Oh boy, what a week of .NET drama again. Not bored yet? Read on, but for this one you’ll need some stamina, because this one is different. 
 Before I start with my actual blog post let me give you a short disclaimer. This is not an issue of some outspoken or sceptical community members making a fuss out of nothing. I know it is easy to see it this way with incomplete information, but trust me…

.NET Basics


 So you want to learn .NET but you are confused about the differences between .NET Framework and .NET Core or what the various versions of ASP.NET are or what the relationship is between C# and F#? If that is the case then you came to the right place. This guide will cover all the basics of .NET and shed some light on the various acronyms and buzz words behind it! 
 If you are new to .NET…

You don’t need Docker

Note: In this blog post I use the terms Docker and containers interchangeably. I know that Docker is only one of many container technologies and not always the best suited one (e.g. Kubernetes), but for the purpose of this blog post I don't differentiate between them. 
 „ You don’t need Docker. I started my business on a small server under my desk. It took me more than 10 years before I…

Using .env in .NET

.NET (Core) comes with a lot of bells and whistles. One of them is the sheer amount of managing application secrets and settings. Developers have a variety of options from which they can load application settings using the ConfigurationBuilder class. The official ASP.NET Core documentation lists all options as following: 
 
 Settings files, such as appsettings.json 
 Environment…

Equal pay for equal work

Remote work is on the rise, the economy is on a decline and businesses are re-structuring themselves around what many consider the new normal. Increasingly more organisations are opening themselves up to the possibility of working remotely beyond just the temporary measure in the fight against COVID-19. Many begin to see remote work as not only a necessary consequence, but rather as a new…

.NET for Beginners

Last night I came across this question on Reddit: 
 
 Hello, I am just starting to learn c# and i am about to start with a course on Udemy by Mosh Hamedani called 'C# Basics for Beginners: Learn C# Fundamentals by Coding'.
 I can see that he is using .NET Framework but i have read that .NET Core is newer and is the future? I am really not sure where to start and would appreciate if…

GitHub Actions for .NET Core NuGet packages

Last weekend I migrated the Giraffe web framework from AppVeyor to GitHub Actions . It proved to be incredibly easy to do so despite me having some very specific requirements on how I wanted the final solution to work and that it should be flexible enough to apply to all my other projects too. Even though it was mostly a very straight forward job, there were a few things which I learned along the…

Automate frequently used CLI commands

Welcome back to my blog! I haven’t written anything here for more than a year now, which is something I very much regret, but I mostly blame real life for it! Luckily due to the COVID-19 pandemic everything has slowed down a bit and I get to spend more time on my blog, side projects and some writing again. It’s always hard to get back to something after a long break, so I thought I'd start with a…

Tips and tricks for ASP.NET Core applications

This is a small collection of some tips and tricks which I keep repeating myself in every ASP.NET Core application. There's nothing ground breaking in this list, but some general advice and minor tricks which I have picked up over the course of several real world applications. 
 Logging 
 Let's begin with logging. There are many logging frameworks available for .NET Core, but my absolute…

Why you should learn F#

If you were thinking of learning a new programming language in 2019 then I would highly recommend to have a close look at F#. No matter if you are already a functional developer from a different community (Haskell, Clojure, Scala, etc.) or you are a complete newbie to functional programming (like I was 3 years ago) I think F# can equally impress you. F# is a functional first language . This means…

Drawbacks of Stored Procedures

A few weeks ago I had a conversion with someone about the pros and cons of stored procedures. Personally I don't like them and try to avoid stored procedures as much as possible. I know there are some good reasons for using stored procedures (sometimes), but I'm also very well aware of the downsides which stored procedures bring with them. 
 This was not the first time that I had such a…

ASP.NET Core Firewall

About a month ago I experienced an issue with one of my online services which is running in the Google Cloud and also protected by Cloudflare . I had noticed a spike in traffic which only showed up in my Google Cloud dashboard but not in Cloudflare. It was odd because all requests should normally route through Cloudflare's proxy servers but it seemed like someone was circumventing the DNS…

Open Source Documentation

Since January 2017, which soon will be two years ago, I've been maintaining an open source project called Giraffe . Giraffe is a functional web framework for F# which allows .NET developers to build rich web applications on top of Microsoft's ASP.NET Core web framework in a functional first approach. Given that Giraffe is targeted at .NET web developers, who practise F# and who also like to use…

Stop doing security (yourself)

Security has a very special place in software engineering. It is very different than other disciplines, because it is a problem space which cannot be approached with the same mindset as other problem spaces in our trade. 
 What makes security stand out so much is that it doesn't follow the same principles as the rest of software development. There is no different set of opinions. There is only…

Giraffe 1.1.0 - More routing handlers, better model binding and brand new model validation API

Last week I announced the release of Giraffe 1.0.0 , which (apart from some initial confusion around the transition to TaskBuilder.fs ) went mostly smoothly. However, if you have thought that I would be chilling out much since then, then you'll probably be disappointed to hear that today I've released another version of Giraffe with more exciting features and minor bug fixes. 
 The release of…

Announcing Giraffe 1.0.0

I am pleased to announce the release of Giraffe 1.0.0 , a functional ASP.NET Core web framework for F# developers. After more than a year of building, improving and testing the foundations of Giraffe it makes me extremely happy to hit this important milestone today. With the help of 32 independent contributors , more than a hundred closed GitHub issues and an astonishing 79 merged pull requests…

Extending the Giraffe template with different view engine options

This is going to be a quick but hopefully very useful tutorial on how to create a more complex template for the dotnet new command line tool. 
 If you have ever build a Giraffe web application then you've probably started off by installing the giraffe-template into your .NET CLI and then created a new boilerplate application by running the dotnet new command: 
 dotnet new giraffe 
 (…

Evolving my open source project from a one man repository to an OSS organisation

Over the last couple of months I have been pretty absent from my every day life, such as keeping up with Twitter, reading and responding to emails, writing blog posts, working on my business and maintaining the Giraffe web framework. It was not exactly what I had planned for, but my wife and I decided to take a small break and wonder through South America for a bit before coming back for Christmas…

Giraffe goes Beta


 After 6 months of working on Giraffe , lots of improvements, great community contributions and running several private as well as commercial web applications in production I am really happy to announce that Giraffe is finally going Beta . This might not sound like a big milestone to you, but given that I was very hesitant on pre-maturely labelling the project anything beyond Alpha and the…

Functional ASP.NET Core part 2 - Hello world from Giraffe

This is a follow up blog post on the functional ASP.NET Core article from about two months ago. First of all I'd like to say that this has been the longest period I haven't published anything new to my blog since I started blogging in early 2015. The reason is because I have been pretty busy with a private project which I hope to write more about in the future, but more importantly I have been…

Functional ASP.NET Core

In December 2016 I participated in the F# Advent Calendar where I wrote a blog post on running Suave in ASP.NET Core . As part of that blog post I introduced the Suave.AspNetCore NuGet package which makes it possible to run a Suave web application inside ASP.NET Core via a new middleware. 
 So far this has been pretty good and as of last week the GitHub repository has been moved to the…

Thank you Microsoft for being awesome

OK so I have to admit that I can have a pretty big mouth sometimes, which is certainly not a good quality to have. I don't shy away to be (overly) critical if things annoy me: 
 
 As you can see, about a year ago I was a little bit upset that a great new product received a not so great new name. I really hoped that ASP.NET Core would have been named something much "cooler" for my taste.…

Error Handling in ASP.NET Core

Almost two years ago I wrote a blog post on demystifying ASP.NET MVC 5 error pages and error logging , which became one of my most popular posts on this blog. At that time of writing the issue was that there were an awful lot of choices on how to deal with unhandled exceptions in ASP.NET MVC 5 and no clear guidance or recommendation on how to do it the right way. 
 Fortunately with ASP.NET…

Running Suave in ASP.NET Core (and on top of Kestrel)

Ho ho ho, happy F# Advent my friends! This is my blog post for the F# Advent Calendar in English 2016 . First a quick thanks to Yan Cui who has pointed out this calendar to me last year and a big thanks to Sergey Tihon who is organising this blogging event and was kind enough to reserve me a spot this year. 
 
 In this blog post I wanted to write about two technologies which I am…

Building and shipping a .NET Core application with Docker and TravisCI

With the .NET Core ecosystem slowly maturing since the first official release this year I started to increasingly spend more time playing and building software with it. 
 I am a big fan of managed CI systems like AppVeyor and TravisCI and one of the first things I wanted to work out was how easily I could build and ship a .NET Core application with one of these tools. This was a major…

Load testing a Docker application with JMeter and Amazon EC2

A couple of months ago I blogged about JMeter load testing from a continuous integration build and gave a few tips and tricks on how to get the most out of automated load tests. In this blog post I would like to go a bit more hands on and show how to manually load test a Docker application with JMeter and the help of Amazon Web Services . 
 I will be launching two Amazon EC2 instances to…

Creating a Slack bot with F# and Suave in less than 5 minutes

Slack has quickly gained a lot of popularity and became one of the leading team communication tools for developers and technology companies. One of the main compelling features was the great amount of integrations with other tools and services which are essential for development teams and project managers. Even though the list of apps seems to be huge, sometimes you need to write your own custom…

BuildStats.info |> F#

After working on the project on and off for a few months I finally found enough time to finish the migration to F#, Suave and Docker of BuildStats.info . 
 The migration was essentially a complete rewrite in F# and a great exercise to learn F# and Suave.io as part of a small side project which runs in a production environment now. Working with F# and Suave was so much fun that I'm already…

JMeter Load Testing from a continuous integration build

In the last two weeks I have been doing a series of load tests and the tool I've been using was Apache JMeter . JMeter is an open source, cross platform load testing tool written in Java. Unlike the Apache benchmarking tool (aka AB) JMeter has been specifically designed to load test static and dynamic web services with high accuracy. Running those tests manually in the beginning of a new project…

Custom error handling and logging in Suave

Some years ago when you wanted to develop a .NET web application it was almost given that it will run on IIS, but today we have a sheer amount of different web server technologies to our availability. If you are an F# developer or in the process of learning F# (like me) then you will most likely come across the Suave web framework. 
 Suave is a lightweight, non-blocking web server written in…

Watch US Netflix, Hulu and more from anywhere in the world

If you are reading this then I assume you are one of those unfortunate Netlix, Hulu and Co. users who does not live in the US and is upset that you are treated like a second class citizen by those companies? Well, you're damn right to be upset because you know you're paying the same amount of money as other users but getting a lot less for it which is just not fair. You are being discriminated…

Asynchronous F# workflows in NancyFx

I have been playing with F# quite a lot recently and to be honest I started to really like it. Besides the fact that F# is a very powerful language it is a lot of fun too! As a result I began to migrate one of my smaller web services from C# and ASP.NET MVC 5 to F# and NancyFx . Nancy as a .NET web framework works perfectly fine with any .NET language, but has certainly not been written with F#…

Filtering the AWS Service Health Dashboard

If you run anything on Amazon Web Services in production then you probably know the AWS Service Health Dashboard very well. 
 Sometimes when you experience a service disruption you might find yourself scrolling through the page and look for an update for one of your affected resources and then you probably wish that the icons were a little bit more distinguishable between healthy and…

Automating CSS and JavaScript minification in ASP.NET MVC 5 with PowerShell

When I started building this blog I kept things very simple in the beginning. First there was nothing but my Hello World blog post and only later when I had more content I added more features over time. It didn't take me very long before I had to think about minifying static content such as CSS and JavaScript files to speed up page load times for my readers. 
 Minifying a CSS file is one of…

CircleCI build history charts and NuGet badges by Buildstats.info

Quick update on Buildstats.info . Two weeks ago I added CircleCI to the list of supported CI systems for the build history chart and last weekend I implemented a new badge for NuGet packages too. 
 CircleCI is the third continuous integration system which is supported by the build history chart now. AppVeyor and TravisCI are the other two. If you have a public open source project which is…

Don't dispose externally created dependencies

Today I wanted to blog about a common mistake which I often see during code reviews or when browsing open source projects in relation to the IDisposable interface. Heck, even Microsoft got it wrong when they wrote on how to implement the UnitOfWork pattern in an ASP.NET MVC application. 
 What I mean is this, in a very simplified way: 
 public interface IRepository : IDisposable
{
…

SHA-256 is not a secure password hashing algorithm

SHA-256 is not a secure password hashing algorithm. SHA-512 neither, regardless of how good it has been salted. Why not? Because both can be computed in the billions per minute with specialised hardware. If you are surprised to hear that you should continue reading... 
 What makes a good password hashing algorithm? 
 A password hash is the very last line of defence. Its only purpose is to…

Understanding ASP.NET Core 1.0 (ASP.NET 5) and why it will replace Classic ASP.NET

ASP.NET has quite some years on its shoulders now. Fourteen years to be precise. I only started working with ASP.NET in 2008, but even that is already 8 years ago. Since then the framework went through a steady evolutionary change and finally led us to its most recent descendant - ASP.NET Core 1.0 . 
 ASP.NET Core 1.0 is not a continuation of ASP.NET 4.6. It is a whole new framework, a…

ASP.NET 5 like configuration in regular .NET applications

ASP.NET 5 is Microsoft's latest web framework and the new big thing on the .NET landscape. It comes with a whole lot of new features and other changes which makes it very distinctive from previous ASP.NET versions. It is basically a complete re-write of the framework, optimized for the cloud and cross platform compatible. If you haven't checked it out yet then you are definitely missing out! 
…

Running NancyFx in a Docker container, a beginner's guide to build and run .NET applications in Docker

The quiet Christmas period is always a good time to explore new technologies and recent trends which have been on my list for a while. This Christmas I spent some time learning the latest ASP.NET framework , in particular how to run ASP.NET 5 applications on Linux via the CoreCLR and how to run a regular .NET 4.x web application via Mono in a Docker container. The latter is what I am going to talk…

Diagnosing CSS issues on mobile devices with Google Chrome bookmarklets

Yesterday, when I was browsing my blog on my mobile phone I discovered a small CSS issue on one of the pages. One of my recent blog posts had a horizontal scrollbar which shouldn't have been there. A page element caused an overflow, but it was not visible which element was responsible for it. 
 When I tried to diagnose the issue on my computer I struggled to replicate it to the same extent as…

Design, test and document RESTful APIs using RAML in .NET

Building a RESTful API is easy. Building a RESTful API which is easy to consume is more difficult. There are three key elements which make a good API: 
 
 Intuitive design 
 Good documentation 
 Documentation which actually matches the implementation 
 
 Intuitive API design is obviously very important, but equally important and often neglected is good and complete…

How to make an IStatusCodeHandler portable in NancyFx

I am currently working on several micro services using the NancyFx framework with many projects sharing the same underlying architecture. 
 The IStatusCodeHandler interface is one of the core infrastructure components which is used by many Nancy projects to intercept and process a Nancy context before the final response gets returned to the client. 
 Having a few identical implemenations…