Kyle Rego

Hello, welcome to my blog! I hope you find the information here helpful, but these posts should not be taken as 100% correct ways to do anything.

A picture of me
Me
Nov 9, 2024

Customizing the Trix editor in a Rails app (Action Text)

I noticed an issue yesterday in the production website for my Ruby on Rails app, Anki Books. I had recently migrated the website from being served from a laptop I...

Nov 3, 2024

Note on mixing constructor and object initialization syntax with EF Core entity classes

I made a small realization today about a different way to instantiate EF Core entities compared to what Iā€™ve been doing. In the past when defining constructor methods for my...

Nov 3, 2024

Note on finding element with Selenium WebDriver where two exist with the same ID (only one visible)

In the React app that is part of my project, there is a Bootstrap navigation bar with a logout button. For small screen widths, the bar collapses, hiding the navigation...

Oct 8, 2024

Service Locator Pattern to provide services to an abstract base class (ASP.NET Core)

Today I refactored a base class of service classes in an ASP.NET Core project, so that instead of two services (IHttpContextAccessor and IAuthorizationService in this example) being injected, an IServiceProviderWrapper...

Sep 18, 2024

Creating and signing in a user with ASP.NET Core Identity (in a service)

As I implemented resource-based authorization in my project recently, I also did the initial work of a demo feature, where clicking this ā€œTry it out!ā€ button will create a demo...

Sep 17, 2024

Resource-based authorization with polymorphic UserId model (ASP.NET Core, EF Core)

I added resource-based authorization to my ASP.NET Core project today; the approach that I used was to add a property UserId to an abstract entity class and then a requirement...

Sep 17, 2024

Mocking IHttpContextAccessor and IAuthorizationService in ASP.NET Core unit tests

Today I did some refactoring of an ASP.NET Core project with a controller-service-repository architecture to add resource-based authorization. As a result of this, my service classes are derived from an...

Sep 17, 2024

React context to track client-side authentication state

A problem I encountered recently was implementing tracking if the user is logged in in a React app that is not being used within a framework. I solved the problem...

Sep 4, 2024

Why LinkedIn won't let me link my project to a .lol domain name

Recently I bought the domain name larder.lol for $1.80 (with a $6 TLS certificate too), which I thought was a pretty good deal, and I set up my project web...

Aug 27, 2024

Controller, service, and repository layers using ASP.NET Core

Before learning .NET, I had a lot more experience with Ruby on Rails. One of the ideas I found in .NET development that I hadnā€™t encountered in Ruby on Rails...

Aug 5, 2024

Notes on continuous deployment for React and ASP.NET Core with GitHub actions

Recently I did some work to set up continuous deployment for a practice project (Larder), which is an ASP.NET Core web API with a React app frontend. This post is...

Aug 1, 2024

Try using a different port

While writing this post, a few times I considered a reader might say it does not show the best security practices, and I donā€™t necessarily disagree with that. In this...

Jul 17, 2024

A change of direction

As I move on from one project to the next, this post is to note some thoughts. No more Windows Subsystem for Linux For a while now the amount of...

May 26, 2024

What Anki Books looks like (one week later)

I scrapped a lot of the old color scheme and refactored to a simpler but overall better looking one. I also added some UI to the sources area of the...

May 24, 2024

ArticleElementRepository in AnkiBooks (refactor of OrderedElementRepositoryBase)

After writing the post yesterday, I was thinking about it some more, and wondering about the design. I also noticed some other small issues while writing the post: I didnā€™t...

May 23, 2024

OrderedElementRepositoryBase in AnkiBooks

In my app, an article can have many elements, and each article element has a unique ordinal position from 0 up to 1 less than the total number of elements...

May 22, 2024

Unit testing model validation in ASP.NET Core

This post shows an example of unit testing an ASP.NET Core model validation property. [RegularExpression] enforces the property matches the regex: public class ClozeNote : Card { [Required] [RegularExpression($".*{clozeMarkersRegex}.*", ErrorMessage...

May 21, 2024

ASP.NET Core resource-based authorization example

I spent some time understanding Resource-based authorization in ASP.NET Core today and implemented a simple example using it (also see Policy-based authorization in ASP.NET Core). This post is an alternative...

May 20, 2024

What Anki Books looks like

Iā€™m sure nobody has noticed this but I was trying to write a blog post every day. I wrote a draft of one today and didnā€™t really like it and...

May 19, 2024

Considerations when prerendering Razor components that request data in a Blazor Web App

Itā€™s common for a single page application to request data from an API. In my Blazor web app, the same Razor components that would request data over HTTP can be...

May 18, 2024

Serializing a list of derived class objects as a list of the base type (.NET)

I noticed a problem with serializing a list of objects that derive from a base class as a list of the base class where the data of the derived type...

May 17, 2024

Anki Books code overview

I wrote this, I accidentally deleted the file which had not been git added yet, and here I am writing it again. Anki Books has a design following clean architecture....

May 8, 2024

Namecheap TLS certificate gotchas

I reissued the TLS certification for my website today (ankibooks.io) which is the third time Iā€™ve done this TLS stuff with namecheap. There are two gotchas that wasted some of...

May 1, 2024

Drag and drop in Blazor with service

I tried a few ways today (about one month ago, but I wrote the beginning of this post, except for this part, a month ago) to implement a drag and...

Mar 29, 2024

Initial thoughts on Blazor

Iā€™ve been using Blazor for a bit now, itā€™s good so far I guess. I started with an ASP.NET Core web API and standalone Blazor WebAssembly app and it was...

Mar 22, 2024

Custom initialization logic for seeding a user in an ASP.NET Core web API

In the initial development of my app (an ASP.NET Core Web API and Blazor Webassembly client), Iā€™m currently using the in-memory database provider while Iā€™m mostly focused on learning Blazor....

Mar 5, 2024

Figuring out .ui files in an Anki add-on

When I was looking into adding some new features to an existing Anki add-on, I had to make sense of some files with the .ui extension that had some Qt...

Mar 2, 2024

Single Table Inheritance example in Rails

I used the STI pattern in my little Rails app today, the second time I used this in a Rails app and I really like the pattern. The first time...

Mar 1, 2024

One way to add and remove form fields on the fly in Rails

Rails provides some help for building a complex HTML form that can edit multiple objects/database records at the same time. However, it is not everything needed for a form that...

Oct 3, 2023

Issue building Anki in WSL2

I had the following error trying to build and run Anki from source following the instructions in development.md and linux.md using WSL2 with Ubuntu (using the ./run script after installing...

Jul 31, 2023

Putting code into Anki with code

I had an idea today while thinking about the difficulty of understanding a software system as it becomes larger and more complex. The idea was that it might be useful...

Jul 30, 2023

Action View permissions error after using Docker

I had an unexpected error today when starting my Rails app after experimenting running it inside Docker containers yesterday. The problem was due to the system user inside the Docker...

Jul 9, 2023

method_missing in the Anki Record gem

This post describes the ghost methods in the Anki Record gem that are defined with the Note#method_missing method. BasicObject#method_missing normally throws an exception when an object is called with a...

Mar 15, 2023

How to recurse through any parsed JSON Ruby object

Today I wanted to recurse through all of the values in some parsed JSON Ruby objects (I had a practical reason for this). I approached the problem in a very...

Dec 31, 2022

How to write Anki add-ons by example

I am going to explain the source code of two Anki add-ons that I wrote while I was in medical school, in the hopes that it will be useful to...

Nov 17, 2022

Launch School (review)

Launch School is a website that teaches a course on web development fundamentals (it is not a coding bootcamp). Instead of focusing on any particular frameworks, the focus is on...

Notes

Miscellaneous

This project is maintained by KyleRego