Posts by carlosfigueira • 7,785 points
168 posts
-
10
votes2
answers222
viewsA: Update model partially with Webapi2
With this approach you are sub-utilizing the power of PATCH. The main advantage of this verb is that the client can send only the attributes to be changed, and this can be done in the same Resource.…
-
1
votes3
answers1099
viewsA: How to divide the elements of a matrix by the average of its column
An alternative is to replicate the means to create a matrix of the same size as the original matrix, and then divide the original by it. The code below shows a way this can be done. > A <-…
-
3
votes1
answer73
viewsA: Serialization of exceptions
If the exception you set in the DLL (a) will not leave the "black box of the process where it is running", then you don’t have to worry about serialization. If you have a DLL (b) or EXE (c) that…
-
4
votes1
answer160
viewsA: Access List<List<string>> in a Thread
You would have the same behavior if you were accessing the list of both the same thread and different threads from where it was created. Your problem is that you are calling the method ToString in a…
-
3
votes2
answers7576
viewsA: What is the best way to undo a merge with staged and modfy elements with conflicts?
Assuming the merge didn’t generate any commit (as there are conflicts). At the root of your repository, type git reset . This will remove all the changes that are staged, putting them back on the…
gitanswered carlosfigueira 7,785 -
6
votes3
answers242
viewsA: Why do I need to declare a guy inside the "foreach"?
The simple answer: why specification requires that the value used in for-each be declared in it. Working out, language designers decided for this model for simplicity - this block works for most…
-
5
votes2
answers2794
viewsA: What is the difference between setInterval/setTimeout and Web Workers?
In this example it really doesn’t make any difference. Both the main thread and the worker thread are doing virtually nothing. But imagine that instead of function timedCount just increment a value…
-
0
votes2
answers828
viewsA: Get Json properties name
Using the Gson, you can use the method entrySet to obtain all the properties of a JsonObject, as shown in the example below. String json = "{" + "\"Ficha\":[" + "{" + "\"nome\":\"nome\"," +…
-
1
votes1
answer91
viewsA: Batch Move and Del commands are not working
The command start batch does not expect the command Started end. What must be happening is that the command MAKEOPEACER5.jar cadperfiSorted it’s not over yet, and with that: the del failed, as it is…
-
3
votes3
answers8395
viewsA: Deserialize JSON Array in an Object Array
The first foreach is trying to convert the string jsonR in a JValue using the implicit converter. You end with a JSON string, not an object, which is what you need. To read using JSON.NET, you first…
-
3
votes1
answer53
viewsA: Client http socket in c
A call to ssize_t send(int sockfd, const void *buf, size_t len, int flags) sending at most len buffer bytes pointed by buf. It may send fewer bytes than the maximum. In this code, the variable sent…
canswered carlosfigueira 7,785 -
1
votes3
answers315
viewsA: Syntaxerror: unterminated string literal JAVASCRIPT
If you are taking data from the server to create a URL, you must "url-Encode" the data. For example, if the data you are searching for has a ', you will get an error like what you are getting, since…
-
1
votes1
answer205
viewsA: Doubts about using Contains with Regex in C#
You need to use the class Regex to apply regular expression to the strings you want to compare. The code below shows an example of how this can be done. String verifica = @"^#[A-Z]{1,7}"; Regex…
-
9
votes1
answer5523
viewsA: Problems returning a large amount of data through WCF
When you use the "Add Service Reference" to generate the client for the WCF service, this tool adds in your configuration file (app.config or web.config) the information necessary for the client to…
-
4
votes1
answer4369
viewsA: Why are you giving "Uncaught Referenceerror: getSetorObj is not defined"?
You need to specify the this. to call the function getSetorObj on that line (and on others as well). If you do not use this prefix, the function this.selectSetor = function(X, Y){ getSetorObj(X,…
-
1
votes2
answers301
viewsA: Xmltextreader() identify end of node and duplicate tags
XML is a multilevel structure, and you’re trying to read "flat" form. What you are doing is basically the deserialization of XML for your C#objects, and the best way to do this is to use a…
-
3
votes4
answers2494
viewsA: How to join observations of tables that have a different set of variables in R?
You can use the function rbind.fill of the package plyr to do what you want: library(plyr) df1 <- data.frame(id=1:10, z = rnorm(10)) df2 <- data.frame(id=11:20, x = rnorm(10),z=rnorm(10))…
ranswered carlosfigueira 7,785 -
2
votes2
answers159
viewsA: When should an attribute be a table or vice versa?
The usual answer: it depends. Your question is basically about normalization: if you want to keep your database normalized, it might be that using an extra table is interesting. But not always.…
-
3
votes1
answer329
viewsA: How to mount XML with C#?
You are adding the tag <Sistemas> (and your children) that you created in the xml file (tag Meuxml), which already has a tag Sistemas - then you get two. What you need to do is add the new…
-
1
votes1
answer88
viewsA: Series using recursiveness
You can re-write the operation serie(x, n) = x^n / n! as x^n x * x^(n-1) x x^(n-1) x --- = ----------- = --- * ------- = --- * serie(x, n - 1) n! n * (n-1)! n (n-1)! n For values of n >= 1. The…
-
7
votes1
answer148
viewsA: Doubt typedef void*
void * is a pointer to an arbitrary memory address, not a pointer to "nothing". The fact that it has returned 4 in its implementation means that you are with a 32-bit application (where memory…
canswered carlosfigueira 7,785 -
5
votes1
answer90
viewsA: Why do I get this Segmentation Fault?
The code below has the following problems: char *s = "string"; sprintf(stdin, "%s", s); stdin is the type FILE *, and the first parameter of sprintf is a variable of the type char *. Do not mix the…
canswered carlosfigueira 7,785 -
2
votes1
answer224
viewsA: Parameters in the Query
Why the first query does not work: parameters for SQL queries are interpreted according to their value; a string parameter will be converted to a string in the query (*). Your first query is…
-
4
votes1
answer931
viewsA: Take the highest value within the Line select
You can use multiple calls from Math.Max to solve this: MaxValor = Math.Max(CF.Janeiro, Math.Max(CF.Fevereiro, ..., Math.Max(CF.Novembro, CF.Dezembro)...)) Or use an additional method that does this…
-
7
votes2
answers2568
viewsA: What is the purpose of the size_t and ssize_t commands in C?
size_t is defined in the standard C (in stddef.h). ssize_t is the version Signed of size_t, but is defined in a POSIX extension, so it may not exist on all platforms. The size_t represents the size…
-
2
votes1
answer99
viewsA: Monitor IOS users in real time
When you say "real time," you need to define precisely what that is. Assuming your application tracks multiple users on some map, if the information is delayed a few seconds (or a few minutes), is…
-
1
votes1
answer75
viewsA: Jarray add values
If you have your JSON in a variable JObject (as you mentioned JArray, I am assuming you are using the Newtonsoft.Json library, namespace Newtonsoft.Json.Linq), you can use a code similar to the one…
-
2
votes2
answers3274
viewsA: C# - XML return from Webservice with encoding error (ISO-8859-1)
As you are using the "Add Service Reference", what Visual Studio generates for you is a client that uses WCF. WCF, by default, uses XML readers that are optimized for certain encodings (UTF-8,…
-
6
votes1
answer1327
viewsA: Can’t find Httpcontext.Current
Of Soen: To have a reference to HttpContext.Current you need to change the term HttpContext.Current for System.Web.HttpContext.Current That’s because the class Controller defines a property with the…
-
6
votes3
answers2350
viewsA: Add multiple items to a list
You can add them as an enumerable (for example, an array): List<Int32> ContasNegativas = new List<Int32>(); ContasNegativas.AddRange(new int[] { 30301, 30302, 30303, 30304, 30305, 30306,…
-
1
votes1
answer51
viewsA: Creation of GIF images
The page probably uses a tool that captures the screen and creates an animated GIF. One that works relatively well is https://github.com/NickeManarin/ScreenToGif.…
imageanswered carlosfigueira 7,785 -
2
votes1
answer230
viewsA: Difference between tuple and set
Because for python the parentheses delimit a tuple, not a set. If you want a set, you need to use the keys ({, }) or the function set: basket = {'apple', 'orange', 'banana', 'pineapple', 'pear'} or…
-
2
votes4
answers9178
viewsA: Regex to pick a text between <>
You can use an expression that reads all characters other than the >: \<([^\>]+)\> A Jsfiddle showing an example with this regex: http://jsfiddle.net/r1mfz24s/. Note that you don’t need…
-
1
votes2
answers1846
viewsA: Error invalid Conversion from 'int' to 'int*' using -fpermissive
Every time you run your program, the memory address where the variable x will be stored is different. Therefore, if you run the program once, copy the address, and try to run the program again, that…
-
1
votes2
answers705
viewsA: Use Ftpwebrequest with Uri https
Are you sure the link protocol is FTP itself, not HTTP(S)? If an address is given as http://dominio.com/path, then the server is "talking" HTTP. And since this is a (virtually) universal truth, all…
-
0
votes1
answer84
viewsA: Java Nullpointerexeption, agenda inserts no compromise
When you are entering the commit, all items in the array Compromisso are void, so the call to this.Compromisso[qtdCompromisso].setData(...) will fail with this mistake. You need to create the object…
-
7
votes1
answer38
viewsA: Problem with Return
The problem with your code is not that it is running asynchronously. The problem is that you are ignoring the result of the call A.every(...) (which is executed synchronously) - if all return (AA…
-
2
votes1
answer1031
viewsA: How to format a String with other elements using format()
You won’t be able to use the String.format for this, but you can break the string into 3 parts (using substring) for such: String valor = "08041995"; String formatado = valor.substring(0, 2) + "/" +…
-
2
votes2
answers74
viewsA: Using functions
You have several ; after the ifs: if (jog_usuario == 1 && jogada_comp == 3); { // remova o ; depois do ) printf("\nPedra amassa tesoura!"); return 2; } // há também outras instâncias desse…
canswered carlosfigueira 7,785 -
1
votes1
answer71
viewsA: Comparing char variable in C
The value you are reading from stdin contains what the user has typed, including the ENTER. If you change the two lines of else down the lines, you’ll see the problem: printf("\nNOT OK");…
-
2
votes3
answers207
viewsA: I need a function to add <br> under certain conditions
You can get the content of the element <p>, and from it "break" the text based on its logic. For example, the code below adds the <br> when the text is larger than a certain size, but…
-
14
votes1
answer243
viewsA: Pseudo Code Chess
As the question is formulated, there is not enough information to solve the problem. But assuming the following: They are not only a king and a queen (of opposite colors), but a king of one color…
-
4
votes1
answer2420
viewsA: Are there any random text generators that produce correct phrases?
You can create a program with several generic phrase components (subject, verb, object), which can be combined correctly. From this you randomly select one of the components of each group, and have…
pythonanswered carlosfigueira 7,785 -
5
votes4
answers4010
viewsA:  - This error appears between the <body> and gives space difference
This value (65279 == 0xFEFF) is probably a GOOD (byte-order mark) which is in your (HTML) file. Open the file in a binary editor and see if these bytes are in the file. For example, in Visual…
htmlanswered carlosfigueira 7,785 -
4
votes1
answer3982
viewsA: How to send complex object to Web API?
You are passing an arbitrary value in the request URL - it is possible that there is a character that is not supported, or that you will change the semantics of the URL (e. g.: ., :, /). This is…
-
6
votes1
answer65
viewsA: How to use Bitconverter.Todouble bytes
The BitConverter uses the IEEE-754 format to represent floating point values, which is the format used by C compilers to represent values double (8 bytes) or float (4 bytes). With this, you can…
-
3
votes2
answers292
viewsA: ggplot data.frame
When you try to convert the expression "jan2006" to a date, you are missing the day of the month - without that R has no way of knowing which date you want. You can, while doing the conversion, add…
-
3
votes2
answers1085
viewsA: How to test whole arrays in javascript?
Your tie is returning if the last element is even or odd, since the value of the variable condicao is being modified for each element (note that if you pass an empty array, the function will return…
-
4
votes1
answer873
viewsA: How to access data from the innermost "level" of a JSON?
There is no array in JSON that you have - you only have objects (and primitive values - strings, numbers, etc). You will need to access them as such, something like the code below: JSONObject jo =…
-
11
votes3
answers2999
viewsA: What is the difference between for...of and for.. in?
The main difference is that while the for..in iterates on the name of the properties of the object, the for..of iterates on the values of these properties. For example: var arr = ["gato",…