โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayCodeProject Latest postings for The Lounge

A truck loaded with thousands of copies of Roget's Thesaurus crashed yesterday losing its entire load

Witnesses were stunned, startled, aghast, taken aback, stupefied, flummoxed, gobsmacked, confused, shocked, rattled, paralyzed, dazed, bewildered, mixed up, surprised, awed, dumbfounded, nonplussed, flabbergasted, astounded, amazed, confounded, astonished, overwhelmed, horrified, numbed, speechless, and perplexed.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GitHub website question

Github has a nifty feature where you can just Open In Visual Studio and it will open VS and clone your repo for you.

I like this magic, but thing is it used to say Open In Visual Studio Code and well over half my projects are in VS Code.

Does anyone know how to get it back? Preferably I'd like both, but if nothing else, I just want it to work with VS Code.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

There are many gotos, but these ones are mine

Gotos are frowned on. You should not use gotos. Long live gotos.

Until someone comes up with a better/faster/concise way of expressing the following DFA state machine (presented in part) I will continue to defend the use of gotos, even if their use cases have gotten significantly more narrow as progress has marched on.

When you need them, there is no better tool.

C#
internal sealed partial class JsonStringRunner : FAStringRunner {
        private FAMatch NextMatchImpl(string s) {
            int ch;
            int len;
            int p;
            int l;
            int c;
            ch = -1;
            len = 0;
            if ((this.position == -1)) {
                this.position = 0;
            }
            p = this.position;
            l = this.line;
            c = this.column;
            this.Advance(s, ref ch, ref len, true);
            // q0:
            // [\t-\n\r ]
            if (((((ch >= 9) 
                        && (ch <= 10)) 
                        || (ch == 13)) 
                        || (ch == 32))) {
                this.Advance(s, ref ch, ref len, false);
                goto q1;
            }
            // [\"]
            if ((ch == 34)) {
                this.Advance(s, ref ch, ref len, false);
                goto q2;
            }
            // [,]
            if ((ch == 44)) {
                this.Advance(s, ref ch, ref len, false);
                goto q9;
            }
            // [\-]
            if ((ch == 45)) {
                this.Advance(s, ref ch, ref len, false);
                goto q10;
            }
            // [0]
            if ((ch == 48)) {
                this.Advance(s, ref ch, ref len, false);
                goto q11;
            }
            // [1-9]
            if (((ch >= 49) 
                        && (ch <= 57))) {
                this.Advance(s, ref ch, ref len, false);
                goto q17;
            }
            // [\:]
            if ((ch == 58)) {
                this.Advance(s, ref ch, ref len, false);
                goto q18;
            }
            // [\[]
            if ((ch == 91)) {
                this.Advance(s, ref ch, ref len, false);
                goto q19;
            }
            // [\]]
            if ((ch == 93)) {
                this.Advance(s, ref ch, ref len, false);
                goto q20;
            }
            // [f]
            if ((ch == 102)) {
                this.Advance(s, ref ch, ref len, false);
                goto q21;
            }
            // [n]
            if ((ch == 110)) {
                this.Advance(s, ref ch, ref len, false);
                goto q26;
            }
            // [t]
            if ((ch == 116)) {
                this.Advance(s, ref ch, ref len, false);
                goto q30;
            }
            // [\{]
            if ((ch == 123)) {
                this.Advance(s, ref ch, ref len, false);
                goto q32;
            }
            // [\}]
            if ((ch == 125)) {
                this.Advance(s, ref ch, ref len, false);
                goto q33;
            }
            goto errorout;
        q1:
            // [\t-\n\r ]
            if (((((ch >= 9) 
                        && (ch <= 10)) 
                        || (ch == 13)) 
                        || (ch == 32))) {
                this.Advance(s, ref ch, ref len, false);
                goto q1;
            }
            return FAMatch.Create(10, s.Substring(p, len), p, l, c);
        q2:
            // [\0-\t\v-!#-\[\]-\x10ffff]
            if ((((((ch >= 0) 
                        && (ch <= 9)) 
                        || ((ch >= 11) 
                        && (ch <= 33))) 
                        || ((ch >= 35) 
                        && (ch <= 91))) 
                        || ((ch >= 93) 
                        && (ch <= 1114111)))) {
                this.Advance(s, ref ch, ref len, false);
                goto q2;
            }
            // [\"]
            if ((ch == 34)) {
                this.Advance(s, ref ch, ref len, false);
                goto q3;
            }
            // [\\]
            if ((ch == 92)) {
                this.Advance(s, ref ch, ref len, false);
                goto q4;
            }
            goto errorout;
        q3:
            return FAMatch.Create(9, s.Substring(p, len), p, l, c);
        q4:
            // [\"\/\\bfnrt]
            if (((((((((ch == 34) 
                        || (ch == 47)) 
                        || (ch == 92)) 
                        || (ch == 98)) 
                        || (ch == 102)) 
                        || (ch == 110)) 
                        || (ch == 114)) 
                        || (ch == 116))) {
                this.Advance(s, ref ch, ref len, false);
                goto q2;
            }
            // [u]
            if ((ch == 117)) {
                this.Advance(s, ref ch, ref len, false);
                goto q5;
            }
            goto errorout;
        q5:
            // [0-9A-Fa-f]
            if (((((ch >= 48) 
                        && (ch <= 57)) 
                        || ((ch >= 65) 
                        && (ch <= 70))) 
                        || ((ch >= 97) 
                        && (ch <= 102)))) {
                this.Advance(s, ref ch, ref len, false);
                goto q6;
            }
            goto errorout;
        q6:
            // [0-9A-Fa-f]
            if (((((ch >= 48) 
                        && (ch <= 57)) 
                        || ((ch >= 65) 
                        && (ch <= 70))) 
                        || ((ch >= 97) 
                        && (ch <= 102)))) {
                this.Advance(s, ref ch, ref len, false);
                goto q7;
            }
            goto errorout;

Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Well that was satisfying.

IP-API.com - Geolocation API[^] is a little web service to get a bunch of info about where you're at based on your IP (or an IP you give it)

I use it for my little internet clocks to fetch the timezone since they don't have GPS.

It can return values in CSV, JSON or other formats.

Arduino already has stream.readStringUntil(',') so parsing CSV seemed trivial. For quite awhile I was doing that.

On a lark, I decided to swap it out to use JSON and my little JSON pull parser for embedded.

The resulting code is actually a bit shorter than the CSV approach. And it doesn't take a lot of RAM because it's a pull parser (like XmlReader), and not a DOM

I'm leaving it in JSON

I love when stuff like that happens.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Kinda wish I knew more about "AI"

But I can't be arsed to learn it.

I do have an idea though - using an LLM to do code synthesis.

Code synthesis is similar to code generation, but unlike code generation code created via code synthesis looks as though it was written by a human being.

This is particularly important for things like parser generators, where generated code tends to be rigid. For example - a generated LL(1) parser always matches greedy while a hand rolled recursive descent parser will switch between greedy and lazy consumption as the situation calls for it. The end result is more compact and more efficient.

I don't recommend using parser generators because of the code they produce - unless you like source files in the hundreds of thousands of kilobytes or even megabytes. Code synthesis stands a good chance of changing that.

Things like Github Copilot can produce code. Code synthesis seems like this functionality.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

My favorite C# project

Visual FA is the project I've most enjoyed in C# in recent years. But it's finished.

Not only is it finished, it's fairly polished. It slices and dices state machines, you can render them to graphs, to and from regular expressions, and analyze them in a myriad of ways. You can generate (optionally dependency free) matching code with them, or compile directly to an assembly. The matchers can stream from TextReaders or match off strings.

I have nowhere else to go with it. It has been a long time since I've truly stuck a pin in a project as "completed for the foreseeable future" but after like 5 articles and 2 tips, plus the code itself and it's associated nuget packages I have nothing left to do.

I'm glad. But I also wish there was more for me to do. I really enjoyed this project.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

I so want to use C#s new(ish) source generator tech for more things

The trouble is, I'm lacking inspiration, and things like Entity Framework, XML serialization (which is crap, but it's there), and other obvious applications of it have already been done to death, or are produced my microsoft, and in everybody's regular rotation such that a contribution in that arena would be at best futile, and at worst annoying.

I wrote a great lexer generator that uses it. But now what?

I've talked myself out of generating parsers. Short of some sort of AI code synthesis, they are too bloated and restrictive to be very practical in the real world.

I thought about generating component model stuff, like the common component property changed event patterns on classes but the core stuff really involves UI components, and it seems like .NET UI is still all over the place. I want the dust to settle before I commit to something like MAUI.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Doctor: "I have good news and bad news"

Patient: "OK...er... give me the good news"
Doctor: "you have a fatal cancer and have 24 hours to live"
Patient: "Doc, if that's the GOOD NEWS, what's the BAD news?"
Doctor: "I should have called you yesterday"
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Fallout update woes

I'm glad I have two fallout machines. my lappy is still pre-update. Fallout 4 update broke F4SE at least temporarily. F4SE uses injection techniques to modify the in memory footprint of the fallout executable in order to extend it. You can then write mods for the game that take advantage of those extensions, and many authors do.

As a mod author, the update caused me some anxiety. I wasn't sure what all it would break. Fortunately my major mod (High Level Perks) survived the update, but my Brews mod will no longer work until F4SE is updated. Overall it could have been much worse.

For me though, the real pain is in playing. I can no longer uncap my framerates past 60 without breaking the game (120FPS runs twice as fast in game D'Oh! | :doh: ) That not only means I went from 240FPS to 60FPS in game (it matters) my loading screens are framerate capped as well and thus take 5 times as long as they used to cap at 350FPS.

Anyone else play? How do you feel about the update?
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

I forgot how to ride a bike

I'm crylaughing at myself. I forgot how to enforce operator precedence in parsing code.

I've written it countless times. I have no idea how I forgot. It should be practically muscle memory at this point.

Next I will forget my birthday. Unsure | :~
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

I found a terrible bug (rubber duck session)

Update: I have since fixed the terrible bug! Big Grin | :-D

I'm posting this because when I rant about these things to you folks I tend to come up with a solution, and I've been at this since last night. Skip it if you'd rather not be used like that. Smile | :) It's not a programming question, though I will describe the problem. There's not really code as such.

[\r\n]* (zero or more carriage returns or line feeds) yields a proper set with two transitions

[^\r\n]* (zero or more of anything but carriage returns or line feeds) matches any characters (incorrect). The set has one range with all unicode code points in it, and when you invert the set and then minimize the result it will actually crash.

[^\n\r]* (functionally same as above) but works properly, yielding a set of all except carriage return or line feed. This despite the sets ostensibly being sorted.

I thought I narrowed it down to a normalization routine I have that takes overlapping ranges and merges them. That still might be part of the problem. However, I removed the call to the normalization routine and it still fails my test, so something else is at fault further downstream.

One of the issues is this is in live code - with deployed nuget packages and codeproject articles, and I only just discovered it. So there's some pressure on me to fix it, albeit self imposed. Unsure | :~
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

The way software is pasted together these days

Glued together from a web of dependencies, development "organized" via agile methodology.

How long before we just fire software packages out of a t-shirt cannon?

"Hold my beer, I've got a version update to deploy"

I am really uncomfortable with the state of software development these days. Dependency hell didn't used to be a distributed problem.

I suppose I'm just getting old and this is the new normal. Eventually we'll *need* AI just to keep our import hierarchies straight. Unsure | :~
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Am loving the fallout series (on Prime)

I'm only on episode one because my anxiety is such where I have to watch it in short bursts, but I'm super impressed so far.

The raiders were downright terrifying. In the game(s) they are soft targets I use to develop my character's combat skills. It's kind of disappointing actually. In the series, holy hell they are scary. That's more like it!

Anyway, even if you've never played the games, Walton Goggins is worth the price of admission. If you liked Westworld give it a shot. Some of the same people involved in making it, and it shows.

(forgive me if you saw my previous attempt at posting this - it went in the wrong section because I'm slow this morning)
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

On potentially enabling piracy and responsibilities in that regard

I recently wrote a tool primarily for my own benefit, as I long ago archived old shows of mine back when they were available on DVD and bluray, but the DVDs didn't necessarily survive all these years. (Many not available on streaming or I'd just stream)

I wrote a tool to go through and catalog my media with html, giving me a streaming-service-like interface to my media using static index.html files and such so it all works totally offline. That way I can browse on a trip or something where Internet is spotty or non-existent. It uses themoviedb.org's API to fill in things like show ratings, name, overview, still images, etc.

It got me thinking about my ethical obligations.

I thought about releasing it here, and I'm not sure I will, or if I do, I may cripple it.

The problem is, you could use it in tandem with a torrent client, and filebot to basically give you a much nicer way to pirate and organize what you downloaded, so much so that I fear that would actually be the primary use of my code.

And that got me thinking more broadly and philosophically about this issue.

So ultimately my question is where do you come down on the ethical responsibilities here from a philosophical standpoint - and I'm more thinking of this project as an example, but asking more generally? Am I obligated to say, cripple this project or otherwise not release it due to the piracy enabling factor? I don't know where I come down on this myself for sure, but I tend to lean toward me sharing some of that responsibility in terms of not enabling piracy even if my code wasn't intended for that.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

I'm finally getting the hang of this web stuff.

page screenshot[^]

Man this is rough. I have more respect for front end web development these days. It seems a lot more demanding than it used to be.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Why does it have to be horrible?

I've got a neat little project in the works.

It catalogs media and provides an HTML5/CSS3 interface to your media with a series of index.html files it dumps in your media folders.

The problem is CSS and HTML. What the hell happened? If it was confusing before, it's inexplicable now.

I like HTML5 for the most part. The trouble is CSS3. Oh wow. It can do so much, but describing what you want is like pulling your own teeth. It's awful. Who designed this mess? It's time for a rewrite.

Maybe I'm just bad at it, but it's stalling my whole project trying to get simple pages to work with many devices, and lay out accordingly.

Plus I need to pack a bunch of content into a tab-like interface and I really don't want to use JS for this. I figured out a way using radio buttons and display: none

I really wish I had somebody who was a CSS whiz I could work with on this. Meh.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Two mafia enforcers were walking in the woods

The first one said "I gotta admit, I'm scared out here."

The second says "You're scared? I have to walk back alone!"
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
โŒ
โŒ