Posts by utluiz • 72,075 points
957 posts
-
6
votes4
answers552
viewsA: How to distribute words in a fixed size area?
A simple solution is to apply a random offset smaller than the margin: function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } function rand() { return…
-
1
votes1
answer78
viewsA: Problems with CONVERT_TZ and BETWEEN in Mysql 5.1.73
I made the following example and it worked: CREATE TABLE tabela ( UserName varchar(100), StartDate datetime, EndDate datetime ); insert into tabela (UserName, StartDate, EndDate) values ('eu',…
-
0
votes3
answers491
viewsA: Logica de Distribuição Igualada
I see a solution with Permutation in Combinatorial Analysis. First we must get the combination of the elements in the example: To1, To2, To3, To4, B1, B2, C1, C2, C3, D1. Then simply delete those…
-
4
votes3
answers8251
viewsA: Using jQuery Validation Engine and CNPJ validation
Analyzing the documentation, I found funcCall[methodName], which allows calling a custom function to perform validation. Here is an example based on the documentation: function verificaCNPJ(field,…
-
1
votes5
answers727
viewsA: Return all CSS classes with Regular Expression
Thinking to address the issue of comments and hacks starting with dot, I thought of the following function: function parseClasses(cssSource) { //remove comentários var semComentarios =…
-
9
votes2
answers2787
viewsA: How to determine which HTML element and/or which event called a function?
The listeners jQuery event parameter takes a parameter with reference to an object representing the event. This object has attributes type and target, which contains the event type and the element…
-
1
votes2
answers1772
viewsA: Is it possible to have dynamic rules with jquery validation?
It is possible to make this logic much simpler. Just add the following rules: rules: { "filtro.tempoInicial": { required: function(element) { return $("#operadorTempo").val() == 3 ||…
-
9
votes2
answers1657
viewsA: How to generate noise in an image using python?
Based on the concept of Moiré from Wikipedia and a little bit of Geometria Analítica, I created a little routine to apply the effect on an image superimposing it on itself. Routine: from PIL import…
-
0
votes2
answers1115
viewsA: Static jsp content is not shown
First you put the images and styles in a directory of resources. Although it’s the same name you’re using, it’s not the same. Note that the top element title is "Other Source Codes". These resources…
-
1
votes2
answers2696
viewsA: How to run a subprocess with admin permission?
Windows has a command called runas. Typing this command without parameters in cmd Windows XP, get the following help: RUNAS USAGE: RUNAS [ [/noprofile | /profile] [/env] [/netonly] ]…
-
21
votes2
answers5355
viewsA: Get colors from the image
The following code mounts an object containing the histogram and recovers the most common color using an element canvas invisible: //carrega uma imagem var img = new Image(); img.src = ... //cria um…
-
1
votes3
answers271
viewsA: Get List Help (Code Refactoring)
In JSF, data can be recovered in a facelet (file .xhtml) or even in a JSP through simple method calls getter by Mr JSF. No need to create Expression Languages elaborated, it is sufficient to…
-
2
votes5
answers708
viewsA: At what point in a project should the platform be chosen?
From the technical point of view, I believe that we should classify the different domains of solutions (webapp, desktop, webservice, batch, mobile, ...) for which the various languages can be more…
-
3
votes1
answer533
viewsA: Different multiple select rendering for each browser
In Chrome it is not possible to resolve only with HTML due to a bug unresolved when the attribute size is less than 4. And Firefox also has a open bug scheduled for future resolution, i.e., they…
-
14
votes2
answers29551
viewsA: Simple paging in jQuery/Javascript
One way to make pagination exclusively with jQuery/Javascript is to have the data in a Javascript array and then apply it to a table with a specific function. For example, you can use PHP to…
-
6
votes2
answers2854
viewsA: How to view a PDF in the browser with an ajax request?
It is not feasible to use Ajax to display a PDF. What you need is just to open a new window or create a frame pointing to the URL that returns the PDF. The browser will automatically make a request…
-
6
votes2
answers725
viewsA: How to focus on a pop-up every 1 minute?
The way to do this is with the function focus of the object window returned by window opening. For example: var janela = window.open('http://www.google.com'); setInterval(function() {…
javascriptanswered utluiz 72,075 -
6
votes6
answers293
viewsA: How to visually indicate which fields are fillable?
A visual option that I find interesting, although for many fields it can be visually repetitive, consists of the use of icons. Blocked field? Lock with a padlock. Can you edit? Use a pencil or pen.…
-
2
votes5
answers10769
viewsA: How to mark and unmark a row from a table by clicking on it?
I didn’t see anyone meet the requirement of the question, so follow my version: $('#codexpl').on('click', 'tr', function () { $(this).siblings().removeClass('marcada');…
-
3
votes1
answer658
viewsA: How to generate Jlabel or Jtextfield at mouse click?
Yes, it is possible: Sets the layout with absolute positioning with setLayout(null) in the target component. Add a MouseListener in the component. Implement the event mouseClicked: Create the…
-
1
votes1
answer125
viewsA: Struts2 with Spring Security Oauth2 plugin
Like most Spring projects, there is no restriction on using Spring Security with other frameworks, including for projects desktop. Spring Security’s idea is not one plug-in Spring MVC, but an…
-
6
votes5
answers9524
viewsA: Receive an expression and calculate in C
My answer will not be in C, but I hope to help in a possible implementation in this language. ;) In most compilable languages, either in "machine code" or bytecode, there is this problem related to…
-
2
votes3
answers2241
viewsA: How to control tuition and access to the application?
I have always worked in companies in the financial sector, which provide services and develop systems for banks. However, I don’t have much experience with the bulletin systems because I didn’t work…
-
5
votes2
answers8082
viewsA: Maven how to define JDK version?
TL;DR Your solution is correct, that is, using the Maven Compiler Plugin to specify the Java version of the project. Specifying the installation java In addition to the version, it is possible to…
-
6
votes3
answers6578
viewsA: How to resolve the SLF4J failure in Maven?
When you talked about Eclipse, I soon thought it was a bug of the plugin m2e (Maven to Eclipse), which is the Eclipse plugin for integration with Maven without command line. Said and done! This is…
-
2
votes2
answers2185
viewsA: Transparent java background
I’m not very good with GUI, but I was able to reproduce the problem and solve with the method repaint() in the "parent". Consider the following example: public class TextFieldTest { public static…
-
4
votes1
answer384
viewsA: Problem with Java timer
Java parameters are always passed by value and not by reference. Then, when changing the variable value Tempo, you are changing the copy value of the argument and not the original value of…
-
3
votes2
answers609
viewsA: Retrieve elements by class in IE8 with pure JS
For compatibility with older browsers, you should create a routine for this. The following was made on the basis in this matter: function findByClass(matchClass) { var elems =…
-
3
votes3
answers589
viewsA: Is there any way to run batch files during the build of a Maven project?
Using the Exec Maven Plugin. With it you can perform other Java programs in the same JVM or a any program in a separate process. See a example of use to an archive .bat: <project> ...…
-
2
votes4
answers1407
viewsA: Prioritize word in SQL query - Mssql
I believe the solution with UNION or UNION ALL would be somewhat bad for the performance, since two darlings would be executed. The solution of @ademario is good, but the query can be simpler, that…
-
22
votes2
answers13323
viewsA: Entitymanager.merge() persisting instead of updating
Object vs. Entity When working with JPA/Hibernate it is important to keep in mind that any object, even if it is an instance of a class annotated with @Entity or mapped to an XML, not automatically…
-
2
votes1
answer925
viewsA: How to determine which HTML file should be displayed as input in Jersey?
If the idea is to direct non-logged users to a particular page, you can create a filter (Filter) to check the user’s status and, if not logged in, redirect it to the correct URL. Also, the same…
-
8
votes2
answers7355
viewsA: Is it better to parameterize your Preparedstatement even if the value is fixed?
TL;DR In most cases use Prepared Statements is better, safer and more performative. But it is not a rule. How do the Prepared Statements When you create a Prepared statement, the JDBC driver sends…
-
10
votes1
answer5562
viewsA: Creating timer with JAVA
Switching to setRepeats(true);, you can check if the seconds have reached zero and run the method stop() to stop the timer. See in the example: public class Eventos extends javax.swing.JFrame…
-
7
votes3
answers331
viewsA: Unknown cause error: "Syntaxerror: invalid range in Character class"
The error is associated with regular expressions, being caused by the range a-Z (a lowercase and Z uppercase) in the attribute pattern. Like the attribute pattern is an element of input included in…
-
3
votes4
answers262
viewsA: How to implement journaling in Python?
Guaranteed recording of files My first thought when it comes to ensuring file processing was the buffer data. See what the documentation says file.flush(): Note: flush() does not necessarily write…
-
2
votes2
answers1602
viewsA: Display "longblob" field content containing PDF file
Depending on the file format you cannot display it directly on the page, but you should put a link to the download of the same. Displaying files directly on the page If the file is text type (txt,…
-
4
votes1
answer368
viewsA: Programmatically close jar
When creating the process with the method exec() an instance of Process. Then you can store this reference and destroy it later with the method destroy(). Example: Process p =…
-
3
votes4
answers482
viewsA: Disabled button modified using firebug
The question of security guard against actions and manipulation of accidental or malicious data in web applications goes far beyond simply inhibiting buttons or fields. The first reference I read…
-
10
votes8
answers64831
viewsA: How to check if a checkbox is checked with PHP?
A checkbox in an HTML form is only sent if it is marked, so just check if it is present in the variables $_GET or $_POST. Example with method post: isset($_POST['minhacheck']) Example with method…
-
26
votes3
answers31700
viewsA: Exactly how Javascript works
As this one says documentation, the return: Sets the value returned by a function. When there is no specified value, undefined will be returned. Stop running the current function. Return with value…
javascriptanswered utluiz 72,075 -
3
votes4
answers3127
viewsA: How to prevent the input-text focus from being lost by clicking on another element?
You can place an event in the table to return the focus to the search field with the function focus() jQuery. Example //evento click da tabela $('#resultado').on('click', 'tr', function() { //muda a…
-
0
votes4
answers15127
viewsA: Uncaught Syntaxerror: Unexpected end of input
There is nothing wrong with the code itself. The problem is hidden in the Javascript links that are added by the code. Instead of: <a href="javascript:void">x</a> Do: <a…
javascriptanswered utluiz 72,075 -
0
votes2
answers931
viewsA: Calling file at each Timthumb run
After knowing a little about this image library and analyzing the question graph, I can comment on some possible causes of slowness... Timthumb is always processing all images This does not seem to…
-
5
votes1
answer1322
viewsA: How to configure . htaccess to accept a hyphen in the URL?
Its regular expression contains the excerpt [a-z], defining that only letters are accepted. Add the hyphen as follows: [a-z\-]. You get the expression: RewriteRule ^postagem/([0-9]+)(/([a-z\-]+)/)?$…
-
4
votes1
answer1821
viewsA: Take all classes of a given Package that is in the classpath
You can use the library Reflections in an unusual way, but it is possible: //lista as classes do pacote "com.google", incluindo os subpacotes Reflections r = new Reflections( "com.google", new…
-
2
votes3
answers1015
viewsA: Send e-mail on behalf of the client
The ideal is to have a specific account for the system to send the emails, as seen around: [email protected], but actually the address doesn’t make much difference. The important thing is to…
-
15
votes4
answers1480
viewsA: What is the correct way to simulate a <script> with a new language?
This is not even a direct answer because it does not involve a callback native, however, I can think that a solution would be the creation of a Loader capable of dynamically loading and processing…
-
3
votes1
answer2128
viewsA: JSON transfer to Codeigniter via AJAX
Use JSON.stringify() to convert your object into a Json string in the attribute data of function ajax. The parameter data accepts a string or an object, but it does not automatically convert to Json…
-
1
votes1
answer109
viewsQ: "Noinitialcontextexception" error while boosting GWT application via Eclipse
I’m trying to upload an application made in GWT 2.4 in Eclipse Kepler (4.3), using Google Plugin for Eclipse. When using the option Run As > Web Application, I immediately receive in the log the…