Posts by brow-joe • 2,144 points
69 posts
-
4
votes2
answers15237
viewsA: How to remove accent in Python?
Use unidecode: from unicodedata import normalize source = 'Arapeí' target = normalize('NFKD', source).encode('ASCII','ignore').decode('ASCII') print(target)
-
1
votes2
answers1539
viewsA: c3p0 error - bad pool size config start 3 min 5. using 5 as start
It’s not directly an error, it’s just an alert, apparently you’re not setting the initial value for the datasource. By default the initial value is 3, and according to this excerpt: if ( start <…
-
2
votes1
answer819
viewsA: Python - Dividing words delimited by blank space or square bracket
Well, the idea is basically to work with clusters. The first step is to identify the data pattern to mount the proper regex. Based on the information provided I identified the following pattern:…
-
10
votes2
answers2065
viewsA: What is "positive zero" and "negative zero" in float and double types?
The Java programming language uses the IEEE 754 standard for floating point arithmetic that defines -0.0 and when to use. The smallest representable number does not have 1 bit in meaning subnormal…
-
1
votes1
answer115
viewsA: Generate grid with random characters - java
This is why in this passage: StringBuilder sb = new StringBuilder(row); for (int j = 0; j < grid[i].length; j++) { sb.append(AB.charAt(rnd.nextInt(AB.length()))); sb.toString(); grid[i][j] =…
-
1
votes1
answer262
viewsA: Word processing
An example of word counter could be done as follows: import sys text = "Num ninho de mafagafos há sete mafagafinhos. Quando a mafagafa gafa, gafam os sete mafagafinhos." wordcount={} for word in…
-
1
votes2
answers255
viewsA: Mask in Textedit
There is a library developed by jansenfelipe, you can find a tutorial at this link more basically you need to add the following dependency: dependencies { compile…
-
1
votes6
answers7179
views -
0
votes1
answer83
viewsA: Problem with using Java lists
You can work with the ConcurrentSkipListSet, he work the same as Set however it is appropriate to work in multithreads and also more secure with respect to data order, follows an example // Define a…
-
1
votes1
answer201
viewsA: Annotation or method to ignore field (Xstream 1.3.1)
See if it solves: XStream xstream = new XStream(new DomDriver()) { protected MapperWrapper wrapMapper(MapperWrapper next) { return new MapperWrapper(next) { public boolean…
-
0
votes6
answers49406
viewsA: how to search for an element in a list that is inside another list?
There is a little cleaner way that you can do, basically consists of searching within the list all the objects that are part of the condition, for this we use the filter and the lambda after this,…
-
7
votes2
answers4257
viewsA: Spring Boot x Spring MVC
Spring MVC is a structure MVC complete based on HTTP managed by Spring Framework and based on Servlets. It would be equivalent to JSF in the pile JavaEE. The most popular elements in it are classes…
-
1
votes1
answer1296
views -
1
votes1
answer279
viewsA: How to add an event to an icon?
To add a listener in a jLabel you can use the addMouseListener, passing as a parameter an implementation of MouseListener called MouseAdapter, making it over-written only in the method mouseClicked.…
-
2
votes1
answer3603
viewsA: Spring Boot application does not rise - org.springframework.Beans.factory.Unsatisfieddependencyexception
Good see if it works, I use this way, inside the pom put these dependencies (JDBC, Spring-data-jdbc and the postgresql driver: <dependency> <groupId>org.springframework</groupId>…
-
0
votes2
answers53
viewsA: How is it possible to condition or check an item in a listview?
To identify the item clicked inside the listview you will need to use the method setOnItemClickListener, in it there is an integer parameter called position, on it is the position of the list that…
-
1
votes1
answer1045
viewsA: Configure Log4j appender to display in the log console from Error and save in logs file from Info
The problem is in the log4j configuration log4j.properties To set it up properly recommend setting in rootLogger always the lowest level (DEBUG) for all the appenders that you will use, then when…
-
2
votes1
answer745
viewsA: Create a graph from values of a calculation
To change what exists inside a Jpanel, you need to use the command .revalidate, This will inform AWT that you have changed the component tree. You’ll need to restructure your code to make it more…
-
1
votes2
answers213
viewsA: Jpanel width exceeding the dimension defined in getPreferredSize()
Logic is right, there is only one condition in the method move of Ball that can be changed, actually when you do: if (x >= board.WIDTH - DIAMETER || x <= 0) { .... } is getting a 30px…
-
10
votes2
answers98
viewsA: Why println ran before printStackTace?
At first an operating system works with 3 rows System.err (flow output for standard error stderr), System.out (standard flow output stdout) and System.in (stdin data input) When using the…
-
1
votes2
answers788
viewsA: How to add text + icon to the label?
To insert an icon into the label you need to load the image, convert to icone and then insert it into the label. You can do using the setIcon in this way: public LabelIcone() { setSize(400, 200);…
-
1
votes2
answers1083
viewsA: Sort a. csv file from the numeric column
A simpler way to do this is to separate all lines of csv \n and after that separate all csv columns ;. After aggregating all rows and columns in a list just give a Sort in the expected column, you…
-
1
votes1
answer1291
viewsA: Create new DF based on a Pandas column
You can give the distinct in the field SRC with the command unique and after this assemble the dataFrames you need for example: uniques = df.SRC.unique() print(uniques) dataFrames = [] for unique in…
-
3
votes1
answer1608
viewsA: Help with Strike Match Similarity Algorithm
When you try to find similarity between sentences, it is not a good idea to use n_grams of the entire sentence because it will find very similar passages and "find" that the two sentences have a…
-
0
votes1
answer172
viewsA: Txt Manipulation - Separating blocks based on a pattern
You can use the following regular expression: ^1 - Where the ^ indicates the beginning of a line followed by the character you are looking for in case the 1. I made an example that I split the text…
-
0
votes2
answers328
viewsA: how to make the time appear in the window(label)?
You need to create a label in your window, after this you need to render and set the update logic of the label where the time will be displayed. using your code, I made some adaptations, see if it…
-
3
votes2
answers3673
viewsA: Linear regression with python
According to the own documentation of scipy it doesn’t turn very well in Windows because it has some dependencies that only work in linux and mac Alternatively, I recommend using sklearn, she is a…
-
1
votes1
answer782
viewsA: How to read xml for object with Xstream
Can you convert the XML for the object Produto using the XStream in this way: public Produto xmlToProduto(String xml) { XStream xstream = new XStream(); xstream.alias("produto", Produto.class);…
-
0
votes1
answer84
viewsA: How to write this xml bean using java?
A way to write this bean is as follows: @Configuration public class ThymeleafEngineConfiguration { @Bean @ConditionalOnMissingBean(SpringTemplateEngine.class) public SpringTemplateEngine…
-
1
votes1
answer893
viewsA: How to increment number from a button click
Good morning, for you to be able to do this increment and decrement control you will need a accumulator you can use the field itself as accumulator for example, with some minor modifications to your…
-
2
votes1
answer445
viewsA: Help python by taking only the last data from the list
You can create an object with the attributes name and surname class Objeto(object): def __init__(self): self.nome = '' self.sobrenome = '' after this you will need to work with arrays, the idea is…
-
2
votes1
answer741
viewsA: Create dataframe tuples generated by Pandas
Good afternoon You can do it this way: tuples = [tuple(x) for x in df.values] For you to take the tuples per column would be something like this: colunas = df.columns.values tuples = [tuple(x) for x…
-
2
votes2
answers4543
viewsA: Turn columns into python pandas rows
Good afternoon, you can do this using the command melt Below is the test I did: Import the input data import pandas data = pandas.DataFrame({'Local':['são paulo','rio','bahia'], '01/09/2007':…
-
3
votes2
answers112
viewsA: Use same sorting algorithm with different attributes
Good afternoon, according to your code, I believe that the simplest way to make the attribute-based Sort would be more or less this way: Create an Enum for fields that can be ordered public enum…
-
1
votes2
answers116
viewsA: How to keep the last 100 objects inserted in an Arraylist?
The simplest way to solve this problem is to apply the concept of FIFO (First in, first out). Fifo refers to a row-type data structure. Lists are widely used in programming to implement queues. In a…
-
1
votes4
answers1921
viewsA: Hibernate does not create table automatically in mysql
Missing add the dialect in their properties spring.datasource.url=jdbc:mysql://localhost:3306/clientesdb;create=true spring.datasource.driver-class-name=com.mysql.jdbc.Driver…
-
1
votes2
answers724
viewsA: Regular expression to deny anything other than social reason
Good afternoon, I believe you can search the entire set of words within the expression: I made a test, it follows below: Blush Set the Voce regular expression can make the escape to java with the…
-
0
votes2
answers689
viewsA: Date value 0000-00-00 cannot be used in java Date
In Mysql 0000-00-00 is considered a valid date, but cannot be represented as java.sql.Date. You can use a query that returns NULL in the event of a date 0000-00-00, or the actual value otherwise:…
-
1
votes1
answer162
viewsA: inverse java Sort shell
Good evening, to change from crescent to descending in your code, just change the condition aux < v[j] for aux > v[j] for example: private static void shellsort(int v[], int n, boolean…
-
0
votes1
answer437
viewsA: How to iterate over a stream from a list that has an array and return if true?
Good night, see if this resolves: create a method to compare whether the item is present within your array public static boolean contains(final int[] array, final int key) { Arrays.sort(array);…
-
1
votes3
answers92
viewsA: Manipulate String in JAVA?
There are some ways: indexed String result = "[email protected];[email protected]"; int index = result.indexOf(";"); if (index > 0) { result = result.substring(0, index); }…
-
2
votes4
answers392
viewsA: Program that returns the unusual numbers of two lists (python)
Good evening, following your logic I believe the most correct would be: def indice(a,b): ind = []; for ea in a: if (not (ea in b)): ind.append(ea); for eb in b: if (not (eb in a)): ind.append(eb);…
-
0
votes2
answers610
viewsA: How to get name of objects contained in JSON with Java?
You can use the Gson: <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.0</version> </dependency> if you…
-
1
votes3
answers4536
viewsA: How to select a piece of the Java string?
Still using regular expression you could catch the grouping public static void main(String args[]) { String x = "@646646&"; Pattern regex = Pattern.compile("@(.+)&"); //Ou se sempre fosse…
-
4
votes2
answers791
viewsA: Approve or refuse a request through Handlerinterceptoradapter
Good morning, the most viable, reliable and appropriate solution in your case I believe would be to work with the spring-security: pom <dependency>…
-
6
votes1
answer116
viewsA: list.clear() vs list = new Arraylist<T>()
When you use list.clear() you really clear the list and take advantage of the same memory space where it is already allocated. When you use list = new ArrayList<>() vc creates a new instance…
-
1
votes3
answers2111
viewsA: Comparing C string contents to find palindrome
Good afternoon, see if this helps you: #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 20 int main(){ char palavra_a[N], palavra_b[N]; int i,j=0,flag=0;…
-
0
votes1
answer205
viewsA: Create an exception on purpose
Depending on the problem you should "customize" an exception, and it is good practice to help you have better control over your application code. I’ll put together an example to customize an…
-
1
votes1
answer77
viewsA: Exception error in thread "main" in my Array
Good afternoon, as your problem, you can solve by putting carrinho[i] = new Produto(); just below your for, a point of attention is with respect to the array you are using, Produto[] carrinho = new…
-
1
votes1
answer763
viewsA: JSON doesn’t convert special character?
Apparently your ide is pointing another enconding. If your project is using Maven, just add in . pom the following property: <properties>…