Posts by GBrandt • 1,052 points
16 posts
-
0
votes1
answer41
viewsA: Subtraction between elements in Ruby array
I was kind of guessing (as commented, the explanation could have been clearer) but I believe that’s what you want: values = [3, 5, 12, 1, 2] (0...values.size).flat_map do |i| values[i+1..-1].map {…
-
0
votes1
answer64
viewsA: Javascript and conditional switch, problems when saving a dynamic value
Tip: name your variables more clearly. a, b and c can be anything, and you will end up changing the balls at some point. On your switch, the value being "conditioned" is the c: The full text of…
-
1
votes1
answer77
viewsA: Password check on select Where
The function password_verify receives two parameters and returns a value boolean: true, if the password hash (not from her hash!) passed in the first parameter matches the hash passed in the second,…
-
0
votes1
answer787
viewsA: RECURSION IN C - COUNT EVEN NUMBERS OF A VECTOR
This function does the job and is much simpler (besides making more sense with recursion), I believe: int contaPar(int *v, int n) { if (n == 0) return 0; // Lista vazia, nao tem numeros, muito menos…
-
3
votes1
answer1123
viewsA: How to get only the records not duplicated with pandas
Almost. df2 = DF does not create a copy of DF, just give him one more name. When you give drop_duplicates(..., inplace=True) modifications happen directly in the dataframe (i.e. your data frame…
-
15
votes1
answer267
viewsA: How to optimize a Node.js script
I strongly suggest that you study callbacks and really try to understand how they work. Your code has several setTimeoutwhich should not exist, and their logic for continually reading and updating…
-
5
votes2
answers144
viewsA: Foreach only works if the array is inside brackets
I think this picture makes it pretty clear what’s wrong, right? Your second "array" is not actually an array. You must be confused with the Python tuple syntax, which does not exist in JS. In…
-
19
votes2
answers2430
viewsA: Using && e || instead of "if" and "Else"
bool && alert( foo || bar ) There’s two different things going on there, but come on. What’s the name of it? First, the bool &&: That part uses the short-circuit evaluation, present…
-
3
votes3
answers982
viewsA: Concatenation in Ruby and . object_id
Adding to Other Responses: When You Use <<, because you are changing the object itself, it may be that you change a string passed to a function from within it and it has outside effects. For…
-
2
votes1
answer170
viewsA: Algorithm to traverse an array
Scroll through the samples in "window - overlay steps": #include <math.h> // ... for (int i = 0; i < total_amostras; i += janela - sobreposicao) { int meanSquare = 0; // Percorre a janela…
-
2
votes3
answers340
viewsA: Sort in SQL by prioritizing a specific field value
This type of control seems strange to put in SQL, maybe it is more interesting to do this ordering using a more complete language. If using SQL is really the only alternative, you can use a CASE:…
-
1
votes1
answer111
viewsA: Structure of Data/ Stacks
You have some points to fix in the code: You declare in your struct one char* itens and a char val. val is never used, and itens is a hand char, that is, a string. It doesn’t seem your goal. I think…
-
1
votes2
answers55
viewsA: Can you add the keyword "noexcept" in get/set methods?
Of an answer in a similar question on Stack Overflow: Place noexcept is a bit compromising. If in the future you depend on changing the return type of this function to one that can throw exception…
-
2
votes2
answers52
viewsA: Chained List
A pointer is nothing more than an address in memory. When you declare a pointer in a struct, be it for the struct itself or anything else, until you assign some value to it, it’s just a random…
-
2
votes2
answers1101
viewsA: Cloud Firestore - Composite query
Seems related to this issue (and several others by the way). That one answer in one of the related issues leads me to believe that the problem has to do with this excerpt in the firestore…
-
1
votes1
answer1219
viewsA: Python Pandas insert records into a column according to the data present in a Dataframe
Try with pandas.Series.map: plan['Nomes Cidades'] = plan['Cod'].map(resultado['Cidades'])…