Skip to content

The Weird and The Wonderful

It was the best of code, it was the worst of code. Coding Horrors, Worst Practices, and flashes of brilliance

This category can be followed from the open social web via the handle the-weird-and-the-wonderful@forum.codeproject.com

1.8k Topics 20.7k Posts
  • Does this scare anyone else?

    design com graphics iot tutorial
    3
    0 Votes
    3 Posts
    30 Views
    honey the codewitchH
    It is at the beginning of the struct and it is used as a discriminator. And yet it seems extremely accident prone, and I should add the docs do not clarify this. At worst there should be, IMO, a function to initialize the structure. At best, there should actually be two lv_img_set_src() functions - one for paths, and one for lv_img_dsc_t structs. Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
  • WTF-8

    question csharp database algorithms data-structures
    12
    0 Votes
    12 Posts
    104 Views
    P
    honey the codewitch wrote: they can't recursively decode UTF-8 without breaking the spec. I don't see how you arrive at that conclusion. honey the codewitch wrote: not .NET's place to satisfy your requirement I agree. honey the codewitch wrote: would break the spec In what way exactly? Particularly if the caller has control over whether or not it does. But you mentioned something about writing control characters in UTF-8 -- which include carriage-return, line-feed, form-feed, etc. -- so I don't understand what you meant that it would break UTF-8. Whatever situation you are trying to communicate, I am sure .net can do it already, and it doesn't "break UTF-8".
  • What the hell gcc?

    design com graphics iot
    24
    0 Votes
    24 Posts
    341 Views
    0
    Try it ;) I think it simply informs the compiler 'you are aware' about a maybe not safe conversion ...
  • .NET Core & (auto)binding: Is it a bug?

    csharp javascript asp-net dotnet wpf
    6
    0 Votes
    6 Posts
    62 Views
    J
    Gonna guess this is the "(almost)". Heh.
  • Looking at the very topmost line ...

    question
    10
    0 Votes
    10 Posts
    75 Views
    Richard Andrew x64R
    If the number of privileges exceeds 32, then just use a bigint! :-D The difficult we do right away... ...the impossible takes slightly longer.
  • SQL (Transact-SQL) needs a proper FOR loop!

    database help
    13
    0 Votes
    13 Posts
    146 Views
    J
    Disagree a bit, and do not care a lick that it defies popular wisdom. Working with input/output as close to the source/destination tends to mean both less traffic and faster. I feel this 'wisdom' is somewhat rooted in the same vein as folk who love NoSQL because it means they don't have to learn databases.
  • Blessed endian mismatches collide with progress

    design c++ css com graphics
    13
    0 Votes
    13 Posts
    132 Views
    J
    One little, two little, three little Indians, Six little, five little, four little endians...
  • Untested Backups with IonicZip

    help learning c++ database sql-server
    3
    0 Votes
    3 Posts
    38 Views
    K
    MarkTJohnson wrote: how long were you "puckered"? I would have been puckered if I had truly needed those backups. As it was, I went through a few emotions: 0: Surprise! Your false sense of security has just been shattered...You are not as clever as you thought you were, and your backups are shite! :omg: 1: Doubt...Hmmm what about the other 20 daily backups? Are they all shite? :confused: 2: Relief...Whew! The other backups are fine. Just these two from this server are crap. 3: Annoyance. I just want to get on with work. Now I have to log on Azure, allow myself to RDP into that box, get raw unzipped backups, and start troubleshooting the problem. 4: Sleuth Mode...the problem seems to be with the zip lib...maybe a bug...maybe fixed? Go get the latest version to find that it's being deprecated, and the last version is 6 y/o. Whatever, I'll try it. 5: Disappointment. :sigh: Nope that didn't work, time to open the project and debug with one of the dbs having the issues. 6: Excitement. :-D Yay! I was able to replicate the issue...now on to understanding. 7: Discovery: A well-phrased search put me on the right track...a known issue with an easy fix. 8: Humility: I'm sure I would have discovered this eventually, but I put a lot of faith in an automated process without actually verifying the outputs, which was the only way to detect the problem. Lesson learned! :laugh: "Go forth into the source" - Neal Morse "Hope is contagious"
  • Given enough eyeballs - a Sunday rant...

    com help question announcement lounge
    9
    0 Votes
    9 Posts
    70 Views
    Mircea NeacsuM
    You succumbed to the the power of the dark side[^] :laugh: Mircea
  • 0 Votes
    4 Posts
    34 Views
    honey the codewitchH
    I've always understood C# to automatically "fill in" any empty method slots with methods of the same name. Contrast this with VB.NET where you must (AFAIK) always explicitly tell it which interface it implements. Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
  • Country code

    com question
    5
    0 Votes
    5 Posts
    36 Views
    T
    PIEBALDconsult wrote: Requiring the country code seems unusual (for a site in the U.S.) What do you mean - is there anything outside the USA? Do they have telephones as well? Really?? ;-) -- but what would prompt a web developer to make it an elephanting drop-down?! I guess that even a lot of Europeans do not know the phone country code of their homeland. I guess that a lot of USA citizens, if they had to call home when on a dangerous vacation trip to The Primitive World outside USA, would go straight ahead with their US number, unaware that they have to prefix it with +1. On a landline phone, that might be 001, or 0951 (that's in Norway, up until 20-30 years ago), or something else. Even when told about the '+1', many would not know the meaning of the 1, but view the whole prefix as a deficiency of the country's phone system. So, I think this drop down list, displaying both the code, so that users learn it, and the name of the country, for those who are not sure about the code, is a really good idea. It is not possible to see from the screenshot if you are allowed to type the code directly without using the pulldown list. Users who know their country code with 110% certainty would most likely prefer that - but maybe their memory has a bit error, or they make a typing mistake, so they specify an unused code or the code of a completely different country. The pulldown list is one way for the software to ensure that a valid number is entered. And, the selected value can display the country: Users from other countries might leave a '+1' untouched without noticing. They are much more likely to notice '+1 (US)': But I am not in the US! The UI isn't really that bad, in my eyes. I think what I saw yesterday was far worse: I sent a notice through the web pages of the Norwegian Automobile Owners Association. The form had entries for name, email, and membership number: The membership number field was a spin control starting at -1. I did not let it spin up to my number (a value for the field was not mandatory) :-) Religious freedom is the freedom to say that two plus two make five.
  • Am loving the fallout series

    design com graphics game-dev iot
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Standards? Eat your heart out, Randall

    com question
    7
    0 Votes
    7 Posts
    58 Views
    T
    There may be an RFC for that tomorrow. Religious freedom is the freedom to say that two plus two make five.
  • .bash_history makes me happy, how about you?

    linux csharp asp-net dotnet tutorial
    6
    0 Votes
    6 Posts
    50 Views
    1
    raddevus wrote: I am vim-weak and don't know how to exit vim How to exit vim: Try to turn off the computer. If you cannot - buy the new one. Turn on the computer and reinstall OS.
  • Classic

    csharp
    30
    0 Votes
    30 Posts
    347 Views
    T
    This might be even better. After all, it's the way I do it in my head. :laugh: bool IsNumberEven(int number) { string sNumber = number.ToString(); string sLastDigit = sNumber[sNumber.Length - 1]; if(sLastDigit == '0' || sLastDigit == '2' || sLastDigit == '4' || sLastDigit == '6' || sLastDigit == '8' ) { return true; } else { return false; } } Tom Clement articles[^]
  • 0 Votes
    4 Posts
    32 Views
    Graeme_GrantG
    honey the codewitch wrote: Edit: IT WORKS! You just have to close VS and reopen it for it to actually take effect. Congrats and thanks for the tip! Graeme "I fear not the man who has practiced ten thousand kicks one time, but I fear the man that has practiced one kick ten thousand times!" - Bruce Lee
  • Command line fun in .NET

    design help csharp com graphics
    3
    0 Votes
    3 Posts
    25 Views
    honey the codewitchH
    A regex is kind of complicated for that. I prefer using my looping dual state state machine (state is just represented by the isQuote bool. The technique i presented above is used in the latest GitHub bits of the project here: Program.Base: Drop In Command Line Application Functionality for Your Projects[^] It does: Command line parsing, using screen generation, error handling, file and argument object lifetime management, word wrapping (necessary for using screen anyway so i exposed it) stale file checking and progress reporting. It's a drop in file with no dependencies, and is targeted to .NET Framework as well as the newer stuff. (I have two files for it but the only difference between them is the .NET Framework (DNF) file does not have #nullable disable at the top, which shuts up nullable reference type warnings in the newer C#. You just pick the one you need. If you can get it approved by your work you're more than welcome to it. I developed it because I got sick of writing essentially the same code over and over again. This is less work than that System.CommandLine stuff, and does more. Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix
  • Microsoft: Saving you time by making you type more

    design css com graphics iot
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Microsoft example includes obsolete code: Why?

    csharp com security cryptography json
    3
    0 Votes
    3 Posts
    22 Views
    raddevusR
    That's a good find and I appreciate you providing the link here. Once I read that, I remembered having to make a code change related to it back in 2021/2 because this functionality change was being reported ahead of time. It's too bad they didn't make that link more conspicuous in the Import method docs. Thanks again
  • Found an interesting algorithm

    algorithms csharp c++ help announcement
    3
    0 Votes
    3 Posts
    28 Views
    Greg UtasG
    honey the codewitch wrote: I don't understand the results I'm getting. This reminded me of a comment that I read long ago: quote: Abandon hope all ye who look at this code. Not even its author knows how it works, or why. The code in question sent instructions to a remote virtual stack machine for which proper documentation no longer existed. It was partially written by trying various inputs and observing the behavior of the black box. :-D Robust Services Core | Software Techniques for Lemmings | Articles The fox knows many things, but the hedgehog knows one big thing.