Posts by Maniero • 444,682 points
6,921 posts
-
4
votes1
answer197
viewsA: What does Java memory management accomplish in an assignment of a previously allocated variable in memory?
Every time you wear one new is creating a new object in the heap (I don’t know if this will change in Java 10, which will be allocated in stack). It’s that simple. And every new object will be…
-
2
votes1
answer138
viewsA: How to loop ("FOR" or "WHILE" or "DO WHILE") in a row in VB.NET?
You can write in many ways, one of them would be: For i As Integer = 0 To 9 : Console.WriteLine(i & ", ") : Next Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for…
-
3
votes2
answers157
viewsA: Revoke in TEMPORARY TABLE in Postgresql, is it possible?
REVOKE TEMPORARY ON DATABASE seuSB FROM usuario I put in the Github for future reference. Documentation.…
-
4
votes1
answer376
viewsA: How to make a "compilation" of the code in Python?
You can only generate the bytecode through the modules py_compile and compileall. To use it you need to use the option -m: python -m py_compile arquivo.py…
-
1
votes2
answers99
viewsA: Problem to remove space after line break
Treat the first one as an exception that doesn’t have a space, the rest will all go within the normal. #include <stdio.h> int main () { int x, y; scanf("%d", &x); scanf("%d", &y); if…
-
7
votes2
answers367
viewsA: How to optimize my access to the Python dictionary?
As far as I know the two ways to access a key in the dictionary are basically equivalent (of course one returns a boolean of existence and the other returns the value, but both get time O(1), in…
-
6
votes2
answers2928
viewsA: What’s the difference between For, Foreach and Find in Javascript?
The reply of bfavaretto is correct and good. I will complement. The for (that I hate that it comes followed by the parenthesis of gap without space that makes confuse as a function) is a statement,…
-
2
votes2
answers148
viewsA: Test equal to the question but is giving error
I am glad that I decided to start learning how to program and started by C. I have bad news: to start doing without really understanding what you are doing doesn’t usually work. And worse, it seems…
-
5
votes2
answers812
viewsA: Get previous element in foreach
Yes, it is possible: using static System.Console; using System.Collections.Generic; public class Program { public static void Main() { var lista = new List<int>() { 1, 2, 3, 4 }; var anterior…
-
1
votes2
answers190
viewsA: Why is it possible to change constant values in Javascript arrays?
You need to understand the difference between types by value and types by reference. In types by value the content (value) is in the variable, in types by reference the content (value) is in another…
-
3
votes1
answer233
viewsA: Is there any way to compare all received parameters?
You have to walk a array received as parameter, using params, and sweep it all in a loop, making the if desiring. If you don’t mind performance you can do with LINQ in a row. Depending on what you…
-
1
votes1
answer99
viewsA: How to get all public properties of a class in the order that were declared in VB.NET
Nothing guarantees order, so you can’t do this. If you want a lot, you can use an attribute by setting the order manually and take this value in each property to use as a sorting key. In fact almost…
-
2
votes2
answers1064
viewsA: Lambda functions in C++, when to use and what are the advantages?
To lambda does not have a name defined at compile time, it is treated as a value. Think that the normal function is like a constant and the only way to call it is to use the name of this constant. A…
-
2
votes1
answer124
viewsA: Dictionary<string, string> or Namevaluecollection?
The only thing you need to know is: don’t use NameValueCollection. Specialized collections are virtually obsolete. They were needed for C# 1.0, with the advent of generic collections, use them…
-
2
votes1
answer151
viewsA: C++ string protection using Mysql Connector
So there is no solution (that way), if people are able to decompile (and can always fall into the hands of those who can) they are able to decrypt something that needs a key and an algorithm running…
-
7
votes1
answer1578
viewsA: What is an embedded database (Embedded)?
Generally the term is used when the database access mechanism is bundled with the application, as opposed to having another application that your database communicates to access. The best known…
-
4
votes3
answers2456
viewsA: How to organize items from an array in alphabetical order?
You can use the usort(). I made for the layer: function cmp($a, $b) { if ($a == $b) return 0; return (substr($a, 37, 4) < substr($b, 37, 4)) ? -1 : 1; } $array = […
-
4
votes2
answers659
viewsA: Problem using print to show function result
What you want to do is sort and not shuffle. Or if you want to shuffle is wrong. Just do this: print(''.join(sorted(input()))) I put in the Github for future reference. Of course this shape is not…
-
1
votes1
answer279
viewsA: How to pass and traverse an anonymous object in a method
It is possible using reflection, but not recommend, saves typing, but lose speed and can create maintenance difficulties. Jil does it, but more performatively. Note that the example where it was…
-
1
votes1
answer141
viewsA: CS1501 C# No Overload for method takes 2 Arguments
The code does not compile because it lacks a using System at first. But it does not give the error informed. Solving the problem cited it compiles and runs normally on ideone.…
-
2
votes1
answer48
views -
6
votes2
answers1153
viewsA: How to transform integers into byte in the Python language?
Can do: print((65).to_bytes(1, byteorder='big')) Documentation of to_bytes(). If the preference is to do with a list use like this: bytes([10,20,30,40,50,60,70,80,90,100]) Documentation of bytes().…
-
3
votes1
answer949
viewsA: How to check the type of elements in a Python list?
Could do this: all(isinstance(n, int) for n in lista) I put in the Github for future reference. Something is already ready (isinstance() and all()). Source.…
-
2
votes1
answer56
viewsA: Can MSIL be converted to Native code?
.NET Framework is one of the implementations of CLR, of CLI that in fact, even by virtue of specification generates a CIL as the question denotes. The question ends up being, even involuntarily,…
-
0
votes1
answer63
viewsA: Fails when accessing a vector option that does not exist
Obviously if you only have options from 0 to 6 declared it is not possible to use 7, so make sure n is in the valid track before using it, something like this: if (n >= 0 && n <…
-
2
votes2
answers655
viewsA: Mysql parameter error with C#
After the AP clarify better the answer would have to be different from the below: Not possible without some trick with SQL itself. Could use a stored Procedure that has a variable that is being…
-
2
votes2
answers146
viewsA: How to associate items from a String list to the code name of a C#label?
Just do this: for (int i = 0; i < numletras; i++) letra[i].Text = palavra[i]; You will create the Labels more or less this way: for (int i = 0; i < numletras; i++) { var letra[i] = new…
-
1
votes2
answers133
viewsA: Any difference between the two expressions?
In theory it is quite different. One makes an assignment of a value contained in a variable to another variable. The other operates the value of a variable stating that it wants to apply a positive…
-
7
votes3
answers597
viewsA: How does the equals() method work in Java?
This is called polymorphism. See definition of this concept. It allows code reuse. Type hierarchy So all the types you create, in your example the Person, are at the same time other types. At least…
-
2
votes2
answers108
viewsA: Question about array size
Actually having a zero is a coincidence, it could have any value there. You are picking up a value that is in a memory position outside the area reserved for this array. You know it goes from 0 to…
-
15
votes2
answers1709
viewsA: There is an "Else while"
In JS does not exist, you need to create a flag inside the loop for a if be executed or not after the end of this loop. Or think of a different stream that doesn’t need this. In Python exists. The…
-
8
votes2
answers312
viewsA: Remove string after "dot" on a number
Already have something ready tested that is the parseInt(). console.log(parseInt("123.33")); I put in the Github for future reference.…
javascriptanswered Maniero 444,682 -
28
votes6
answers4346
viewsA: What is the difference between attribute and field in the classes?
Quite a controversial subject, but it shouldn’t. Everyone can have their opinion, they can follow a specific school, but there’s evidence that most of the use is what I put here. I do not deny that…
-
4
votes2
answers111
viewsA: Why doesn’t a private method go into the documentation in Java?
void will not change anything, is just an indicator that the method does not generate a result. What is private is implementation detail, is something that can be changed at any time without notice.…
-
6
votes2
answers139
viewsA: Can hashes be different for the same bytes?
To manufacturer’s documentation that you used to say that the secret key needed to calculate the hash is generated randomly. And at each run a new object is created. Then at different executions the…
-
2
votes1
answer2404
viewsA: Can we develop a 100% Javascript/HTML/CSS web application without backend?
First, you seem to believe that there’s only one way to do things, that there has to be MVC. You can do whatever you want any way you want. Of course some things are more suitable than others for…
-
7
votes1
answer2211
viewsA: Difference between @Html.Labelfor and @Html.Displaynamefor
The DisplayNameFor() generates a pure text with the title of that element, already the LabelFor generates a tag label HTML with the title text, thus: <label for="Campo">Título</label>…
-
2
votes2
answers415
viewsA: Problem with ternary operator
Or if you want to use conditional operator even though the performance may be even worse: k += i < 5 ? 1 : 0; Or k += i > 4 ? 5 : i; //ver comentário do Bacco acima Or even with likely better…
-
5
votes2
answers3151
viewsA: Check if an email exists or your email domain
For me, checking if an email exists only serves to send spam. So I don’t care how to solve this issue. I don’t even want to know if you have the mailbox address or the domain name. Check if someone…
-
12
votes2
answers152
viewsA: Settimeout and server traffic
It interferes a lot, generally this should not be done. You need a event system (the engine is this, but the client/server architecture is different). Using the Hollywood Principle the client…
-
26
votes2
answers2114
viewsQ: What is an asymptote?
In a reply came the term asymptotic. In comment came a definition. I think it would be to have a more complete definition here. But the focus of the question is even simpler: In Portuguese clear,…
-
11
votes1
answer259
viewsA: Why not iterate a hashmap?
When someone tells you what to do, ask for justification. Iteration Iterating any data structure with a data set is no problem at all in general. If you want to iterate in a specific way, in a…
-
14
votes2
answers750
viewsA: How to improve the performance of my code with "for"?
In this example there is not much to do. You want to show 8000 items, no matter what you do you will have to print 8000 items and that is high cost. Maybe in a different structure, which you don’t…
-
4
votes1
answer166
viewsA: If I have two servers (application and database) with different time zones, which one is better to use as a base?
Schedules should always be stored and manipulated like UTC, so no problem will occur (or almost, it is not so simple, but for most scenarios is ok). You only handle local time at data input and…
-
2
votes1
answer104
viewsA: How to use C# syntax in onclick
You can’t do this directly, what runs on the client has nothing to do with what runs on the server, they’re different code bases, they’re even different languages. It’s like you want to delete an…
-
4
votes1
answer115
viewsA: Difference between :80 and other doors
Will performance be changed? Because it is not the standard access port. If you access directly there will be no performance loss. But if someone takes this address and ends up carelessly taking the…
-
4
votes1
answer344
viewsA: Join three similar codes into one
Would be basically this: import csv curso_desejado = input('Qual o curso? ') vagas = 0 inscritos = 0 ingressos = 0 arquivo = open('oks4c.csv', encoding='utf8') for registro in csv.reader(arquivo):…
-
5
votes1
answer161
viewsA: What name is given in C# when we use the expression "new {}"?
As the return message of GetType() show, it’s an anonymous guy (Anonymous type), He’s a guy who doesn’t have a name in his code. Of course, internally it has a name because it’s not possible to have…
-
3
votes1
answer949
viewsA: How to take line break in the "Cin" of the <iostream> library?
It is not possible. The cin is made for basic use, for experimentation, minimal interaction without ceremony. If you want to have total control over the data entry you will have to write a code that…
-
6
votes3
answers2102
viewsA: What is the difference between function and array assignment?
In these examples you cannot compare well. One adds an element to the array, or another assigns value to element 0 of array. They only do the same thing if the array is empty, so the semantics is…