VoidPointer
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
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
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
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
do
s 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
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
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
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
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