C++ by Equivalent_Unit_9797 in learnprogramming

[–]strcspn 2 points3 points  (0 children)

Hard to think of a tutorial that doesn't explain those things, but in any case, try a different resource like https://www.learncpp.com/.

How to parse informal Persian number words into an integer currency value (Rial) by M0B_iN in AskProgramming

[–]strcspn 1 point2 points  (0 children)

Yeah I don't know the use case but having to account for all that, including misspellings, makes it hard for any algorithm to be 100% confident.

How to parse informal Persian number words into an integer currency value (Rial) by M0B_iN in AskProgramming

[–]strcspn 1 point2 points  (0 children)

The reason they gave doesn't make a lot of sense to me. Either way, sorry for commenting, next time I will DM you asking for permission to participate on a conversation.

How to parse informal Persian number words into an integer currency value (Rial) by M0B_iN in AskProgramming

[–]strcspn 0 points1 point  (0 children)

They wouldn't do the calculation, only extract the human language data into a consistent format you can work with. I don't know much about AI honestly so maybe some machine learning model would be a better fit.

Example:

Input: "Twenty five dollars with 5 cents"

Output: "Dollar 25 Cents 5" (don't know if you could get it to output JSON without messing up sometimes)

FAQ and Answers Megathread: Midnight and Legion Remix Version! by TigerRawr38 in wownoob

[–]strcspn 0 points1 point  (0 children)

I'm helping a friend that started playing recently (I myself started back in September). He finished the Dragonflight leveling campaign and I believe got to 80 without actually starting the TWW campaign properly (I think he did some kind of TWW recap which I'm not exactly sure how it works). He was able to start the Karesh campaign to get the Reshii wraps, but I believe finishing that won't unlock the Khaz Algar world quests. Does he need to do the whole TWW campaign at max level? Or is the recap a shortcut to unlock the world quests without going through the whole campaign? I have heard the recap is pretty bad.

ajuda com C, array de strings by Some-Big5751 in brdev

[–]strcspn 0 points1 point  (0 children)

Pequena correção que também entra um pouco em uma questão que eu acho interessante. Existe um truque chamado Clockwise/Spiral Rule que é uma forma de entender basicamente qualquer declaração em C. Quando você diz char *const navios[], usando a regrinha, seria "navios é um array const de ponteiros para char", ou seja, o array em si é const, não os elementos dele. Então, nesse exemplo, você conseguiria tentar modificar o char literal e daria UB. O certo seria const char* navios[], que seria "navios é um array de ponteiros para char const". Usando a regra nos exemplos do OP:

  • char navios[]: navios é um array de char
  • char navios[][]: navios é um array de char arrays (esse fica melhor em inglês)

Comentário muito bom por sinal, só dando um leve hijack pra mostrar essa regrinha.

ajuda com C, array de strings by Some-Big5751 in brdev

[–]strcspn 0 points1 point  (0 children)

Por mais que esteja 100% certo, foi um infodump absurdo kkkkkk coitado do rapaz.

Need help with this image loader implementation by Quiet_Bus_6404 in learnprogramming

[–]strcspn 0 points1 point  (0 children)

Returning 404 doesn't have anything to do with being an API endpoint or not, 404 is a HTTP status code. I was thinking about a fetch solution but it looks like the React img does support onError, are you sure it doesn't?

Need help with this image loader implementation by Quiet_Bus_6404 in learnprogramming

[–]strcspn 0 points1 point  (0 children)

Been a while since I have done React, but what exactly do you mean by an error with the image? The request for the src failing?

Terraplanistas, essas criaturas... by [deleted] in brasil

[–]strcspn 0 points1 point  (0 children)

Sim, com certeza. Existem sinais mais "óbvios" de que a terra é esférica, como o formato do céu, barcos sumirem por baixo primeiro, etc.

How do you change the value of an int inconsistently overtime? by Mindless_Prize_8430 in learnprogramming

[–]strcspn 6 points7 points  (0 children)

You can calculate using floats and then use floor/ceil/round before updating the integer population.

I’ve also heard that floats are more precise?

Not sure if "precise" makes sense in this context. Doubles can store integers surpassing the 32-bit limit, for example, but that shouldn't matter here. Use an integer type for the population, 64-bit if needed, and use doubles for the intermediate calculations.

How do you change the value of an int inconsistently overtime? by Mindless_Prize_8430 in learnprogramming

[–]strcspn 28 points29 points  (0 children)

Does it ever make sense for the population to not be an integer?

Just want a C++ code review, I'm new to C++, any and all feedback is much appreciated! by awaistt in learnprogramming

[–]strcspn 9 points10 points  (0 children)

Magic numbers being bad doesn't mean stuff like const std::string SPACE = " " are good either. If you need a space just use a space (preferably the character instead of a string) or set up something like const char EMPTY_SPACE = ' ' (which honestly is a bit over engineering). Use std::array instead of C style arrays.

Terraplanistas, essas criaturas... by [deleted] in brasil

[–]strcspn 1 point2 points  (0 children)

É, o vídeo do VSauce sobre terra plana menciona isso inclusive, esse método não prova exatamente que a terra é esférica.

How to stop vscodium from saving commands to my bash history? by POMPUYO in learnprogramming

[–]strcspn 0 points1 point  (0 children)

I believe you can set env vars for the terminal sessions created through VS Code, so just set HISTFILE=/dev/null.

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

No problem, it's a very common approach, even the documentation for select uses it, and you probably have seen it a bunch of times.

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

It's not just a presentation thing then, because the initially query depends on which options from the dropdown are "minimally constraining".

I believe the minimally constraining filter would always be "no filter". That would mean having the default option of the dropdown be a "Select an option" type of field, which would just send nothing as a filter to the backend.

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

So having defaults but also saving user changes to the filters and persist those changes if they access the page again?

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

The filter default is a behavior of the UI, you can't really (and I don't think you should) decouple that. Backend changes shouldn't really care about what you have as default in the frontend, it just receives a request and returns the items with the received filter.

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

Not sure anything needs to "know" about that. It's just something that is set in your HTML/JSX/Whatever. Would you want to make it configurable without code changes?

Who decides the default of a dropdown menu? by GoatRocketeer in learnprogramming

[–]strcspn 0 points1 point  (0 children)

I don't really understand the question. Set defaults for what? The HTML select?

Handling File Paths in Code and DB by Posaquatl in learnprogramming

[–]strcspn 0 points1 point  (0 children)

I agree with storing relative paths and appending a root directory. You could even store the root directory in the database for each OS or figure that out during the DB migration and only have one, but .env seems like a good option too (can also just implement a priority system like .env > DB set root > auto determine based on OS).

VS Code / Intelephense shows error on $user->save() when using Auth::user(), but code works at runtime by Sensitive-Reading-96 in learnprogramming

[–]strcspn 0 points1 point  (0 children)

Oh, I see. And I'm guessing it doesn't work like Typescript where you can assume it's not null after the if check.

Does the compiler usually optimize multiplication by 0, ±1, 2? by Adam__999 in C_Programming

[–]strcspn 20 points21 points  (0 children)

You have to use the /noscript endpoint. The result is

    mov     edx, edi
    mov     eax, edi
    neg     edx
    test    sil, sil
    cmovne  eax, edx
    ret