VoidPointer
VoidPointer
CC#
Created by VoidPointer on 4/19/2025 in #help
One IEnumerable with 1 item mysteriously becomes empty after I query a second IEnumerable
The code I posted here was just proof of concept, getting to know the DataStax Mapper for Cassandra, and I had just copied from some legacy code without checking anything. That code not using parameters, I didn't think of them yet. I have now parameterized all the queries after seeing that the Mapper methods nearly all have an overload with a params object[] args parameter. These args are used to fill in ? placeholders in the query string.
6 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
One IEnumerable with 1 item mysteriously becomes empty after I query a second IEnumerable
I would have said the session's lifetime is only for the duration of the GetTableColumns method, but now on closer inspection I see ISession is an IDiposable, and I don't have a using for it. Just maybe that has something to do with it. I just ended up slapping ToList() on the end of the queries and everything works nicely now.
6 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
How to get indents for code formatting right in Scriban
For now, I'll gratefully accept the extra lines and close this post as it has helped me achieve what I wanted, the indentation is perfect now and I learned a lesson about it in Scriban.
12 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
How to get indents for code formatting right in Scriban
Hehe, I kind of do, but for these generated model classes I could easily overlook that because we never actually work on the class's source code.
12 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
How to get indents for code formatting right in Scriban
That looks like the neatest solution. I tried that once and gave up too early, because I was lazy and wanted a quick fix, but I think for future generator code I will use interpolation.
12 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
How to get indents for code formatting right in Scriban
I think I'm going to revert to T4 to see how it compares
12 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
How to get indents for code formatting right in Scriban
No description
12 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
Find all instances of a substring in a string
Looks like an interesting approach. I didn't fully grok it just reading it, but I'll play with it, thanks.
17 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
Find all instances of a substring in a string
I only wanted to rotate the grid once, to find all vertical instances, after already done horizontal, and then use a loop just for the diagonals.
17 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
Find all instances of a substring in a string
This for an AoC puzzle. I have to find the word XMAS in a large grid of letters, as follows:
This word search allows words to be horizontal, vertical, diagonal, written backwards, or even overlapping other words. It's a little unusual, though, as you don't merely need to find one instance of XMAS - you need to find all of them. Here are a few ways XMAS might appear, where irrelevant characters have been replaced with .:
I thought I'd use IndexOf horizontally, transpose the grid and use IndexOf horizontally again, but effectively for vertical occurences, then only use loops for the diagonals.
17 replies
CC#
Created by VoidPointer on 4/19/2025 in #help
Find all instances of a substring in a string
I imagined IndexOf would have been more optimized somehow than simple looping. Get the index of the word/substring, then call IndexOf again on the rest of the string after the last occurrence.
17 replies
CC#
Created by VoidPointer on 4/16/2025 in #help
How to get regex matches between optional start and end tokens
Yeah, thanks guys, I am doing it with a loop after all. Much simpler.
10 replies
CC#
Created by VoidPointer on 4/16/2025 in #help
How to get regex matches between optional start and end tokens
I wrote a Logo parser 1st year uni. That's about it
10 replies
CC#
Created by VoidPointer on 4/16/2025 in #help
How to get regex matches between optional start and end tokens
I've never written a real one in my 25 year career
10 replies
CC#
Created by VoidPointer on 4/16/2025 in #help
How to get regex matches between optional start and end tokens
It looks like it is supposed to. The problem statement says:
Only the most recent do() or don't() instruction applies. At the beginning of the program, mul instructions are enabled.
It doesn't mention surplus dos like yours at sit do()amet. The function that will process your string with the do() doesn't care about either of these two tokens.
10 replies
CC#
Created by VoidPointer on 4/16/2025 in #help
How to get regex matches between optional start and end tokens
It's for 1 part of an AoC day challenge. Wrting a proper parser would be a nice exercise, but maybe for another time. What I can do here is just use find instances of the 2 enclosing tokens and loop substrings between them. I am a little too regex fixated.
10 replies
CC#
Created by VoidPointer on 4/5/2025 in #help
Too Much Indentation When Rendering a Scriban Template
Thank you for all your very helpful suggestions. I couldn't get any of the whitespace control working, except for public class {{model.Name -}}, where the minus sign causes the extra blank line after the public class <className> , but for the indentation, I had to reduce that from 4 to 2 spaces in my template, so now the template renders 4 spaces, like I want, not the 8 it was rendering. It's somehow doubling the indent size. Scriban is by default set to autoindent, and the section of the docs about indentation says there is an option to set TemplateContext.AutoIndent to true, but I can't find how to apply the TemplateContext object to my tempate's parsing or rendering. I have cloned the Scriban source and will later hopefully figure this out with that as a reference, but for now I have things basically working and can get on with other stuff first, before bothering about the prettiness of my generated class.
4 replies
CC#
Created by VoidPointer on 3/31/2025 in #help
Guide or Reference for Quality UX With CLI Applications
I'm not at all looking for guidance on writing my own parser. That would be daft with those already available. I'm using Cocona Lite for my current project and am very happy with it. I was looking for the type of design advice that helps me choose between having e.g. a sort ascending option and a sort descending option, or have a sort direction argument. All the parsers I know make either way of doing this very easy. I'm concerned about the ergonomics of how the cli input is structured, not how to interpret it.
35 replies
CC#
Created by VoidPointer on 3/31/2025 in #help
Guide or Reference for Quality UX With CLI Applications
I have been looking at the various parsers as well, but will reconsider them in light of the design principles I found in that document. Thanks for you input.
35 replies
CC#
Created by VoidPointer on 3/31/2025 in #help
Guide or Reference for Quality UX With CLI Applications
I've previously used Spectre on this project and read their documentation on command parsing, and didn't find what I'm asking for. I found how to create commands, arguments, and options, but not how to uses these for optimum UX. The document on Command Line Interface Guidelines, at https://clig.dev, goes a long way to answer me, and if my question elicits nothing but criticism, I will close the post by reason of the one answer I have found myself. I was just hoping somebody might know about a similar resource to the single one I found.
35 replies