Posts by Maniero • 444,682 points
6,921 posts
-
6
votes3
answers1096
viewsA: How to change a value of a literal Javascript object?
In addition to a typo you are calling a function that does not exist globally, it only exists in the context of the client object, so you must call it through the object. var cliente = { nome:…
-
5
votes2
answers170
viewsA: Check UNIQUE element before inserting it
Don’t do that. You’re creating a race condition. You check if it is ok, another user (or the same in another session) changes the state of the bank, ie, a value that was unique, is no longer, then…
-
16
votes1
answer498
viewsA: Is a framework based on a programming language?
A framework specific is made for a specific language. I don’t know if you can say "based on a language," it depends on the interpretation of what this means, but generally speaking, this is not the…
-
3
votes2
answers87
viewsA: Problem with vector ordering
I believe it was just a typo: #include <stdio.h> int main (void) { int troca, vetorA[10]; for (int i = 0; i < 10; i++) { printf("Digite o valor do elemento:"); scanf("%d", &vetorA[i]);…
-
4
votes2
answers716
viewsA: How to prevent POST from outside the server?
At least it was funny to see how people post such great bullshit on the internet. When that’s how you quote the source. This code blocks the your internal access and no one’s access. You are the…
-
3
votes1
answer657
viewsA: Size of struct allocation
The allocation size of a structure is not so simple, there is the question of alignment. Depending on the compiler, directives, code and the platform you are running may be different but there is a…
-
2
votes2
answers429
viewsA: Run N threads and know when all finished running
It is possible to use Tasks as recommended by Miguel Anelo and do in a simplified way without worrying about the mechanism: using System; using System.Collections.Generic; using System.Threading;…
-
10
votes3
answers175
viewsA: What is the most correct way to make a query with LINQ?
You need to do this: public decimal GetCustomerBalance(long accountCurrentAdvisorId) { return this.Table.Where(x => x.AccountCurrentAdvisorId == accountCurrentAdvisorId) .Select(x =>…
-
5
votes1
answer768
viewsA: Unexpected value is being displayed
The problem is the tag of formatting the scanf(). To read a type value double the correct is %lf and not just %f: #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[])…
-
4
votes2
answers145
viewsA: printf does not show the expected value
Is that all there is to the line? So it makes sense to have a "garbage" on the screen. The %d indicates that there will be placed an integer value. What value are you passing to the function to put…
-
5
votes1
answer164
viewsA: Invert 0 or 1 in a column
This is probably what you need: UPDATE Pedidos SET posicao = 1 - posicao; I put in the Github for future reference.…
-
9
votes2
answers647
viewsA: How to use Ruby blocks
You know closures (in English)? It’s the same thing. You can see more on another question done here on the site. It is not the same language but the idea is the same. The Java 8 has the same feature…
-
9
votes3
answers1001
viewsA: Use OR operator in a PHP CASE
It is not possible to use the || or any operator. If you need to do this, you must use a if. The switch was created to compare values directly and individually, it cannot have expressions. But can…
-
8
votes3
answers2003
views -
4
votes1
answer276
viewsA: How to style a WPF application to look like Windows 8 applications (Metro style)
You can only do this by creating a style of your own or using one that someone else did. It doesn’t mean that it will be perfect but it is very close. Some examples: Mahapps.Metro Modern UI for WPF…
-
5
votes2
answers768
viewsA: Git repository size problem
Probably what you want is to rewrite the history of your repository, which can be problematic if you don’t know what you’re doing (I don’t know :P). this is done with filter-branch. An example: git…
-
9
votes6
answers12868
viewsA: What’s the difference between Isis and elseif?
Everyone has already explained well what it is. I will try to show otherwise. if ($valor < 10) { $total += $valor } elseif ($total < 20) { $total += $valor * 1.1; } elseif ($total < 30) {…
-
7
votes2
answers1324
viewsA: How to use Template in C++?
To define the methods you need to say you are using template there too. Each part is independent: template <class Type> Type p<Type>::setVal(Type i){ // code goes here } There you can…
-
5
votes3
answers397
viewsA: Can reference arguments be harmful?
If the resource exists it is because there is a reason for its use. Unless there is something complementary that makes it obsolete. Probably the recommendation not to use is to try optimizations.…
-
10
votes3
answers14735
viewsA: How to break a line of a Mysql field into an HTML page
You can store virtually anything in a column of characters. You obviously cannot format these characters, they are "pure". What you can do is put characters that indicate formatting by some…
-
3
votes3
answers864
viewsA: Make primary key uplinkable
This is not possible so directly. The primary key cannot contain duplicates. Depending on the database system may not even be in any order, but do not think that is your case, even if you do not…
-
4
votes2
answers1195
viewsA: Difference from #! in the first line of a Python script
The first looks at the environment variable PATH looking for python to know where the installed Python is running. The second is a specific location. The search in the environment variable is done…
-
2
votes1
answer99
viewsA: When including a header file, does the compiler include all functions in the final program or only the functions used?
The header generally only includes function statements to provide important information to the compiler. Thus, if the function is not used, there is a chance that the final application will not be…
-
7
votes2
answers1444
viewsA: How to organize code without losing performance?
At first it influences performance. But it may not influence by a number of factors. A call to a function, in addition to the instructions of deviation and return of the program flow to another…
-
2
votes1
answer3534
viewsA: Pass and return vector of type defined by struct as parameter of a function in C
Your problem is how to manipulate the array. There is a syntax error in the parameter. It is not the type that should declare that it is a array but yes the variable should indicate this. It’s kind…
-
8
votes3
answers2534
viewsA: Why doesn’t the height accept percentage?
I believe this solves your problem. The height percentage can only be obtained if it is relative to the other elements that contain these divisions. You have to determine how the upper blocks should…
-
4
votes3
answers146
viewsA: Modification of Javascript on websites
You basically have nothing to do. From the moment your software sends code to an unknown computer to run there, it is the prerogative of this machine to do whatever you want with the code. Nor would…
-
5
votes4
answers3093
viewsA: Function to check if number is prime in Javascript
According to this response in the OS you can do it like this: function isPrime(number) { var start = 2; while (start <= Math.sqrt(number)) if (number % start++ < 1) return false; return number…
-
3
votes4
answers357
viewsA: Objectcache to provide a variable for all users
What is good for you in the specific situation only you can say. Even though you put too many details it can still be difficult to tell precisely what is best because any detail omitted, even…
-
8
votes3
answers3406
viewsA: Storing representative values of a user’s 'sex' in databases
Depends on each case. What I never recommend, but there may be exceptions, is to use the full description. It will not be wrong to use the description if you have a good reason for it. If you do not…
-
9
votes1
answer543
viewsA: Parameter of any type in method
I don’t recommend doing this in C# but you can do it using dynamic that allows the variable to have its type determined at runtime: public static bool isNotNull(dynamic AnyTypeValue) { //tratamentos…
-
3
votes2
answers243
viewsA: Cast problem in a generic method that receives an array of Enum’s (Enum[])
You know that without giving the guarantee, you can not have a reliable code, so you will have to solve at runtime whether it is possible to do the operation or not. There are some possible ways,…
-
42
votes13
answers20263
viewsA: What makes a language to be considered low/high level?
I have seen several definitions but I do not know one that is universally accepted as correct and accurate. There are some people with opinions on the subject. Generally speaking, it can be said…
-
3
votes2
answers95
viewsA: How to change filename with variable
I decided to reply because I had solved in the comment. You mixed the apostrophe with quotes. The correct: include_once '../inc/saudacao_' . $rp_lang . '.php'; or include_once…
-
4
votes3
answers606
viewsA: Correct Inheritance in Entity Framework
If you want to take a property, you have to instantiate a class that has this property. So if you want the CPF, needs to instantiate the DadosCLientesPF. Instantiate DadosClientes there is no way to…
-
4
votes2
answers155
viewsA: Undefined Ference to MIN
One very obvious problem is that you are not including the file that has the definition of MIN. But this will not solve the problem because this function (a macro actually) only accepts two…
-
2
votes2
answers403
viewsA: Computer buffer
Buffer (the article is not the most elucidative) it is essentially an abstract concept. There is no area of memory that is a buffer because any area can be one. You define what is one buffer. He’s…
-
4
votes2
answers76
viewsA: Get width in pixels
The secret is the getBoundingClientRect(). It returns the desired information for some time. It works on all browsers that are not very old. document.body.innerHTML +=…
-
2
votes3
answers173
viewsA: Are there any techniques to apply maintenance in the code?
In this case little can be done. These code analyzers do not distinguish the intention. What can improve a little is to create the condition in a method and the if just call the method that will…
-
3
votes2
answers117
viewsA: Use multiple names with distinct functions in a variable
The first question you should ask is: what advantage does it have in taking advantage of a variable name to do two different things? In general the answer is none or it is just to type a few…
-
2
votes3
answers89
viewsA: How to make several projects have the same post-compilation event?
I found a solution in a response in the OS. I don’t know if it serves you but it is a way. On the same page there are other solutions, including plugin.…
-
4
votes1
answer114
views -
2
votes2
answers386
viewsA: LINQ to Entities does not recognize the 'Boolean Like' method?
If you were using LINQ To SQL you would need to ensure that you are using namespace with using System.Data.Linq.SqlClient. But in LINQ To Entities there is no such method. You would have to create a…
-
1
votes1
answer76
viewsA: Type conversion going wrong
Try this: If mObra.Rows.Count >= 1 Then Dim vl_mo_total As Double = 0 For Each currow2 As DataRow In mObra.Rows vl_mo_total += Convert.ToDouble(currow2("vl_maodeobra")) //esta é uma forma…
-
3
votes1
answer158
viewsA: How to receive input data from a C program from a file?
Basically what you need to do is read the stdin which is where the archive data will come from. A simplified implementation would be this: #include <stdlib.h> #include <stdio.h> #define…
-
5
votes2
answers326
viewsA: Do I need to include jQuery on every page?
Yes, it is necessary to put on all pages that will use it. And ideally it is always the same URL, so it probably take the browser cache file. Ideally it would be good to load the standard library…
-
2
votes2
answers599
viewsA: How to request input data N times, and concatenate this data
To make the loop is simple. c = input("Quantos links de download deseja colocar: ") print() i = 0 texto = "" while (i < int(c)): dw = input("Link de Download:") texto = texto + dw + " " i = i + 1…
-
4
votes1
answer451
viewsA: Object and pointer allocation
Pointers do not point to classes, but to objects. Classes are abstract concepts that exist during the definition of their form in code, after compilation they do not exist. There may be some static…
-
9
votes1
answer268
viewsA: What size of a large sizeable query?
In Mysql you can check this with: SHOW VARIABLES WHERE Variable_name = "max_allowed_packet"; I put in the Github for future reference. This same variable can be changed in the my.ini or my.cnf. It…
-
5
votes1
answer727
viewsA: How to create a value pair within a Java Map
Java doesn’t really have one Pair proper. You can implement your own class that handles the desired data pair. Normally this class is an interface implementation Map.Entry<K,V>. An example of…