Posts by Anthony Accioly • 20,516 points
346 posts
-
2
votes2
answers118
viewsA: How to improve this "Flattening" function from a list
One option is to create a nested function: def flatten_list(ls=[]): flattened_list = [] def aux(ls): for elem in ls: if not isinstance(elem, list): print("ADDING NO-LIST ELEMENT...")…
-
4
votes1
answer396
viewsQ: XA transaction does not commit changes in procedures (intermittent)
I have an EJB Stateles that monitors files that fall into a folder. When a file arrives it is handled, a receiving event is recorded in a central database and the file is inserted into a target…
-
2
votes1
answer94
viewsA: Check if CONSTANT exists in Package
Recompile your package with the parameter PLSCOPE_SETTINGS setado to IDENTIFIERS:ALL (for more information see Using PL/Scope). ALTER SESSION SET PLSCOPE_SETTINGS='IDENTIFIERS:ALL'/ CREATE OR…
-
12
votes3
answers1089
viewsA: What are the pros and cons of indexing vectors by zero or one?
Behold these notes of Dijkstra that I blatantly I copied from Soen. Basically the convention helps to represent sequences without having to deal with corner cases. You know those horrible codes they…
-
5
votes1
answer961
viewsA: Custom auto increment
There are several options. One idea is to create an auxiliary computed column to identity in the database (see that article): CREATE TABLE MinhaTabela ( DbID INT IDENTITY NOT NULL PRIMARY KEY, );…
-
3
votes1
answer641
viewsA: java interface layout
In Netbeans I recommend the Grouplayout. The IDE has excellent support and the layout is quite flexible (allowing anchor elements, set policies for vertical and horizontal growth, etc). You’ll have…
-
7
votes1
answer178
viewsA: Why does the group_concat of primary keys (integers) generate a BLOB as a result?
According to the sql manual: group_concat The Return value is a nonbinary or Binary string, Depending on whether the Arguments are nonbinary or Binary strings. The result type is TEXT or BLOB unless…
mysqlanswered Anthony Accioly 20,516 -
4
votes2
answers57
viewsA: What is the function of the ismount method
They can. Links (hard or symbolic) appear in most operating systems and file systems. On Linux you can create a link with the command ln. In modern versions of Windows you create a link with the…
python-3.xanswered Anthony Accioly 20,516 -
5
votes2
answers189
viewsA: Add JNI Library Compilation with Maven or ant tasks
Maven owns the Native Maven Plugin and the NAR Plugin for Maven. Both have Goals to work with C/C++ compilers, generate headers with javah, etc.. If you need a "do it yourself", that article (a…
-
1
votes1
answer121
viewsA: Using Napkin Lookandfeel
Victor, here it is (This code is hard to run). There appears to have been a compatibility breakdown between JDK 6 and JDK 7 for translucent windows (see that post on Soen). Napkin dependent on that…
-
3
votes1
answer827
viewsA: When converting an object to JSON, because it appears several characters " "
The problem is on the line: object.put("questionItem",values.toString()); You are sending the library to convert the values to a String (which contains quotes") and put them on the property…
-
12
votes1
answer8955
viewsA: Inheritance in relational database
There are several ways to map the inheritance relationship in the bank. The best strategy will depend on the situation (types of queries that will be performed against the data, amount of common…
-
1
votes1
answer113
viewsA: GOTO and ACTION table generator
While I understand that the Beaver is a super set what you need, I think it’s worth taking a look. It generates Java classes from EBNF grammars. The classes are a representation of the lookup…
-
2
votes2
answers1183
viewsA: Sum of squares
This is a recursive function that computes the sum of the term-to-term arithmetic progression (x, x + r, x + 2r, etc). The sum of the squares follows the same structure, the only difference is that…
canswered Anthony Accioly 20,516 -
4
votes1
answer1498
viewsA: How to replace characters from a String?
A "simple" option is to use the method replace class String. String valorComPonto = "100.00"; String valorComVirgula = valorComPonto.replace('.', ',');…
-
2
votes1
answer812
viewsA: Load objects related to @Onetoone
The problem is that the view does not contain part of the data of the objects referenced by destination (ids, non-enterable values, etc). This is a common problem. When a system user submits the…
-
7
votes2
answers455
viewsQ: JAX-RS Resource as Session Bean or CDI Managed Bean?
Today I ran into an interesting problem trying to inject an EJB into a JAX-RS feature (in Glassfish 4.1, running the pre-installed version of Jersey). @Stateless public class MeuEJB implements…
-
5
votes1
answer115
viewsQ: Return only albums with at least one photo
I am currently making the following FQL query to return all the logged-in user’s Albums that have at least one photo (with the amount of photos): SELECT object_id, name, photo_count FROM album WHERE…
-
2
votes1
answer672
viewsA: How to use regular expression in input?
In accordance with comment from mgibsonbr, "masks" for URL are not a good idea. A better strategy is to validate the URL after loss of focus with some kind of visual indication. As this kind of…
-
9
votes1
answer5156
viewsA: What is the difference between @Inject and @EJB when injecting an EJB?
For Java EE 6 or 7, the recommendation is to always try to use @Inject, annotations @EJB should be used only when a feature without counterpart in the annotation @Inject is necessary. The idea is…
-
14
votes4
answers5405
viewsA: Strategies to analyze very large databases in R (that do not fit in RAM)
R is a specialized language whose Sweet spot are data analysis problems in memory (an extremely significant set of problems). That said, the R ecosystem is large and several solutions are emerging…
-
2
votes1
answer1055
viewsA: Pass parameter between two Jsps
You can get the parameter on the page saida.jsp through EL: ${param.informal} Even within a tag jstl <c:out value="${param.informal}" /> Or use scriptlets (which should be avoided): <%=…
-
1
votes1
answer262
viewsA: Unable to locate current JTA Transaction
Solving the author’s problem. Remove the mode="aspectj" of <tx:annotation-driven />. Reason, was not enabled the weaver (for more information see: Soen The Old "@Transactional from Within the…
-
1
votes2
answers851
viewsA: Is it possible to limit the number of lines in a class attribute that is a list via JPQL?
Doing the reverse way as suggested by Felipe Fonseca SELECT e FROM Endereco e WHERE e.usuario.id = :id ORDER BY e.id DESC Then you can page normally em.createQuery(query) .setParameter("id", id)…
-
2
votes1
answer966
viewsA: Help with Java codemount from ArrayList (search, insert String)
Case 1: The Scanner leaves a line break in the input after the method call next(), you can discard it by calling the method nextLine(). System.out.println("Digite o nome do Aluno ");…
-
3
votes1
answer1320
viewsA: rbind error: "Error in match.Names(clabs, Names(xi))"
You are reassigning the variable temp with each iteration and deleting the column names. One option is to copy the column name at each iteration: temp<-data.frame(i,rowcount) # nova data frame…
-
2
votes1
answer479
viewsA: How to simulate the Python title function [string.title()] in Java?
The library Apache Commons Lang has the function capitalize in class Wordutils. String title = WordUtils.capitalize("oi, meu nome é goku"); If you need to normalize a title beyond the first letter…
-
19
votes1
answer28571
viewsA: Enable . htaccess in Ubuntu
You’re on the right track. mod_rewrite You need to enable the mod_rewrite (it may be that it is already enabled, but it is good to check): sudo a2enmod rewrite htaccess The default file path varies…
-
1
votes1
answer72
viewsA: Error running Spring Roo
By the log you probably bumped into this Bug: [ROO-3505]. For now Spring Roo is incompatible with Java 8, install a version of JDK 7 and make sure you’re running Spring Roo with it.…
-
1
votes1
answer500
viewsA: How to use ping/pong in Websocket Java
If you are thinking of implementing this at the application level, take a look at these Unit tests of Tyrus. The idea is quite simple, create the server-side message logic: @ServerEndpoint(value =…
-
6
votes2
answers39212
viewsA: Replace in SQL - Character to keep a piece of text
In Mysql a possible solution would be to search through REGEXP for all emails ending in @jf.gov.br. UPDATE Tabela SET email = REPLACE(email, '@jf.gov.br', '@jf.jus.br') WHERE email REGEXP…
-
13
votes2
answers1081
viewsA: What are the advantages and disadvantages of Duck Typing?
Disclaimer: Like the utluiz, I am also Javeiro. In particular it schools strongly and statically typed languages; I believe in complex typing systems and compilers able to eliminate inconsistencies…
encoding-styleanswered Anthony Accioly 20,516 -
3
votes3
answers14892
viewsA: function $.Ajax() return value?
The value returned is in the parameter data of its role of callback in case of success: success: function( data ){ console.log("data ="+data ); } The call $.ajax itself is asynchronous by default…
-
5
votes2
answers595
viewsA: @Named does not work JSF
This happens because the annotation @Named is part of the package javax.inject, that can be consumed by JSF but is not part of the technology itself. Use a complete Java EE container such as…
-
3
votes1
answer148
viewsA: Development of mobile games
The Java ME 8 SDK contains the Apis of previous versions (and the novelties of JSRS CLDC 8 and MEEP 8), including Midlets. For more information you can read: Documentation for Java ME SDK 8…
-
7
votes3
answers6508
viewsA: Difference in postgresql date months
You can achieve the value in months by extracting the parts manually and doing the mathematical operations involved. Unfortunately Postgresql does not have a function DATEDIFF to simplify these…
postgresqlanswered Anthony Accioly 20,516 -
1
votes1
answer243
viewsA: Check which Websocket sessions are inactive
The method isOpen() only indicates the status of the connection according to the Websocket protocol (i.e., if one of the sides did not close the connection, for example, with the method close…
-
0
votes2
answers572
viewsA: Primarykey, Foreignkey and Unique With JPA
In all cases you will need a composite key (since on the bank side the PK is composed the JPA must keep this model). This can be done in two ways: Id entity + @IdClass public class…
-
4
votes1
answer1144
viewsA: Calling Java class inside Oracle
Yes, it is possible to call Java code within the Oracle database. Following is link to official documentation: http://docs.oracle.com/database/121/JJDEV/chthree.htm#JJDEV13167. See Oracle example,…
-
2
votes1
answer263
viewsA: Integration between Spring and JPA
Turning my comment into a response. For stack trace: Caused by: java.lang.IllegalAccessError at net.sf.cglib.core.ClassEmitter.setTarget(ClassEmitter.java:45) at…
-
1
votes1
answer1606
viewsA: Correlation Matrix in R (cov.wt)
Reading the source code of function cov.wt vi references to the functions cov2cor and cor. If these functions do not return the exact same function result above you can implement your own solution…
-
3
votes2
answers64
viewsA: How to iterate over a huge amount of records with scala sorm
The methods Querier.fetch and Querier.fetchIds return streams, which doesn’t mean you can’t run out of memory if you have to work with all the returned objects at the same time. The object Query…
-
1
votes2
answers4146
viewsA: Plugin that applies zoom when mouse pass
A brief Google search gave me good results: Elevate Zoom: http://www.elevateweb.co.uk/image-zoom/examples - Internal and external zoom, various Divs positioning customizations, custom cursor during…
-
4
votes2
answers148
viewsA: Detect when a form is sent
You can use the onsubmit: <form onsubmit="return minhaFuncao();"> function minhaFuncao() { alert('Minha funcao'); // Se retornar true deixa a form ser submetida return false; }…
javascriptanswered Anthony Accioly 20,516 -
8
votes2
answers917
viewsA: Check if parenthesis has been closed
You are looking for a parenthesis balancing algorithm. Algorithm Definition: Go through the String character by character recording the amount of open parentheses and the number of closed…
-
2
votes1
answer1184
viewsA: matrix multiplication with minimum maximum of each line
Create an auxiliary function to calculate the largest element of a vector: int maxElement(int array[], int arraySize) { int max = array[0]; int i; for (i = 1; i < arraySize; i++) { if (array[i]…
canswered Anthony Accioly 20,516 -
0
votes2
answers1316
viewsA: How to Inhibit Display of Information on the Eclipse Console using Hibernate
Only complementing the answer of colleague Kyllopardiun, follows a free translation of Hibernate-specific log categories table: org.hibernate.SQL Log all SQL DML commands as they are executed…
-
1
votes1
answer187
viewsA: Modularization without OSGI in Web project
From what I understand its requirement is to basically separate implementations of certain interfaces from the core. These implementations are in projects jar apart from your main web project. The…
tomcatanswered Anthony Accioly 20,516 -
2
votes2
answers146
viewsA: GIT error with Mac OS X: dyld: Lazy Symbol Binding failed: Symbol not found: _iconv_open
Try pointing the variable to a real path from the iconv in your system. Assuming your system has a version of the /usr/lib (on my OS X Mavericks it’s there, but I installed a lot of extra stuff on…
-
2
votes1
answer1794
viewsA: Capturing events on a button
There is a good tutorial from Oracle on how to instantiate and register Listeners, deal with events, etc (link). From the conceptual point of view events, producers and listeners exist to separate…