Posts by utluiz • 72,075 points
957 posts
-
4
votes2
answers2102
viewsA: How to compare Date class to System.currentTimeMillis() in Java?
There are two simple ways: Comparing time in milliseconds The method getTime() of java.util.Date returns the time in milliseconds since January 1, 1970. The same occurs with the method…
-
1
votes1
answer366
viewsA: Error in final bar with mod_rewrite and mod_jk
The following rewrite rule adds a bar to the end specifically in the case of access to the path /dreamtech: RewriteRule ^(dreamtech)$ $1/ [R] Try to put it this way: <VirtualHost *:80>…
-
1
votes1
answer668
viewsA: Pick up mouse position on virtual machines
I imagine you are using windows API to recover cursor position, but this function should stop working when you disconnect, end there is a "monitor" so it is possible to say the current position. Not…
-
3
votes3
answers526
viewsA: Tag script is not printed with jQuery
You don’t need to "inject" the Script that way. In fact, this can create problems if the selector picks up more than one element in the frame by doubling the listeners. //código html a ser injetado…
-
0
votes4
answers271
viewsA: Does the secure API depend entirely on the developer or platform?
The security of information in systems depends almost entirely on the developer. No matter how many settings and how many security standards an application uses, you won’t have security if:…
-
3
votes2
answers564
viewsA: jqGrid does not call the blockUI method without using window.setTimeOut when ajax request fails
At first I see nothing wrong with its implementation. On the other hand, the Blockiu plugin has no relation to Ajax, so your assumption about the problem seems mistaken. This type of problem can be…
-
1
votes1
answer898
viewsA: Upload Angularjs image with Java server
I believe there is a misconception in your code. First you retrieve an item like this: FileItemStream item = iterator.next(); Then, while reading the bytes of the file, you recover the InputStream…
-
1
votes3
answers400
viewsA: Refactoring with eclipse
Refactoring features for the Java language are sufficient for 99% of cases. In fact, in my experience, I never needed to use all of them. However, depending on the technology you work with, plugins…
-
6
votes4
answers1418
viewsA: How do I programmatically respond to a command on the Linux terminal?
I’ve been reading a article on the Python Subprocess Module, specifically on the subprocess.Popen, which explains how Python allows communication with the executed process. I made a small example…
-
5
votes6
answers1877
viewsA: Code refactoring to convert GPS coordinates into DMS format into an array
I created a function that I believe to do what you want with less difficulty, based also on regular expressions. Regular Expression The created expression was:…
-
7
votes6
answers66760
viewsA: "foreach" in Javascript
Similar alternative: for..in In Javascript there is a version of for that has some similarities with the foreach PHP. It is the closest type of construction, but it exists to iterate on object…
-
1
votes2
answers353
viewsA: Remove matrix input by its value
I could think of two ways to do that: 1 - Using array_search and array_values As already answered by @perdeu the function array_search() solves the problem of finding the value. However, I would…
-
17
votes2
answers9606
viewsA: How to compile a PHP file?
TL;DR A simplistic technique that you can use to protect yourself "from prying eyes" and have a basic (low) type of "security" is obfuscate the code. Higher security can be achieved with bytecode,…
-
6
votes2
answers609
viewsA: Could current Javascript engines optimize "tail" recursive calls?
Well, I don’t really understand compilers or interpreters, so I’ll stick to the facts I found in the documentation and references. In thesis, Javascript could have "tail" call optimization. In fact,…
-
5
votes2
answers638
viewsA: How to do an action after three dynamic elements are filled with jQuery/javascript?
It is possible to solve the problem in a more "generic" way, that is, by creating a kind of camp group using CSS classes. A possible HTML would look like this: <select class="meu_grupo"…
-
7
votes4
answers3728
viewsA: Java client library for REST web services
I can’t say if it’s the most used framework (this is very debatable), but I use the Jersey, to reference implementation of the JAX-RS API. It implements both the server part and the client part. See…
-
5
votes1
answer409
viewsA: Is it possible to integrate SVN with my task control tool?
For what I found in some links the hook of post-commit SVN in a Windows environment can easily be directed to an archive batch (.bat). The repository and the identifier of the commit are received by…
-
3
votes1
answer1071
viewsA: How to launch my own exceptions with PDO?
I did some research and analyzed the documentation officer. It seems not possible to replace the exception PDOException by a custom via some simple configuration. However, I have thought of some…
-
3
votes2
answers3152
viewsA: Build generation in the Maven project
The simplest and "manual form" The simplest practice to get an artifact with the review of VCS in the file name is to put the desired revision in the version configured in the pom.xml. Although it…
-
8
votes6
answers23686
viewsA: Difference between absolute and relative Urls in page contents
There are practical differences in different URL types? The other answers are very good. I can only agree that any difference in efficiency compared to the bandwidth used (amount of bytes…
-
2
votes3
answers1058
viewsA: Createelement() method in PHP
For the complete XML (or XHTML) creation the best solution is the DOMDocument, as mentioned in the other replies. However, if your goal is simply to create an HTML tag in a simple way, I believe…
-
6
votes2
answers1232
viewsA: Differences when instantiating a class
In practice, there seems to be no difference. From what I understand, most people and IDE implementations prefer to instantiate in parentheses to follow the standard code used in PHP’s own…
-
8
votes1
answer5564
viewsA: How to change PDF source generated by iReport?
I made a test to reproduce your case as I explain in the following topics: Including a source in iReport First I downloaded some source, in this case, called Royal Chicken. Then I downloaded the…
-
40
votes6
answers7903
viewsA: When should we allow a column of a table from a database to accept NULL?
A bit of history The discussion on the use of null is discussed by developers of various platforms. I’ve heard a lot about this in Java as well. On one occasion, talking to a colleague after a…
-
6
votes5
answers704
viewsA: Event is not tied to the element
Assuming you’re using a function like the jQuery.load(). Add the code to callback event, that is, a function that jQuery performs to conclude both the request and the update of the DOM. Take an…
-
11
votes1
answer1892
viewsA: Check whether a path is relative or absolute
Check relative path The method File.isAbsolute() says if the path is absolute. Then just deny (!) the return to know if it is relative. Take an example: File f1 = new File("..");…
-
7
votes3
answers2560
viewsA: Database redundancies are always undesirable?
TL;DR Participating in the development of a financial system used by several institutions, among them a bank of a very famous car manufacturer worldwide, my team decided to eliminate the table of…
-
2
votes2
answers606
viewsA: Competitive when using time table
A generic solution, i.e., that does not apply only to Microsoft Access, is to add a column referring to the user ID and reference this column in all queries performed in the table, so as to allow…
-
4
votes1
answer1567
viewsA: Use the same entity in Hibernate to write to two tables
Inheritance with mapping via annotations This is a very common question and it is most often indicated to use a heritage-based border. For example this answer gives us basis for the following…
-
11
votes1
answer1462
viewsA: Use Resultset without knowing the column type
Recovering an object generically One option would be to use the method ResultSet.getObject(). The method documentation says that the type of the returned object will be the standard of JDBC…
-
13
votes2
answers3208
views -
6
votes4
answers5034
viewsA: Set Custom Error 403 Page
According to its documentation, the ErrorDocument apache is very flexible and has 4 ways to redirect and display an error message. Learn: Display a simple fixed message (hardcoded) Display a custom…
-
-2
votes5
answers1562
viewsA: Optimize function to include classes also looking in sub-directories
Cache in a Map One of the ways to do this is to store a class cache by name in a array. I did a basic implementation: function list_classes($dir, $array = array()){ $files = scandir($dir);…
-
24
votes8
answers7830
viewsA: Is giving a "SELECT" before an "INSERT" a safe way of not having duplicate records?
A solution would be to lock the table with the command LOCK TABLES within a transaction. Obviously someone can argue that this is bad for performance. And it is, because you are queuing all the…
-
21
votes3
answers12113
viewsA: Check if a table exists in the database
Based in this OS response, the simplest way is: $table = 'banana'; $tableExists = $db->query("SHOW TABLES LIKE '$table'")->rowCount() > 0; Alternatively, if someone does not want to use…
-
5
votes2
answers3444
viewsA: How to count the amount of occurrence of a substring within a string?
The method groupCount() returns the number of groups of the expression, which in this case is a. You need to go through the Matcher until the end of String, like this: String aString =…
-
11
votes3
answers3229
views -
12
votes2
answers4712
viewsA: How to create Permissions (Permissions) instead of Roles (Roles) in Spring Security?
The Spring Framework decision system After a deeper analysis of the structure of Spring I solved the issue with a Spring Bean that implements the interface AccessDecisionVoter. A Voter (Voter) is a…
-
11
votes5
answers14927
viewsA: How to not allow a character to be typed in the textbox, with Javascript/jQuery?
The reply from @bfavaretto answers the question directly, but as I commented, I would not use a character filter of this type to prevent unwanted input. This can be easily circumvented, even…
-
3
votes3
answers2292
viewsA: How do I leave a "Default" language on Github?
You can’t do this manually. According to the Github help page, they use a library called Linguist, which determines the predominant language in the files. However, as the same cited page indicates,…
-
28
votes4
answers2188
viewsA: Time spent developing tests
TL;DR There is no magic number to estimate time spent testing, just as there is no magic solution to the software estimation problem. Some time ago I saw a presentation of a test specialist and, in…
-
8
votes3
answers4784
viewsQ: Why Laravel instead of Yii?
It’s been a while since I actually developed in PHP. In my last research, about two years ago, I didn’t hear much about the Laravel, as long as the Yii led some rankings (including my) framework to…
-
41
votes8
answers5920
viewsA: Is it always guaranteed that a multi-threaded application runs faster than using a single thread?
Let’s go in pieces: It should not always have gained performance when it has multiple processors (not necessarily chips)? Not, as additional processing is required to create, finalise and manage the…
-
8
votes4
answers2589
viewsA: Is it possible to create an 'abstract class' in Javascript?
There is serious confusion here about concepts of classes and members (attributes) in the question. Static attributes They are those that, regardless of the instance of the class/function used,…
-
14
votes4
answers3196
viewsA: What is good practice when casting an exception within if?
Although this is prone to a strong sense of personal opinion, I believe that best practice is nay block the else. The reasons are as follows:: Readability of the code Adding nested blocks, although…
-
44
votes5
answers10782
viewsA: What is a Mysql Transaction for?
TL;DR SQL databases in general, not only Mysql, are transactional, that is, they allow you to perform a sequence of operations as an indivisible block in order to ensure data integrity in a…
-
8
votes2
answers389
viewsA: Android app for tablets only
According to this topic the configuration of manitest, as mentioned in the @Ernandes reply, prevents users from finding their app on market place, but if they have the file apk in hands they will…
-
4
votes3
answers7499
viewsA: How to fill in a numerical field as in internet banking (right to left)?
I tested both responses from @Denisbernardo and of @bfavaretto (maskMoney plugin) and found some small differences. For example: Using the jQuery plugin, when the field content is deleted with the…
-
3
votes4
answers805
viewsA: How to use Simpledateformat in concurrent environments?
Such a simple and almost insignificantly more "performative" to the creation on demand of instances of the SimpleDateFormat, as presented by Victor, is cloning. A performance test is presented in…
-
6
votes2
answers245
viewsA: Infinite loop when walking recursively through DOM nodes
I spent a good few minutes debugging the code on a fiddle, until I realized a very, very subtle nuance. The control variable of your loop for is declared as a global variable without the var, soon…