Posts by utluiz • 72,075 points
957 posts
-
3
votes5
answers18470
viewsA: delete repeated values java array
Follows a direct implementation, without using the Collections API, which results in a repeatless vector: import java.util.Arrays; public class TestIntArray { public static void main( String[ ] args…
-
30
votes7
answers2227
viewsA: Agile methodologies - a single programmer
Solo Scrum is interesting and, as the @Caputo response, was used by some people successfully. But keep in mind that it won’t be a "pure" Scrum, since the original focus is on Team and various…
-
7
votes2
answers17077
viewsA: Convert milliseconds to hh:mm java format
Unlike solutions using mathematical calculations, I propose one that, although simple, allows to be easily adapted to other formats. The following method takes the time in milliseconds and uses the…
-
6
votes4
answers22316
viewsA: Subtract two TIMESTAMP and receive the value in minutes on Oracle
Given a table T with two fields of the type TIMESTAMP, t1 and t2: create table T (t1 timestamp, t2 timestamp); We can calculate the difference in minutes by extracting and summing the different…
-
11
votes2
answers1104
viewsA: How is Garbage Collection implemented in Go?
According to the FAQ of the language, Go uses a parallel collector mark-and-Sweep. The basic algorithm is the same one used in Java, but in parallel for better performance, consisting of scanning…
-
3
votes1
answer13631
viewsA: How to change the date format in SQL Server 2008?
If the idea is to use date literals in queries, just use the ISO format: YYYY-MM-DD (year, month and day). This will be interpreted smoothly in any environment. To format (or "print") dates for text…
-
2
votes3
answers408
viewsA: How to index and update a user comparison system?
I’m guessing this is some kind of social network, right? I can’t see how viable algorithms can compare users one to one. It would be very inefficient to perform this on a Rigger and too "time…
-
3
votes2
answers661
viewsA: Why does the month numbering of the Date object start at zero?
The reason why the months of the year start from scratch is a major flaw in the Java Date API design and which, in my opinion, occurs in other languages as well, such as Javascript. This is probably…
-
3
votes3
answers144
viewsA: Should I use Symbols in hashes and parameters to optimize memory usage in Ruby?
According to some sources you must do this yes. The symbols are stored internally in a table as integers without signal, which saves a lot of memory compared to the use of strings. As a result, the…
-
2
votes1
answer232
viewsA: How to make the p:Poll component not interfere with the modal in Primefaces 3.5
This is an expected behavior, since the updated element’s HTML code and its children is replaced by a new one in the event update. If the modal was out of center it should not have been closed. You…
-
1
votes2
answers348
viewsA: Is there any way to search (FULLTEXT) in a specific field in Mongodb?
In accordance with the mongodb documentation, it supports indexing and text searching from version 2.4, if enabled. As of version 2.6, this feature is available by default. To create a text index,…
-
2
votes1
answer85
viewsA: outputStream writing a byteArray - XSS validation
Not knowing the criterion used by the tool is tricky to speculate. However, the above code may cause security problems because the file submitted via download could, in theory, have malicious…
-
3
votes1
answer1426
viewsA: Trigger UPDATE write TXT file
The best known method is create a common Trigger and use the command master..xp_cmdshell to execute any command on the operating system environment which in turn save the data to the desired file…
-
1
votes1
answer546
viewsA: Draw a polygon freely using Fabric.js
How the script works The script consists of an editor that allows you to draw and work with geometric shapes. To do this, click on the label "Pressto Draw! And to stop, "then click on a few points…
javascriptanswered utluiz 72,075 -
9
votes1
answer1447
viewsA: Differences between Log4j and SLF4J
The advantage of SLF4J is that it is an abstraction of many of the existing log frameworks, allowing the creation of program, frameworks and libraries independent of the concrete implementation of…
-
8
votes1
answer2472
viewsA: Problem in converting number (Numberformat)
The catch(ParseException) is sufficient to handle the error and avoid the compiler message. If your Java continued to report the aforementioned exception it could be for some other error, for…
-
5
votes1
answer1111
viewsA: How to ensure transactional atomicity in more than one concurrent Thread in a Java SE environment using the Spring framework?
Using only Atomikos, an implementation of JTA and of XA, made a simple example that lets you run processing on multiple threads within a transaction. The complete project is available in my Github.…
-
6
votes2
answers3171
viewsA: Show only month and year in Primefaces Legend
The Primefaces component does not natively support this. Options would be: Customize the component (as in this SOEN response). Using a third-party plugin like monthPicker (indicated in the question…
primefacesanswered utluiz 72,075 -
1
votes2
answers350
viewsA: Fetchtype.EAGER for Fetchtype.LAZY
To make a query with JPQL by selecting only the necessary entities. With JPQL you can force joins for LAZY relationships or select only a few attributes. In the latter case, use a native query.…
-
2
votes1
answer504
viewsA: How to map a http request parameter to an Enum in java?
According to the jersey documentation, the types used in the parameters annotated with @*Param (as @QueryParam and @FormParam) must not fit in one of the following items: To be a primitive kind Have…
-
2
votes1
answer89
viewsA: Ruby-on-Rails Insert/uptade external program
The db:migrate allows you to migrate between versions of the database structure and optionally make Seed (plant) some initial data. The included or modified data, via Rails or not, has no direct…
ruby-on-railsanswered utluiz 72,075 -
0
votes1
answer257
viewsA: Multiple projects using a single "properties" file
The basic solution is to put the configuration in databases and load the data at the startup of each application. Another possibility is to set a network directory and read its properties file. All…
-
2
votes1
answer1064
viewsA: I can’t connect Jpa to Postgresql at all
A generic connection failure error can have numerous causes. However, the ideal is for you to search the application logs to see if there are other error stacks that have been written but don’t…
-
0
votes1
answer275
viewsA: Configure user.name
I am assuming that the operating system is Windows. Where git looks for the file The archive .gitconfig with the option --global is in the system user directory. See the configuration documentation.…
-
3
votes1
answer158
viewsA: Use of Spring Security
It all depends on how your application is structured. Problems may arise due to access security implemented in Java Classloaders. If your application manages the connection to the database, there…
-
1
votes1
answer890
viewsA: Read Word file without losing formatting
To read without losing formatting, save the record in the database with a field containing the extracted content in plain text format and the original file in a specific location using the registry…
-
67
votes7
answers11287
viewsA: Is it wrong to write byte of images into the database?
In addition to the cost being higher as mentioned, one should take into account several factors: Data volume: for a low volume of data may be no problem. On the other hand, for large data mass…
-
3
votes2
answers402
viewsA: "Variable system" with regular expressions
Depending on the requirements (since it was mentioned that the question is a simplified example), the goal of replacing variables and generating content based on a model from outside the program can…
-
3
votes3
answers29445
viewsA: How to check if the String is null or blank in Java / Android
Starting from Java 6, the most efficient and direct way to verify that a String is not empty is by using the method String.isEmpty(). Example with the verification of null: if (str == null ||…
-
2
votes1
answer701
viewsA: How to not filter only a folder in JAVA - Filter
The java API does not allow specifying this type of pattern. Unfortunately, there are only three ways: by exact path, path with a * at the end, extension. Additionally, you can apply the filter to a…
-
26
votes8
answers61967
viewsA: Should I use input type="Submit" or button type="Submit" in forms?
From the functional point of view there is no difference, both will submit the form in the same way. According to specification, if attribute type is absent from tag <button>, the default…
-
1
votes1
answer796
viewsA: How to add values from a column in Ruby/Ror
Sum and other aggregation functions To add values through the API ActiveRecord, use the method sum(). Example: Person.sum('age') List of options On the second point, to display an element select…
-
1
votes1
answer708
viewsA: How to store date/time of change in BD using Hibernate Envers?
According to the documentation of hibernate envers, the date of each revision is stored in the audit tables. Refer to revision date You can get the date of a review through the method…
-
1
votes1
answer157
viewsA: How to send messages to open tabs of an app on Chrome
In a recent project it was necessary to do something similar. It consisted of an accounting system. When the user selected another company, all tabs should be notified and updated. The system in…
-
2
votes2
answers814
viewsA: How do you tell Maven that one module depends on another?
Since you mentioned that you can’t alter the structure, I’m going to give you three ideas for circumvent the situation: Including the sources In one of the projects include the necessary sources of…
-
19
votes4
answers22728
viewsA: What are the definitions of method, function and procedure?
To definition of method of the English Bible says it’s a procedure associated with an object, which can also be called member function. Static methods would be those associated with a class. Often…
terminologyanswered utluiz 72,075 -
3
votes1
answer663
viewsA: JSF rendering
To update the screen partially, that is, only a chunk of it, after an action via Ajax you can use the attribute update if you have a button. See Richfaces documentation on this. Example:…
-
10
votes3
answers333
viewsA: Is there any advantage in bringing together all the icons of a website in a single image?
The question here is to decrease the amount of requests the browser makes to the server and therefore optimize the page load time and decrease the response time to the user. Performance This…
-
4
votes2
answers939
viewsA: How is the java project separation?
One thing is the division into projects made by Ides like Eclipse and Netbeans and another thing is the division of Java into libraries. A Java program dynamically loads classes and resources that…
-
71
votes2
answers4053
viewsQ: Is it wrong to use class inheritance to group common behaviors and attributes?
What they teach us about Inheritance The overwhelming majority* of materials dealing with Class Inheritance exemplify it as a mere mechanism for grouping common attributes or actions. At most, as a…
-
2
votes1
answer807
viewsA: Persist an entity that is inherited
Possible Solution The question code would work with some adjustments to the annotations. You might consider as if there were already entity data Administrador. If you recover one Administrador which…
-
6
votes3
answers60168
viewsA: Horizontal line in the middle of an unordered HTML list
<hr> son of <ul> Chrome correctly shows a row between the list items. I used the following code for testing: <ul> <li>Item 1</li> <hr style="height:2px; border:none;…
-
26
votes3
answers2309
viewsA: Is it right to prefer composition to inheritance?
Less prolific response ;) Many misuse inheritance to repurpose or organize code. Inheritance Extend a class only when it is necessary to replace the original class with the subclass in order to…
-
13
votes5
answers1927
viewsA: Why is multiplication faster than division?
Tests carried out According to the results of jsperf presented by Renan, other tests I created by differentiating integers and floating point and the tests recently created by Marcelo the statement…
-
0
votes3
answers4136
viewsA: Update a table using javascript and arrays
In a answer to another question, made an example of how to popular a table from a javascript array. Functional code in Jsfiddle. I suggest using this example as a basis. Just update the array and…
-
8
votes1
answer599
viewsA: Standard Java design for code reuse
There is no pattern absolutely better than the others. The MVC concept helps, but it’s only a start. Reuse of the code will depend on the coupling level of your code. It is possible to write MVC…
-
4
votes1
answer120
viewsA: Error with super(this) when calling a Java constructor
It is not necessary (and not allowed) to pass a reference to the object itself in its constructor. To refer to yourself in the superclass, just use this, in the same way as in the subclass. No…
-
71
votes7
answers13788
viewsA: How to represent money in Javascript?
All the answers add great information, but I would like to give a more direct answer. Representing a currency (money) The most suitable way is to use integers (int or long). The reason to avoid…
-
155
votes3
answers101378
viewsA: What are the main differences between SOAP, REST?
SOAP SOAP is an XML format message transfer protocol for use in distributed environments. The SOAP standard works as a framework type that allows interoperability between multiple platforms with…
web-serviceanswered utluiz 72,075 -
1
votes1
answer121
viewsA: Android getDeclaredFields value
The error occurs because you are trying to create an instance without passing arguments in the constructor of a class (Produto) that has parameters: public Produto(Context context) { super(context);…