Attach to Process

Thoughts and Notes on Software Development

Fire and forget template for C#/.NET to run something that you don't need to wait on and don't care about the results.

Task.Run(() =>
	//code goes here

In ReactJS, if ESLint says you cannot use inline arrow functions to pass in props in JSX, a solution is to wrap them with the useCallback hook.


Modals — can be used to add dialog or popup info boxes on your ReactJS app.

So using this library actually helped me solve my Azure Application Insights logging issue. The issue being, since I had a dateOfBirth object in my formData object, app insights would save it as an object, as opposed to something like dateOfBirth: 2024-04-16. The solution was to flatten the formData object so it will get logged properly in Azure App Insights.

Rendering the HTML string in React — short tutorial on how to render an HTML string in ReactJS/Gatsby.

Series: #DevNotes Tags: #CSharp #DotNet #Template #ReactJS #Azure #ApplicationInsights #Gatsby

Discuss... or leave a comment below.

There was a bug on my Archive Page Generator web app. Instead of creating URLs with the correct alias in there, for instance, it was hard-coding the word alias, like

It was an easy fix, though it wasn't the web app that was broken, but the API that it was calling. I mentioned in a previous post, that I was working on an API to power my Blazor WASM apps. The API is functional, it's out there on the internet, running as an Azure App Service. And it's the one with the bug that I just fixed a few hours ago.

So, the Archive Page Generator should be working correctly now. You no longer need to do a “search and replace” on the output to correct the URLs.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

To cause Azure to keep sending emails repeatedly for your Heath Check alerts, you need to uncheck the checkbox that says “Automatically Resolve Alerts”.

If you want to see what kind of error Axios throws, it is better to use console.log(error.toJSON()) than console.log(error). That's because the former option will list out all the properties from the error variable, while the latter option will only list out the error message itself.

Instead of adding todo comments, track it as a task so it doesn't get lost.

Source: TODO: Post an Article

Looking for a new way to do end-to-end testing on modern web apps? Check out Playwright. The tests are pretty easy to follow because it's basically a set of instructions written in code. So as you might have guessed, it's catered more to developers than non-technical folks.

I am going through the Pro ASP.NET Core 6 book. After trying to run the command libman install bootstrap@5.1.3 -d wwwroot/lib/bootstrap from page 72 (Chapter 4) of the book, I started getting the error listed below:

[LIB002]: The "bootstrap@5.1.3" library could not be resolved by the "cdnjs" provider

Turns out it was an issue with the library manager package that was installed. The fix is to install a newer one. More info can be found here:

Was looking for a way to add a list of objects to the appsettings.json file, then retrieve that list and turn them into something I can check against in a controller class. This answer works wonderfully.

React Hook Form — seems like a cool alternative form handler for React.

SQL to MongoDB Mapping Chart — good reference on how to write MongoDB queries based on expected SQL Server queries.

Reasons to blog if you're a software developer:

  • It helps you write better emails at work.
  • It helps you write better user stories and acceptance criteria.
  • It helps you communicate your ideas better.

If you're noticing a pattern there, it's all about being a better communicator. And you would want that, because that also helps you advance in your career.

Series: #DevNotes Tags: #Axios #ASPNetCore #Azure #Blogging #JavaScript #MongoDB #Playwright #React #SqlServer #Tests

Discuss... or leave a comment below.

My Archive Page Generator is back up and running. I've already updated the Archive pages for my other blogs. It seems to be working fine. Please give it a try and let me know if you run into any issues with it.

I did notice, during my testing, that it can fail on blogs with a huge number of posts. That's mainly because the API call times out at like the 1.7 minute mark. I'll see if I can fix that in the future. But for now, just getting the archive page generator working is a win. So I'll call it a day.

Tags: #Blazor #WriteAs

Discuss... or leave a comment below.

Version 1.2.1 of WriteAs.Net has been released.

This very minor update adds an interface for the WriteAsClient class, which opens it up for use with dependency injection in ASP.NET Core. This allows you to create a single WriteAsClient instance and re-use it when needed, making the caching additions from Version 1.2.0 much more useful.

This also frees me up to make better use of it in the API I'm working on.

You can install it via nuget: Install-Package WriteAs.NET -Version 1.2.1

Or via the .NET Core command line interface: dotnet add package WriteAs.NET --version 1.2.1

If you find any bugs or issues with it, please let me know. Thanks and y'all have a good night.

Tags: #DotNet #WriteAs #WriteAsNet

Discuss... or leave a comment below.

A number of people have been asking me about why the WriteAs Archive Page generators I made no longer work. They no longer work because of CORS restrictions on the API server. I'm trying to see if I can work around the restrictions on my Blazor WASM apps by going the Web API route.

Started working on an API for my websites

Tags: #DevLog#ASPNETCore #WebAPI #WriteAs

Discuss... or leave a comment below.

I seem to have a need for this every 6 months or so. So I'm putting it up on this site to make it easier for me to lookup.

This SQL Server query allows you to search for specific text inside all stored procedures on a database. The query will return the name of the stored procedure.

SELECT name 
FROM   sys.procedures 
WHERE  Object_definition(object_id) LIKE '%Search-Text%' 

Source: Search text in stored procedure in SQL Server

Tags: #SqlServer #Scripts

Discuss... or leave a comment below.

Cache Implementations in C# .NET — good blog post on implementing caching with .NET.

You're using HttpClient wrong and it is destabilizing your software — great blog post that told me that we should avoid the use of the “using statement” when working with an HttpClient instance. And that's because disposing it after say a one time use, like doing one API call and then immediately disposing, will leave open/pending socket connections. Do this often enough and you'll accumulate a number of those open/pending socket connections and that will slow down your app. The better approach is to use a single static HttpClient instance in your app.

The always-recent guide to creating a development environment for Node and React (with Babel and Webpack) — good guide to setting up a full-stack JavaScript development environment on your local, with an eye toward ReactJS.


Disclaimer: I'm not an expert in Git. This post is me trying to understand how it works, by trying to explain it to someone else. If I've said something wrong in this post, please don't hesitate to correct me by leaving a comment below or getting in touch with me.

So, in the past, I got confused by how a git revert command affected the merges. Part of it is due to my TFS background. But anyway, as it turns out, it works exactly how it is supposed to work, once you have a better understanding of how Git works.

A git revert rolls back a specific commit made in the repo. In addition to that, it adds a new commit to indicate that the previous commit was rolled back.

To better explain how this affects merges, I'll try to go over a scenario where I merge branches, then revert a commit in one branch, then try to merge the branches again. So here goes.

Imagine that I have two branches, develop and master. The develop branch was created based off the master branch, so they should have the same code in them.


What is a react helmet?

  • React helmet is a helper component that allows you to add data to the <head> section of a document or HTML page. It basically allows you to add <link> tags, <scripts> and other tags that goes into the <head> section of an HTML page.

Source: What is react helmet?

So react-helmet library didn't work for me, but this one did.

The equivalent of the npm install command in yarn is yarn without any parameters.

Was trying to help out someone on get a logo to show up beside their blog title. I learned that you can actually set the size of the background image using something like background-size: 150px;. Cool stuff.

Reference: Resizing background images with background-size

So last time I decided to just not show a header image for my Now Listening to... website on mobile screens. It was because I didn't know how to handle it. Well my easy solution turned out to be getting a smaller sized image to use as a header image. Then I was able to just add a css media screen entry that uses the smaller sized image.

Co-worker was running into Gatsby/Kentico/Grahpql errors with one of our projects. We pretty much had the same .env file and code base. Deleting the folder and downloading again didn't fix it. What worked for him was running the command npm cache clean --force.

Note: This is probably a dangerous command to run. Please research what it does before you try it out. I'm only sharing what worked for me and my team. But this was a last resort type of attempt to fix our errors.

To create a repository from an existing folder or files using Github Desktop, first you have to create the repository on the app itself. This is so that the app can create and initialize the folder on your drive. Then you can copy over the files into the folder that the app created. And then you're set.

To copy the _redirects file (or any other file for that matter) to the Output folder in Wyam, you can use the pipeline code below:

    // Copy redirect file to the output folder

Tags: #DevNotes #CSS #Gatsby #Github #NodeJS #ReactJS #Wyam #Yarn

Discuss... or leave a comment below.

Enter your email to subscribe to updates.