• About
  • Privacy Policy
  • Utilities
Darchuk.NET

JavaScript–toggling an item in a list with xor

June 1, 2018 by Robert Leave a Comment

I had a problem where I wanted to either remove an item from a list if it existed or add it to the list if it did not exist. A use case for this might be selecting which day(s) of the week you want: Behind the scenes, you might store this as a simple array: … [Read more…]

Posted in: JavaScript, Typescript Tagged: Array, JavaScript, js, list, lodash, toggle, ts, Typescript, xor

Automatically registering properties as implementations in AutoFac

May 25, 2018 by Robert Leave a Comment

In this post I talked about building out a configuration service that could be split into various areas of concerns so that each piece can be injected where it makes sense (without all of the noise of the rest of the configuration). Previously, the registration looked like this: Reflection With reflection, we can loop through … [Read more…]

Posted in: .NET Core, C#, IoC, Reflection Tagged: AutoFac, C#, Configuration, DI, IoC, Reflection

C# Mapping an Enum to a key value pair

May 18, 2018 by Robert 2 Comments

Enums are useful because they help you avoid magic numbers.  You can write your code in a way that is easy to read and understand from the human’s perspective, which, at the end of the day, is pretty important. Exposing enums on your Web API I want to share my enums with other things, notably … [Read more…]

Posted in: .NET Core, ASP.NET, C#, Typescript, Web API, Web Development Tagged: .NET, Angular, ASP.NET, C#, enum, Typescript, Web API

C# Printing Integers with leading zeroes

May 11, 2018 by Robert Leave a Comment

I’m writing this down because I find that I’ve googled it a couple of times and it always seems to take longer to figure out than I think it should. Say you have a number, but you want it to be padded with leading zeroes. So, 42 => 00042.  In my case, I was trying … [Read more…]

Posted in: C# Tagged: C#, format, leading, padleft, string, zero

TypeScript async / await

May 4, 2018 by Robert Leave a Comment

JavaScript is pretty dumb.  I know its the most popular language right now (due to the pervasiveness of browsers and other things that can run it), but, I mean, its just… dumb. Luckily TypeScript is pretty awesome.  It takes a lot of what makes JavaScript stupid and fixes it.  It makes it a lot more … [Read more…]

Posted in: Angular, AngularJS, Asynchronous, Concurrency, JavaScript, Typescript, Web Development Tagged: async, await, JavaScript, multi-threaded, promise, single-threaded, threading, threads, Typescript

Packing two small numbers into a single byte

April 27, 2018 by Robert 2 Comments

In this day and age, you don’t usually need to think about saving memory.  Need a whole number?  Just use an int!  Who really cares if the maximum value will never get above 255?  Using a byte is just archaic! Well, if you’re looking at optimizing network traffic or database usage, those bytes could add … [Read more…]

Posted in: C#, Generic Tagged: AND, Bit Shift, Bit Shifting, Bitwise, C#, OR

Angular 2+: Binding HTML Select ngModel to a number

April 20, 2018 by Robert Leave a Comment

I hate magic things.  In programming, I mean.  I try to avoid magic strings and magic numbers as much as possible because I can barely remember the thing I typed five seconds ago, let alone something that you have to maybe type five hours from now.  So, I tend to use a lot of enums … [Read more…]

Posted in: Angular, HTML, Typescript, Web Development Tagged: Angular, HTML, JavaScript, Option, Select, Typescript, Web Development

ASP.NET MVC — Unit Testing IActionResult

April 13, 2018 by Robert Leave a Comment

In the last post I talked about using and extending IActionResult to return your preferred HttpStatus code in your ASP.NET MVC controllers.  But how do you write unit tests that make sure that you’re returning what you expect?  Your controllers will return one of these: IActionResult There’s nothing on this interface that you can easily … [Read more…]

Posted in: .NET Core, ASP.NET, C#, MVC, Unit Testing, Web API, Web Development Tagged: .NET Core, ASP.NET, C#, Controller, IActionResult, MVC, unit testing, XUnit

.NET Core MVC Controller – Supporting more HttpStatusCodes in IActionResult responses

April 6, 2018 by Robert Leave a Comment

When I’m designing a RESTful API, I like to use the correct verbs for the correct actions, and return HTTP status codes that convey the correct message.  Sure, its easy to just return a 200 OK for everything, but its a little more useful to return 204 No Content if your client shouldn’t navigate away … [Read more…]

Posted in: .NET Core, ASP.NET, C#, MVC, Web API Tagged: C#, HttpStatus, IActionResult, MVC, REST, WebAPI

Capturing and Analyzing localhost to localhost traffic on Windows

March 30, 2018 by Robert Leave a Comment

Recently I had an issue where I was trying to create a stubbed/mocked version of a SOAP service locally.  I ran my web application, my client connected, my service got the request, sent back the response and… the client didn’t like it.  Not sure why… everything should be working.  So I wanted to look at … [Read more…]

Posted in: .NET Core, C#, Web Development Tagged: .NET, C#, capture, localhost, Packet, SOAP, TCP, Wireshark
« Previous 1 … 7 8 9 … 12 Next »

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall