โŒ

Normal view

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

Wordle 757

Wordle 757 5/6*

๐ŸŸจโฌœ๐ŸŸจโฌœโฌœ
โฌœ๐ŸŸฉโฌœ๐ŸŸฉโฌœ
๐ŸŸฉ๐ŸŸฉโฌœ๐ŸŸฉโฌœ
๐ŸŸฉ๐ŸŸฉโฌœ๐ŸŸฉโฌœ
๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

When did they add this to Visual studio?

I've only just discovered "Peek definition"* - it opens a "floating window" into the code where that object is actually defined. Wow, but that's handy - I've been using "Go to Definition" for years and it's a pain because it opens in another window if it's in a different file (or you can use Window Split if it's in the same file).

How long has that been there? Probably years ... OMG | :OMG:

* Right click any class, variable, field, property, or method and select "Peek Definition" or use ALT+F12
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

Is ChatGPT worth the effort for a developer?

As a quick answer, Yes and No!

Their are tons of articles on it's worth, it's unworthiness etc. etc. There is a Q&A from this morning that turned out quite interesting IMO - How to take specific element from the first list , second list and those specific element add into third list[C#][^]

Richard MacCutchan and Graeme_Grant posted respective solutions, both of them works as a solution. Graeme did an excercise in using ChatGPT (as he mentioned in his post, just for fun and interest sake) and it actually returned a correct answer, for a change!

I then did a fun check by asking CHATGPT to check both blocks of code and show which block is -
1) The fastest generated output
2) Using the least performance
3) Is the most efficient

The returned answer were that it's own generated code were the worst performer. Richard's code were Block2 and Graeme's ChatGPT code were Block1 -
Quote:
Block 2 will run faster and use less performance compared to Block 1.

In Block 1, you are using a List<string> to combine the elements from two lists (a1 and a2) into a single list (combinedList). The code iterates over the length of the longer list (maxLength) and checks if the current index is within the bounds of each list before adding the element to the combinedList. Finally, it uses string.Join to concatenate the elements in combinedList into a single string.

In Block 2, you are using a StringBuilder (output) to build the combined string directly. The code iterates over the length of a1 and adds each element to the output. It also checks if the current index is within the bounds of a2 and adds its corresponding element. Finally, it prints the output using Console.WriteLine.

Block 2 is more efficient because it eliminates the need for an additional list (combinedList). It directly builds the string using StringBuilder, which is more efficient for concatenating multiple strings compared to repeatedly appending to a List<string>. Additionally, it does not involve the overhead of checking list bounds for every iteration, as it directly uses the lengths of a1 and a2 in the loop condition.


We do from time to time make use of ChatGPT, more as an exercise than a solution and we found, as mentioned in my comment at the psot, that you have to hammer the blue &^%$ out of it to return actual proper code. By hammering I mean that you ask question after question leading it into the expected answer until you can compile, test and run properly the desired returned code. The secret I think lies in the way or form the questions is submitted to ChatGPT, same as the way we Google for things. The better the question, the better the answer (there are many links on how to ask ChatGPT questions/give it instructions).

Problem is that we can see it in the Q&A (not all members mind you) where code is generated by ChatGPT, the user has no idea what the code means or why it does not work and they will post their question "It does not work!", "I'm new to programming", with a zillion lines of code posted, expecting a miracle working solution from other members. Confused | :confused:

So, to the question in the title - It is a great tool if you have a general idea of what the code should look like or function as. The time however in hammering it to return what is expected is just not worth the while, I can write the code, have a coffee, eat my lunch and then some in the same time trying to make ChatGPT work for me!. Is ChatGPT worth the effort for a developer? - IMHO, NO!

Hmmm, Win 11 update seems to have broken something

Hi All,
There was a Win 11 update which took an age on my home set up. It appears to have broken the old version of office I had (XP), I know it's out of date, I know really I do, But I didn't have a need to update or change it.
My Mum (bless her!) could use it. I did try to update to 2007, but found it a show stopper and my Mum was left clueless. So I am now forced to update to Office 365 to type a letter. Other PC's such as the Win 10 box I have are not affected but not plugged into the Laser Printer. A two minute job becomes a Saga...

Declarative software, please.

I am learning STM32 development and almost all the information available on it is trapped in webinar length videos.

I strongly suspect that the reason for this is the bloody CubeMX software which requires you to use combo boxes, and tree views, and other nonsense to set up the initial code for the project.

There is a project file it creates that has these settings, but the format opaque like old school visual basic forms.

People don't think.

When you make software that is fundamentally not declarative it means its data is not serializable. Even if you make it declarative but only you know the format, then you're forcing people to do it visually, which means YOU CANNOT EASILY WRITE INSTRUCTIONS on how to use it.

Microsoft finally figured it out with Visual Studio .NET.

I wish the CubeMX tool would work the same way. D'Oh! | :doh:
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx

worldle 540 3/6

#Worldle #541 3/6 (100%)
๐ŸŸฉ๐ŸŸจโฌœโฌœโฌœโžก๏ธ
๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŸฉโฌœโฌ…๏ธ
๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŸฉ๐ŸŽ‰
https://worldle.teuteuf.fr
should have been easy
"A little time, a little trouble, your better day"
Badfinger

Connector standard

Most PC mainboards have various 'headers' (why are they called that?) for attaching I/O sockets on the back, LEDs on the front, internal fans etc. Micros such as Arduino have lots of them - super simple, naked pins, no shielding, no locking holding the plug in position. Sometimes the board has the male pins, sometimes it has the female receptacle. They are far less robust that the power connectors.

I believe that the distance between pins are 1/10", commonly in a single row, but two rows is not uncommon. The number of pins vary from 2 (or even 1) up to at least 36. The cross section is usually square, but is is always? Always the same size (pin thickness)? Always 1/10" apart?

I have tried to find out what these connectors are called, to learn about their specification. There must be some standard defining them. What is the name or number of that standard? Maybe there are several standards - I suspect that some of them have a pin distance smaller than 1/10". Sometimes, there is a lock and release on the plug (typically on fan connectors), but maybe that is a different standard? (Or several different ones - 'The good thing about standards' etc.

Can anyone provide the name of the connectors, so I can google for more complete information? Or possibly give me a link to more information about them: Physical dimensions/distances, pin shape/length, male/female usage, lock/release usage, acceptable voltages and current/power and so on.

Code comments - how old is your code?

Just hit an interesting thought and would like veterans' perspective. I support a product that has over 20+ years of accumulated history. As I was writing some comments to explain why or what some code was doing, I've found that the #1 person who read my comments was me. Do comments even matter any more, or am I flattering myself?

Filed under hmmmm
Charlie Gilley

โ€œThey who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.โ€ BF, 1759

Has never been more appropriate.

ARRGGHHH!! register heck!

I wanted to turn on an LED on a STM32 devkit.

To do so I needed to turn some GPIO off and on.

It turns out, this isn't so straightforward.

I did not want to tie myself to a particular framework, so I decided to target the CMSIS headers which are available everywhere (I think?), even surprisingly under Arduino.

That means going to the hardware registers directly though.

Between being sidetracked by paying work and doing the research and code for this I've been at this all day.

I've got a class that almost lets me set the various properties of a GPIO pin and turn it off and on.

bool cmsis::gpio_pin_t::output() const {
    const int shl = 1<<index;
    uint32_t odr = READ_REG(gpio_ports[(size_t)port].reg_base->ODR);
    return !!(odr & shl);
}
void cmsis::gpio_pin_t::output_type(pin_output_type_t value) {
    const unsigned shl = 1<<index;
    MODIFY_REG(gpio_ports[(size_t)port].reg_base->OTYPER, shl, (shl * uint32_t(value)));
}
pin_output_type_t cmsis::gpio_pin_t::output_type() const {
    const int shl = 1<<index;
    return (pin_output_type_t)(READ_BIT(gpio_ports[(size_t)port].reg_base->OTYPER, shl) >> POSITION_VAL(shl));
}
void cmsis::gpio_pin_t::speed(pin_speed value) {
    const unsigned shl = 1<<index;
    MODIFY_REG(gpio_ports[(size_t)port].reg_base->OSPEEDR, (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(shl) * 2U)),
             (uint32_t(value) << (POSITION_VAL(shl) * 2U)));
}
pin_speed_t cmsis::gpio_pin_t::speed() const {
    const int shl = 1<<index;
    return (pin_speed_t)(READ_BIT(gpio_ports[(size_t)port].reg_base->OSPEEDR,
                             (GPIO_OSPEEDER_OSPEEDR0 << (POSITION_VAL(shl) * 2U))) >> (POSITION_VAL(shl) * 2U));
}
gpio_port_t cmsis::gpio_ports[] = {
  {(GPIO_TypeDef *)GPIOA_BASE},
  {(GPIO_TypeDef *)GPIOB_BASE}
#if defined GPIOC_BASE
  ,{(GPIO_TypeDef *)GPIOC_BASE}
#endif
#if defined GPIOD_BASE
  ,{(GPIO_TypeDef *)GPIOD_BASE}


In arduino it's just stuff like
pinMode(pin,OUTPUT);
digitalWrite(pin,HIGH);


There's a whole mess of behind the scenes there. And I ran face first into it.

I'm several hundred lines of C++ in and I've got it almost working. Just need to enable the clock for the pin group even though I'm not entirely sure what that is, just how to do it. Unsure | :~

Here goes everything.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
โŒ
โŒ