Posts by carlosfigueira • 7,785 points
168 posts
-
3
votes4
answers239
viewsA: Ignore class name in XML serialization
You can control exactly what the serialization of your class to XML will look like with the interface IXmlSerializable. If you make your class Pessoa implement this interface, you can, in the method…
-
6
votes2
answers649
viewsA: Sort a Multidimensional array by column c#
. NET Framework does not have functions to sort multidimensional arrays directly - sorting functions work mainly for arrays Jagged. One solution is you convert your array to Jagged, order it, and…
c#answered carlosfigueira 7,785 -
1
votes2
answers54
viewsA: Vector in C- Program Received Signal, Segementation fault
When I compile your code, it shows the following Warning: warning C4700: uninitialized local variable 'num' used When you are reading this value, you need to pass the address of this variable, not…
-
2
votes1
answer543
viewsA: Problem with float and matrix
You specified the locale of the program as Portuguese (called setlocale in the first line). You need to enter the number in this format - if you enter with 1,2 instead of 1.2 your program should do…
-
18
votes3
answers13759
viewsA: Difference between %i and %d
In the printf, both are equivalent (print an integer in base 10). In scanf, the %i shall interpret the different number if it is preceded by 0x (interpretation as hexadecimal).…
-
14
votes2
answers2384
viewsA: char[] or *char malloc?
The main advantage is that you don’t need to know the size (in your case, 10) a priori. If you know exactly how much space you need when creating your program, and you will only use that memory…
-
1
votes1
answer39
viewsA: Update link within a variable
In order for the image to be different, you need to pass a parameter that varies to the URL being used - if you do not cache the browser you will assume that the image you are looking for is the…
-
5
votes1
answer34
viewsA: Access to json is returning error
You need to use the following syntax to access your object: console.log(x["body-json"].id) How the expression x.body-json.id is interpreted as x.body - json.id according to the Javascript syntax…
-
6
votes2
answers78
viewsA: Functions with a number of "dynamic" arguments
You can define a function using the ..., which can be used to access arguments explicitly passed by name. To access the values, you convert the ... in a list (using list(...)). The code below shows…
ranswered carlosfigueira 7,785 -
3
votes4
answers1988
viewsA: Is there any way to know if I’ve done git push?
The git status will tell you if his branch site is delayed or advanced from origin. If you have advanced (Ahead), then it means you need to push your updates. In the example below, I made a local…
gitanswered carlosfigueira 7,785 -
2
votes1
answer1403
viewsA: Error while converting to Json with Gson
You probably have a circular dependency on your data definition. For example, if you have this definition: public class Venda { // outros membros private List<ItemVenda> carrinho; } public…
-
8
votes1
answer557
viewsA: TDD and Unit Test, both are the same thing and have the same purpose?
These are different concepts. TDD is a software development philosophy: to implement any functionality (or make changes to code), you: Creates a (or more) test(s), which will probably be unitary,…
-
8
votes2
answers204
viewsA: SQL Select Where
You can use the function MAX SQL in its condition SELECT * FROM <tabela> WHERE DATA = (SELECT MAX(DATA) FROM <tabela>)
-
1
votes1
answer113
viewsA: WCF out bool parameter
Instead of using the option to add the reference to a Web Service, try using the option to add reference to a "Service Reference". The first is the option for services. ASMX (old), while the latter…
-
3
votes2
answers1328
viewsA: Is it safe to use List with Parallel.Foreach?
It depends. Whether you can ensure that the list will not be modified while the Parallel.ForEach is running so you will have no problem. Otherwise, follow @Ciganomorrisonmendez’s suggestion. Of…
-
11
votes2
answers228
viewsA: Is there any functionality similar to Assert (affirmations) in C#?
The class System.Diagnostics.Debug has several Assert methods that you can use for this. In your case, for example: Debug.Assert(value, "Value is invalid") The calls to Debug.Assert are only…
-
1
votes2
answers117
viewsA: Show source line author in Visual Studio (Git)
You can use the git blame for this. It shows the last person who changed each line of the file, plus more information (commit hash, date, etc.)…
-
1
votes1
answer774
viewsA: Replacing accents and cedillas
You can use the function encodeURI for URL-Find the characters. var url = 'http://my.url.com/que/tem/ç/cedilha/e/ãé/acentos'; var encoded = encodeURI(url); window.open(encoded); Example in Jsfiddle.…
-
1
votes4
answers3023
viewsA: Rand between numbers with comma
If you want to use rand, and not one of the functions they support floats (as the response of Maniero), you will need to convert the result of rand in a float (preferably between 0 and 1) before…
-
4
votes2
answers3321
viewsA: Convert Character Frame Data Column to Numeric
The conversion of as.numeric treats the . as integer/decimal separator, and not ,. A simple solution is to make the exchange before the call to as.numeric: colunanumerica <- as.numeric(sub(",",…
ranswered carlosfigueira 7,785 -
2
votes1
answer43
viewsA: Data Reception and String Conversion
Your text probably has more empty characters at the end (probably '\0'), then when you print it looks like the value is only "007F", but actually it has several characters '\u0000', what makes the…
-
2
votes1
answer42
viewsA: Two Salesforce Queries Generate Undefined Values
The operation conn.query is asynchronous - the call returns immediately, and the values of x and y have not yet been assigned when you print them. You need to wait for the operation to complete…
-
8
votes3
answers22504
viewsA: How to change the name of a column
You can use the function names to obtain, and also to change the name of the columns. In your case, you can use names(meus.dados)[2:4] <- c("ano", "mes", "dia"). The complete example below shows…
ranswered carlosfigueira 7,785 -
6
votes3
answers4507
viewsA: What is the point of "interrogation" in the type statement in C#?
The question is a syntactic sugar to declare that a primitive type may have a null value (i.e., Nullable<T>) - null is not a valid value for a primitive type. Using the Nullable, you have a…
-
5
votes1
answer364
viewsA: How to know if three points are clockwise or not in C/C++?
If you get the cross product of the segments on both sides of the angles, and pick up your signal, you will have information of which direction the points are oriented, as shown in the code below.…
-
4
votes1
answer212
viewsA: How to check if a polygon is convex
To see if it is a convex polygon, it is necessary to calculate the angles on each of the vertices of the polygon. If all angles have the same sign (positive or negative, depending on orientation),…
-
4
votes1
answer460
viewsA: How to check if a polygon is regular or convex
To check that the polygon is regular, you need the distance of all points, including the "last" point of your polygon to the "first" - in the code examples below, if you do not "close" the polygon,…
-
2
votes1
answer141
viewsA: c# hexa conversion
You can use the class Encoding, that has methods to convert strings to bytes. In your case, for example, you can use Encoding.ASCII: byte[] arr = Encoding.ASCII.GetBytes("ON");…
c#answered carlosfigueira 7,785 -
7
votes3
answers821
viewsA: What is the difference between "decimal. Divide" and the traditional "/" in C#?
The answers of Maniero and Gypsy Morrison Mendez are correct, pointing out the differences in methods for operators. But in this particular example, there is no difference (*) - the variables a and…
-
6
votes2
answers87
viewsA: Somatoria accumulating columns in a Matrix in R
You can use the function cumsum to obtain the cumulative sum the elements of your Trix. And apply, added to the t (transpose) can be used to get the result you need: temp <- t(matrix(c(11, 34,…
-
5
votes2
answers305
viewsA: Turn positive values into negative values in a data.frame based on one condition in another column (R)
The ifelse can help you here: df <- data.frame(Qtd=c(100,200,300,400,500), op=c('V','C','C','V','V'), stringsAsFactors=F) df$Qtd <- ifelse(df$op == "V", -df$Qtd, df$Qtd) Or you can also use…
-
3
votes1
answer58
viewsA: Function to send AJAX data?
The function $.ajax is asynchronous: her result is not available when she finishes running. You need to make your function (sendAjax) asynchronous as well, getting a function (callback) which will…
-
4
votes2
answers2858
viewsA: Difference between Viewresult and Actionresult
Of a response from forum of ASP.NET: ActionResult is an abstract class, and has derived classes, including ViewResult. If you will return in your method a Viewresult, you can declare it either by…
asp.net-mvc-5answered carlosfigueira 7,785 -
9
votes2
answers7712
viewsA: Search for values in one data.frame and add to another (R)
merge is the function you are looking for - it can join two data frames. Since you only want a column of the first data frame, you can filter it to have just it: Teste=data.frame(matrix(runif(20),…
-
3
votes1
answer99
viewsA: Comparing a function result
You are calculating the number of points, but you are not returning the value. With this you will have the value to assign to the variables pontosMeuTime and pontosAdversario. var meuTime =…
javascriptanswered carlosfigueira 7,785 -
4
votes4
answers1339
viewsA: Equivalent to Excel SOMASES, in R
You can use a value manipulation library such as dplyr to sum the quantities based on day of the week / hour, and then manipulate the result to get the format you want. The code below shows an…
ranswered carlosfigueira 7,785 -
1
votes1
answer123
viewsA: IOS - how do I find the screen size of the user’s device?
To find out the screen size in points, you can use the method bounds: CGRect screenBounds = [[UIScreen mainScreen] bounds]; If you want to know the screen size on pixels, you need to discover the…
-
3
votes1
answer87
viewsA: What is the best way to perform a descriptive analysis of birth dates in R?
Your code has some problems: The function as.Date assumes the date is in Y/m/d format, and its date is in m/d/Y. Change the first call to x <- as.Date(rehab.1$Data.Nascimento, "%m/%d/%Y") What…
-
5
votes2
answers1753
viewsA: global variable Angularjs
The function that is passed to the method then is not executed synchronously. It will only be executed when the output of shows.get is available. But the line console.log(splited) is executed…
-
3
votes1
answer416
viewsA: I can’t find the reason for Formatexcpetion
The method SqlParameterCollection.AddWithValue takes as parameters the parameter name and the value parameter. You are passing the name and the guy parameter. How you pass a SqlDbType like the value…
-
3
votes1
answer167
viewsA: How to show the axes of a histogram with their respective classes in R?
You’re passing FALSE for the parameter axes of function hist (which controls whether the axes appear or not). Remove the axes = F, or switch to axes = TRUE, and the axes will be drawn.…
-
1
votes1
answer65
viewsA: Httpwebrequest.Getresponseasync is limiting to 2 simultaneous calls
You can use the property ServicePointManager.DefaultConnectionLimit to limit the connections outbound which you can do in your process. If you increase this value. The default value is 2, which…
-
2
votes1
answer67
viewsA: Does closing Datainputstream always close Inputstream?
If you close Datainputstream, it will close the stream you passed in your constructor (in your case, the socket inputStream). Of the documentation of Datainputstream, in the section methods…
-
4
votes1
answer74
viewsA: Is there a difference in creating HTML elements in javascript?
In most cases, if the value of innerHTML does not come from the user, and is properly formed, there is no difference - the result will be the same. The biggest problem of using the innerHTML is that…
-
1
votes2
answers2296
viewsA: Read multiple lines from a file in parallel with c#
As you have a text file, where the lines may have different sizes, you will not have an efficient way to read the file in parallel. What you can do, however, is read the lines sequentially, and…
-
11
votes3
answers2210
viewsA: What is the purpose of the builder of an Enum?
Java enum constructors are used in situations where you want to add more information to Enum values other than your name. In its example, its Enum has associated with the MALE and FEMALE values…
-
17
votes2
answers920
viewsA: What is the purpose of this language called Brainfuck?
This language is part of a set of languages that has more theoretical applications than practical. Wikipedia (free translation): Although it is equivalent to the Turing machine, [the language] was…
brainfuckanswered carlosfigueira 7,785 -
3
votes1
answer817
viewsA: Generate Class From XSD - CTE for SEFAZ Webservice
If xsd.exe is generating classes whose names conflict with other classes in your project, you can specify a namespace different when you call her: xsd.exe /namespace:Meu.Novo.Namespace <outros…
-
1
votes1
answer119
viewsA: Error in file code. c
The problem is that the variable buff is defined as a array of 500 string elements, where string == char pointer (char *) - but these pointers are pointing to arbitrary memory addresses. If you want…
-
4
votes2
answers3791
viewsA: Write current Directory to a text file
%CD% is the environment variable that contains the current directory. And if you want to access a file in the current directory, you can use the .: echo %CD% > .\testecmd.txt The archive…