Posts by Luiz Vieira • 34,160 points
330 posts
-
2
votes2
answers811
viewsA: How to create sublists with numerical elements that are in a sequence?
If you can use the library Numpy (which I strongly advise), a way very simple to achieve this is with the following code: # Sua lista original lista = [1, 2, 2, 3, 3, 3, 6, 6, 7, 11, 12, 12, 13, 14,…
-
3
votes1
answer6913
viewsA: Excel VBA - How to use Vlookup with Letters and Numbers to Delete Queues?
Here’s an example of code that does what you want: ' Verifica se um dado dígito é um número. Retorna True se for, False se não for. Function ehNumero(ByVal digito As String) As Boolean a =…
-
6
votes3
answers464
viewsA: Should the checkbox label be on the right or left of the controller?
A checkbox (checkbox) represents a binary option that can be checked or unchecked by the user. Thus, far more important than the organisation of the accompanying text is affordance selectable…
-
48
votes5
answers991
viewsA: What is UX (User Experience)?
UX stands for "User Experience" (User Experience, in the English original). It refers to a field of study within the Human-Computer Interaction (IHC) that seeks to understand how people’s…
-
2
votes1
answer293
viewsA: Calling Progress bar class from another file
The problem is that you create (instance) your class object ProgressBar within the slot click the button (within the call of test_progressbar). Thus, the scope of this variable is only that function…
-
15
votes5
answers1252
viewsA: What are the advantages and disadvantages of using pagination and infinite scroll on websites?
What does the user gain or lose when choosing one of them? Consequently what website owner has some gain in function of the best user experience. From the user’s point of view: in paging it has more…
-
2
votes1
answer83
viewsA: How to take care of status in one part of the system?
A review (after all, there are unclear things in the question): Your current table configuration contains a table called PERGUNTA, which stores the question data and contains a foreign key for the…
answered Luiz Vieira 34,160 -
6
votes3
answers304
viewsA: What is the difference between the modules Math and cmath?
As described in the documentation, the module cmath "provides access to mathematical functions for complex numbers". In fact the functions of this module also accept integer and real numbers, and…
-
6
votes2
answers1080
viewsA: How to calculate the time from point A to B?
Observation 1: Your question has the tag python, then I will respond with a hint of how to do this using Python. But if your data is maintained in an SQL database, it is certainly much better you…
pythonanswered Luiz Vieira 34,160 -
4
votes2
answers137
viewsA: How do I compare the keys of a hash to a user input?
Although you already have a good answer, it is worth noting that your code already works and you no need for csv library. Your dictionary rexh is already being created with the data of the surfers.…
-
4
votes1
answer183
viewsA: Help with Signal and slots (connect in another file slot)
Here is a suggested solution. The class DialogForm already receives the class instance pointer MainWindow in the constructor (variable track parent). Then, in this constructor, make the connection…
c++answered Luiz Vieira 34,160 -
19
votes2
answers1804
viewsA: Format String "28122016" for "2016-12-28" date
The best solution is to use the ready-made package functions datetime. Example: from datetime import datetime d = datetime.strptime('28122016', '%d%m%Y') print(d.strftime('%Y-%m-%d')) See working in…
-
5
votes2
answers516
viewsA: Function IF Nested?
You must use the fução E to make the union of more than one condition. Thus, a possible response to what you want is: =SE(E(G6>=20;G6<=30); 100; SE(E(G6>30;G6<=40); 200;…
excelanswered Luiz Vieira 34,160 -
3
votes1
answer2948
viewsA: Split numbers of an int. C++
In your own text you have: "Tip: Use integer and module splitting operators". That’s the real tip. Suppose you read the whole number 42339, as you yourself illustrate. If you divide it by 10, you…
c++answered Luiz Vieira 34,160 -
13
votes5
answers5611
viewsA: Draw square on the canvas using wire fences (#)
Another possible solution (with flexibility of the drawing with parameters for the border and filling): def desenhaQuadrado(altura, largura, simbolo = '#', preenchimento = ' '): print(simbolo *…
pythonanswered Luiz Vieira 34,160 -
2
votes1
answer1560
viewsA: How to make a python script run two processes simultaneously?
Here’s an example of code that reads on a separate thread. The idea of storing the tables read in a list (which in practice acts as a fila fifo) is because your processing of the frames received in…
-
2
votes2
answers470
viewsA: How do I get Qt 5.7 with MSVC2015 to work?
Your Qtcreator error is probably some wrong configuration even (as the error message indicates). If you’re going to use it, I suggest you try to recreate the 2015 VS Kit (follow the Qt Creator…
-
5
votes1
answer289
viewsA: What is the difference between using #include "stack. h" or using the class statement ?
They’re not options, since they don’t do the same thing. In doing #include "um.h" you in fact includes the class header file (supposedly already defined), so that from then on (where it is including…
-
6
votes1
answer3590
viewsA: How do I send a file as an attachment by email without automatically renaming it?
You are not setting the name of the attachment, so a generated name is being used. Try changing the line: mime=MIMEImage(f.read(),subtype='jpg') for: mime=MIMEImage(f.read(),subtype='jpg',…
-
2
votes2
answers494
viewsA: How to calculate the Xmin,Xmax,Ymin,Ymax of an object?
You just iterate over the vertices and save the smallest/largest comparing to each new observed vertex. But for this you will need to keep the vertices in a list/vector (today you only draw them).…
-
9
votes1
answer14432
viewsA: Calculation of Sine with Python
The problem is that the calculation of the cosine approximation is incorrect. If you observe the taylor series cosine, you will see that the value starts with 1 - but you start the variable…
-
7
votes1
answer1728
viewsA: How to save a video captured by webcam without showing it using Opencv in python?
The problem is that the function waitKey Opencv depends on the existence of a window to capture a pressed key (i.e., the key is actually pressed in the context of the window which therefore needs…
-
3
votes3
answers603
viewsA: How to check any received type (upper or lower case)?
Simple: convert text to uppercase and compare. Example code in C++: #include <iostream> #include <string> #include <algorithm> using namespace std; bool compare(string s1, string…
c++answered Luiz Vieira 34,160 -
11
votes1
answer392
viewsA: Create algorithm for fluid simulation?
Yes, there are some strategies. To begin with you don’t simulate the whole "ocean". You only simulate the area or region of the fluid that will have some contact with the player’s avatar (or an…
-
5
votes1
answer258
viewsA: after creating a file(.txt) iterate from a line that is not the beginning
Assuming your first line has the number of lines to ignore (you didn’t make that exactly clear), just do so: try: file = open('teste.txt', 'r') # Lê o número de linhas a ignorar n =…
pythonanswered Luiz Vieira 34,160 -
1
votes1
answer253
viewsA: Python Load Serialization Files
Well, like I said, running an external script the way you suggest is dangerous because you have no way of knowing what’s there to run. If your need is only to receive data that is easily…
-
4
votes2
answers2422
viewsA: How to get a list of processes running windows in python?
For a solution cross-Platform, use the package psutil. 1 - Install it from github or (easier) with Pip: pip install psutil 2 - Run the following example program: import psutil as ps print('Lista de…
-
3
votes1
answer1006
viewsA: Ioerror: [Errno 24] Too Many open files
Really, you are opening all the files for each frame of the video. While doing: images = [Image.open(filename) for filename in framesMap] You are generating a list (images) with the Handles of each…
-
3
votes1
answer65
viewsA: Memory leak in Return
The function TheFunction does the following: SimpleCat * pFrisky = new SimpleCat(5,9); This line dynamically allocates an instance of the class SimpleCat, points your memory address to the variable…
-
2
votes2
answers303
viewsA: Incorrect python value conversion
To Reply by @Priscilla is sufficient and in fact the best choice for the vast majority of cases. However, if your crowler need to handle money in different formats, it may be useful for you to…
-
10
votes2
answers6367
viewsA: Open, edit and save a binary file in Python3
Yes, it is possible. Consider a binary file called teste.bin example with the following content (hexadecimal bytes): A0 B0 C0 D0 E0 F0 The following code reads these bytes and changes the byte…
-
5
votes3
answers2432
viewsA: How to speed up a script to full speed in python?
Without analyzing your code in depth, just pounding your eye really quickly, I’ve already noticed a critical point that can be easily improved: the call of sqrt for the calculation of the…
-
11
votes4
answers843
viewsA: How to limit the generation of pseudo-random numbers to non-zero and non-repeating numbers?
If you want non-repeated numbers in a range ([1, 60], for your example), a very simple solution is to make a random permutation. Using numpy is pretty easy with the function…
-
5
votes1
answer229
viewsA: Typeerror: a float is required
The error that is occurring is due to the fact that you are using an object Dataframe of Pandas and not a list of values (in the contents of the variable x). If you put, right there at the beginning…
-
4
votes2
answers3252
viewsA: How to use sys.Arg for data entry
Miguel’s answer already gives you the way and is the simplest, most direct and immediate solution (I even suggest the accepted answer). But remember that there is also the package argparse which is…
pythonanswered Luiz Vieira 34,160 -
6
votes2
answers93
viewsA: Is it possible to use Elide with Qlabel?
There seems to be nothing native. But you can use the method QFontMetrics::elidedText to implement an "elided text" of a line. Here is an example (original source for example in Soen): QString…
qtanswered Luiz Vieira 34,160 -
2
votes3
answers4668
viewsA: How to compare one to one all the elements of two vectors?
There is no native function that does this because this comparison makes no sense as a general purpose resource. That is, you may have some need to make this comparison, but a vector has very broad…
c++answered Luiz Vieira 34,160 -
2
votes1
answer475
viewsA: Graphics in pdf in R
Use the function pdf Example: pdf('grafico.pdf') H <- c(2,3,3,3,4,5,5,5,5,6) counts <- table(H) barplot(counts) dev.off()…
-
11
votes2
answers110
viewsA: Why is the output coming out like that?
The reason of None is because the function map performs its functions for each element in the list, so that a return on these functions is always necessary. As you do not return anything in the else…
-
3
votes1
answer338
viewsA: Open text file in Python package
Do it like this: 1- Get the module installation directory: import os modulePath = os.path.dirname(os.path.abspath(__file__)) 2-Use this path to find the file: fileName =…
-
25
votes8
answers3166
viewsA: Fewer moves from a horse to a given house in Chess
A possible algorithm involves minimizing the distance between the horse and the target piece until you capture it. Try to do so: In the current position, the horse has only a limited number of…
-
2
votes2
answers233
viewsA: How to know how many "black" pixels you have in a letter x, using an x font?
The question does not say exactly everything. You mention the font of the letter, so I imagined that your need involves knowing the dimensions of a text to do something about, and not necessarily…
c#answered Luiz Vieira 34,160 -
3
votes2
answers131
viewsA: When generating an image, I just want to visualize it and not save it
Create a JFrame, inside it add a JLabel and set the label content as an image using a ImageIcon encapsulating your BufferedImage. Example: import java.awt.Color; import java.awt.FlowLayout; import…
-
4
votes2
answers2354
viewsA: Concatenate arrays using numpy module
Suggested solution (the sample arrays A and b could be created more automatically, but so I thought the example would be more didactic): import numpy as np A = np.array([ [1, 2, 3, 4], [5, 6, 7, 8],…
-
3
votes1
answer2037
viewsA: Sockets - Tic-tac-toe / Rooster Game MULTIPLAYER
By the example of code you provided, you seem to have understood that communication via socket allows you to send and receive messages. Ok. But you insist on trying to run a function remotely (or…
-
2
votes1
answer6338
viewsA: Python matrix manipulation with numpy module
If by "exchange" you mean transpose rows x columns, you do so: import numpy as np teste = np.array([i for i in range(1,41)]).reshape((10,4)) print('Normal:') print(teste) print('Transposta:')…
-
1
votes1
answer728
viewsA: Help with a simple game
The main problem with your code is that you create a new object Ball every new frame of the game. In addition to causing the unwanted effect, you are absurdly consuming the memory of your game. The…
-
7
votes1
answer3076
viewsA: How to create text in a python image?
There are several ways to do it. You can use the package PIL (Python Image Library), can use the package matplotlib, can use the package scikit-image and so on. You can also use screen creation…
pythonanswered Luiz Vieira 34,160 -
2
votes1
answer281
viewsA: Add photo in excel from local folder
When you say you "edited" I’m guessing you changed that code snippet: With oImage .Left = oCell.Left .Top = oCell.Top .Width = oCell.Width .Height = oCell.Height End With For that reason: With…
-
23
votes1
answer1939
viewsA: Computational Geometry: Determine nearest neighbor
Yes, there are some. Possibility 1 The simplest and most direct possibility is to calculate the distances k to each of the points in the set, sort these values in ascending order, and then choose…
algorithmanswered Luiz Vieira 34,160