Tandy
Explore posts from serversRegex negative lookahead not working
I am trying to use regular expressions to detect URLs in dynamic text (I know). I have a pretty good working example, but I'm struggling to filter out certain HTML codes that could be present in the dynamic text. For example, the current regex is capturing
google.com 
as the URL for the following text: visit us at google.com for more information
. I'd like to prevent that and only match on google.com
. I tried to add a negative lookahead to remove matches on  
, but it's not working. Can anyone help?
https://regex101.com/r/WJ6y2x/25 replies
Fill in missing dates in list?
For simplicity, suppose I have a list of nullable dates, and I need to reverse engineer the dates that are missing. The tricky thing is that it's not simply filling in between the first date and the last date, but the data can be monthly, quarterly, etc, and so the list of dates is not consistent.
so something like
[2022-10-03, null, null, 2022-12-31, null, null, 2023-03-31]
should be filled in with monthly data like [2022-10-03, 2022-10-31, 2022-11-30, 2022-12-30, 2023-01-31, 2023-02-28, 2023-03-31]
but there could be cases where the first few items in the array are empty, or the gaps between data is smaller, etc.
I don't need an answer just need a nudge in the right direction. There's currently a solution in place for this but it's difficult to follow and there are a few bugs that would probably be fixed by an alternative, more robust solution3 replies
Validate PDF Accessibility via dotnet?
Are there any dotnet libraries or tools to validate a PDF file for accessibility compliance (WCAG)? Alternatively, is there a tool outside the dotnet ecosystem that you've used? Given a PDF, I need to create a list of accessibility issues (color contrast, tags missing, etc). Ideally, it would be MIT or other permissive license, but also open to paid options
2 replies
❔ WYSIWYG model storage - hierarchy table(s) vs JSON column
Using EF + SQL Server, I need to support saving a
Template
which consists of Page
s and Element
s maintained via a WYSIWYG editor. Element
is an abstract class with derived classes like Section
(which corresponds to a div), Text
, Image
, and Chart
, each with their own unique properties. A Section
can contain another Section
, for example, so the data model needs to be hierarchical.
Initially, I considered using a hierarchy table where an Element
had an optional parent - public abstract class Element { public int? ParentElementId { get; set; }
. It's easy enough to query and hydrate into a read model suitable for consumption, but my assumption is that it would be rather complex to persist changes for the whole disconnected graph since users can add/remove pages, add/remove elements, move an element from one section to another (even across pages), update all style properties of a given element, etc.
I was considering using a JSON column for the whole hierarchy instead since it's very unlikely we'll need to query any of that info (and we can use SQL Server JSON support if absolutely necessary) and it would be incredibly easy to save the whole hierarchy, just re-assign a single variable to the hierarchy constructed from the WYSIWYG editor.
I've considered the performance/storage implications of JSON, and the discipline required to maintain a backward compatible model (since we'd be giving up migrations in favor of JSON). I'm fine with both of those tradeoffs. Is there anything I'm overlooking? Anything about working with that disconnected graph with EF Core that could make a relational model easier? Has anyone solved this problem before with JSON columns?7 replies
❔ Multi-tenancy - database per tenant - which database(s) to store Users?
We're using Auth0 for authentication. A given User could have access to multiple tenants. I'm envisioning a
Catalog
database with Tenants
table and Users
table, as well as a UserTenants
table that links the two.
However, I imagine that the tenant databases will require user information, like first name, last name, email, etc, for business logic. So does it make sense to have a Users
table in both the Catalog
database but also in each tenant database?15 replies
❔ Playwright dotnet - Duplicate 'Content' items were included.
A colleague has installed Playwright dotnet in our dotnet API project and now Omnisharp is throwing the following error (and failing to provide any intellisense in the whole solution):
Duplicate 'Content' items were included. The .NET SDK includes 'Content' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: '/Users/me/.nuget/packages/microsoft.playwright/1.32.0/buildTransitive/../.playwright/node/LICENSE'I may be dense, but from the options provided, it's not clear what exact csproj changes I should be making. It seems like I need to exclude any content provided from Playwright, but it's not clear how to do that, especially considering this Nuget package is outside the context of my project. Any suggestions?
4 replies
❔ Does BlockingCollection TryTake free the consuming thread to do other things?
I'm not too knowledgeable about multi-threading. But I'm trying to use
BlockingCollection.TryTake
to consume messages like so:
While _queue.TryTake
is waiting for an item - is it occupying the thread such that other API functions will be impacted? My fear is that I have to create n number of these collections. If each one is permanently blocking a thread, then the server will run out of resources. But if the thread is freed to do other things - like process incoming HTTP requests - before being signaled then I should be safe.
The documentation is a little confusing, but I'm hopeful that the "blocked thread" is free to do other work:
The thread is then free to do some other useful work before trying again to access the collection.https://learn.microsoft.com/en-us/dotnet/standard/collections/thread-safe/blockingcollection-overview#timed-blocking-operations
2 replies
❔ How to pause BlockingCollection consumption?
I'm currently enumerating through a
BlockingCollection
(with an underlying ConcurrentQueue
backing class) using GetConsumingEnumerable()
. But I have to pause execution based on some logic, leaving items on the queue, until some other business logic resumes execution. Anyone know the best practice for that? Do I have to bypass GetConsumingEnumerable()
and instead write something like below, but adding pause logic?
3 replies
Remote robot state and commands - best patterns, practices?
I have a use case where I'm able to remotely control a robot via a SPA frontend and dotnet API + robot API. The UI can dispatch actions like undock, dock, power off, sit, stand, move, rotate (with joysticks). But commands require state and state transitions to occur before they're valid. The UI should be aware of these state transitions so buttons can be disabled, the user can be notified that something is happening, etc. I can access the robot state by polling an API or I can embed C# code on the robot that runs every tick and pushes updates to our API when things change.
I was considering putting a singleton class which holds the current state and owns state transitions using state pattern on the robot C# payload. Then all our API calls would go through that class, which would then broadcast events back to our API when things changed. But I have almost no experience in this domain. Is there some framework or design pattern that's standard for this pattern? Just some things to Google is fine if anyone knows!
1 replies