Posts by Rogério Dec • 1,511 points
66 posts
-
1
votes1
answer137
viewsQ: Image is being cropped when the "max-width" CSS element is used
At the bottom of this Wordpress site there are various logo images. These images are entered by the site administrator himself within a table Pods, so I have no individual control for each image, I…
-
18
votes5
answers1841
viewsA: Why are there so many programming languages?
There are several reasons: Natural evolution of languages: in the same way as in human language, where she was born with simple phonemes and according to the evolution of the human being and its…
language-independentanswered Rogério Dec 1,511 -
0
votes1
answer55
viewsA: List directory files and subs-directories
Translating this answer: You can use glob() with the option GLOB_ONLYDIR or $dirs = array_filter(glob('*'), 'is_dir'); print_r( $dirs);…
phpanswered Rogério Dec 1,511 -
13
votes1
answer816
viewsQ: How to make an excellent C++ program without C traces?
As a beginner in C++ I asked some questions here and was warned a few times by @Maniero that what I was doing was C and not C++. The problem is that C++ allows us to use many things similar to C. So…
-
0
votes1
answer28
viewsQ: Protect Mysql table against drop
I have a Wordpress module (Cerber) that for some obscure reason, is deleting a table (cerber_files). The developer does not manifest. I wonder if there are any commands that prevent a mysql table…
mysqlasked Rogério Dec 1,511 -
0
votes3
answers1982
viewsQ: "for" with step "float": Typeerror: 'float' Object cannot be Interpreted as an integer
I want to loop 0 to 100 with step 0.1: for x in range(0, 100, 0.1): a = cos(radians(x)) But I get this mistake: Typeerror: 'float' Object cannot be Interpreted as an integer How can I make a loop…
-
3
votes1
answer973
viewsQ: Why doesn’t Python use 100% of the processor?
I’m developing a Python application where in some parts, it requires a lot of CPU for calculations. However, I realize that even at these "bottleneck" points, the CPU never reaches more than 50% of…
-
2
votes1
answer585
viewsQ: Error: "illegal target for variable Annotation" using "@Property"
Like pygame does not have a function similar to the library SFML -> View, I am developing a "camera" format to scroll the screen and preserve the positions of objects within the general…
-
1
votes1
answer130
viewsQ: How to create a "trigger" function when a variable changes value?
Watching pygame.Surface.get_rect(), I realize that when I change a variable, for example left, pygame automatically recalculates all class variables (center, right, etc.). I’d like to know how it’s…
-
0
votes4
answers658
viewsA: Debug showing variable name and value?
Use eval is the solution. Here’s my new job debug, which is simple. You just need to put the variable names in a string list: def debug (vars): for var in vars: print (var, "=", eval (var)) Example:…
-
1
votes4
answers658
viewsQ: Debug showing variable name and value?
Often when I need to debug the value of a variable at runtime I use the print(). But when there are many variables, I need to identify the variable name along with the value. In this way, the print…
-
1
votes1
answer188
viewsQ: Complex operations with Python (pygame.math.Vector2)
I am learning Python and I came across a complex expression that derives from pygame.Vector2: import pygame x = pygame.math.Vector2(1,2) b = x * 5 - (1, 2) print(x) print(b) Upshot: [1, 2] [4, 8] In…
-
1
votes0
answers47
viewsQ: Absurd performance difference between pygame.surfarray.array3d and array2d
Using the pygame.surfarray to control an image as an array, manipulating any element in an array3d is more than 5 times slower than manipulating an element array2d. See this benchmark: from datetime…
-
-1
votes3
answers229
viewsQ: Python is not so "smart" for redundant operations
Unlike many cases in c++, Python is apparently not so smart to optimize redundant operations, even between constants. I made a simple benchmark to test math.cos inside and outside a loop. In this…
-
1
votes1
answer331
viewsQ: How to get a pixel color out of the screen limit in pygame?
I know to get a color of a pixel in Pygame I use get_at. But I have a huge background image and a lot of it is outside the screen area delimited by pygame. For example, a 1000x1000 image inside a…
-
3
votes1
answer690
viewsQ: What is the difference between classes initialized with (and without) __init___
I’m a beginner in Python and I wanted to understand a difference. The two classes below produce exactly the same result and the variables become public in the same way in both classes: class c(): t…
-
0
votes2
answers107
viewsQ: How do you inherit a pygame class?
When I run this code (this is the current entire code, ie only 3 lines): import pygame class sp(pygame.sprite): pass I get: Typeerror: module() takes at Most 2 Arguments (3 Given) I would like to…
-
2
votes1
answer323
viewsQ: How to copy an array of struct to an equal one?
I have 2 arrays made of a struct: struct events { string Kind; int Time; int DurVal; int Chan; }; events e1[100] events e2[100]; How can I make a full copy of the array e1 for e2 in a single…
-
3
votes1
answer221
viewsQ: Algorithm for connecting dots on a graph with curved lines
I need to develop an algorithm that connects dots in a way nonlinear, that is, with smooth curves, as in the image below: The problem is I can’t find the best solution, whether using Bezier curves,…
-
2
votes1
answer65
viewsQ: How do edits count during debug?
When I am debugging a code in Pycharm (Shift+F9) and make some changes, it is not recognized during the same debug session. I am obliged to restart the debug again for the changes to be recognized.…
-
3
votes1
answer167
viewsA: Memory overflow with mysqli_query
Based on @Bacco’s comment, I researched and realized that actually the command mysqli_query loads ALL records into RAM. That is, for large tables, it will actually generate a memory limitation. The…
-
5
votes1
answer167
viewsQ: Memory overflow with mysqli_query
The following instruction stopped the program: $result = mysqli_query($db, 'SELECT * FROM base'); And returned the following error: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted…
-
1
votes4
answers653
viewsA: Cross values in array
EDITION: This solution will only be feasible for a limited number of items, not by space, but by the processing time due to the large number of possible combinations. To know how many combinations…
-
2
votes4
answers653
viewsA: Cross values in array
It took me eight hours to develop the algorithm, but thanks for the challenge. Here is the code: <?php $total = 3.60; // valor total a ser testado echo "Para um total de $total:\n\n"; $dados =…
-
4
votes1
answer2511
viewsA: How to activate automatic line breaking in Pycharm?
In the editor, right-click on the number of lines and activate "Soft-Wrap":…
pycharmanswered Rogério Dec 1,511 -
1
votes1
answer334
viewsA: Create a new table for optional values
Mysql is "smart enough" to take up little space for null fields. Therefore, creating an auxiliary table only to register optional fields, in addition to being laborious, may take up even more space…
-
2
votes2
answers138
viewsA: group columns in mysql
This code solves: SELECT TIME, SUM(J.PONTOS) AS PONTOS FROM ( SELECT TIME1 AS TIME, PONTOSTIME1 AS PONTOS FROM JOGOS UNION ALL SELECT TIME2 AS TIME, PONTOSTIME2 AS PONTOS FROM JOGOS) AS J GROUP BY…
-
1
votes2
answers1303
viewsA: How to validate an email in c
First, your program has some errors: The formatting is quite messy Don’t have the #includes Instead of if(email[i] > 3) should be if(i > 3) The line if(ponto=1 && email[i] >=2) you…
canswered Rogério Dec 1,511 -
1
votes1
answer716
viewsA: Image html mapping that works on mobile
This site (https://www.zaneray.com/responsive-image-map/) generates the responsive html/css code that will be required for your map. Insert the image of your map there…
-
0
votes3
answers312
viewsA: Could help me count the number of characters in a word in PHP
You can access characters from a string as if it were an array. Note: as warned in the comments, accented characters (UTF-8) occupy two spaces instead of one, so to detect this type of character, we…
-
0
votes2
answers1214
viewsA: Levels in the game of old
Here’s the code I made (player against computer). It is not AI, but the computer can play at the "beginner" (for children) and "expert" level (where it does not fail). Then I did it to learn Java,…
pythonanswered Rogério Dec 1,511 -
3
votes2
answers2309
viewsQ: What is the isset equivalent of PHP in Python
In PHP, if I want to know if a variable has been started, I use isset. How can I do the same in Python?
-
1
votes3
answers416
viewsQ: How to Insert in a non-zero position in an empty list?
How can I insert a value in a non-zero position into an empty list? Ex: lista = [] . . . lista.insert(3, 'valor')
-
3
votes2
answers3768
viewsQ: What is the equivalent of PHP explode in Python?
In PHP, if I want to split a string into several parts based on a delimiter, I use explode. How can I do the same in Python?
-
0
votes2
answers723
viewsA: Autocomplete doesn’t always work on Pycharm
It was a bug of the current version. Solved by downloading the new version on Pycharm Early Access Program.…
-
1
votes2
answers723
viewsQ: Autocomplete doesn’t always work on Pycharm
I am starting the use of Pycharm, creating a test with Pygame. I realize that some Pygame methods do not appear in Pycharm Autocomplete. For example, if I want to put one pygame.mask.from_surface(),…
-
0
votes1
answer89
viewsA: Read . txt, set delimiter, remove duplicates
One way to avoid element duplicity is to use the element as the index of an array. So every time you play the same index on it, it will be disregarded. So, from what I understand of your question…
phpanswered Rogério Dec 1,511 -
0
votes2
answers1221
viewsA: How to format a txt file by inserting columns and changing date and time format with php script
This solution should help you: <?php $linha = "0000000001 001 00000000000090000001 01/01/2014 00:00:38 1 0 5"; $partes = explode(" ", $linha); $i = 0; foreach ($partes as $campo) { echo 'campo' .…
-
1
votes1
answer31
viewsQ: vector inside vector generates double values in the second dimension
In the example below (which can also be seen in Ideone), I have a vector of a class and within the class I have an element too vector. The point is that by doing the push_back class, the internal…
-
1
votes1
answer275
viewsQ: How to put classes inside vector and manipulate variables with push_back?
It’s definitely something simple, but I researched and didn’t understand how to do. If I have for example the following class, with two variables: class x { public: int var1, var2; }; I want to…
-
0
votes1
answer811
viewsA: WP plugin to show post time
In the administrative menu: Options -> General, go in the field Date format and select the option Personalized. There you can create a specific output format. If you put the format j \d\e F \d\e…
-
1
votes2
answers1967
viewsQ: How to send current screen resolution to PHP (on first load)?
I know there are several ways to get the screen size by javascript, etc, but I haven’t found a satisfactory way to get communicate this size to PHP BEFORE screen loading. For example, I would like…
-
1
votes0
answers47
viewsQ: Should I really use getters and setters for all public variables in the classes?
So this subject seems very controversial but at the same time I don’t see a call among developers. Some say that getters and setters are 100% rule to access any variable within a class. That is, if…
-
5
votes2
answers111
viewsQ: Should I avoid repeated access to the same method within a loop?
I worry about the final performance of an executable, at the same time I don’t want to penalize the programmer with excessive or unnecessary care in the code. In the code below, for example, it will…
-
3
votes2
answers3378
viewsQ: How to print UTF-8 characters on the c++ console?
The console incorrectly displays accented characters. How to print them correctly (UTF-8)?
-
2
votes1
answer69
viewsQ: Add method to an existing c++ class
I wonder if in c++ you can increment an existing class by inserting new methods, without touching the class source code directly. For example, if the class below is part of an external library that…
-
2
votes1
answer367
viewsA: Get the name of the respective PHP table in SELECT UNION
You can create an additional 'dummy' field within SQL by identifying the table: SELECT DISTINCT titulo, categoria, views, tabela FROM ( SELECT DISTINCT titulo, categoria, views, 'secao_aves' as…
-
0
votes2
answers847
viewsA: PHP timer function
PHP is server-side, so this can only be done on the client side, in case, javascript.
phpanswered Rogério Dec 1,511 -
1
votes2
answers263
viewsQ: How to avoid array overflow in C++?
My show was exhibiting some weird behavior, until I found out that there was a bang of array, for example: int arr[3]; for (int i = 0; i<10; i++) { arr[i]=i; cout << arr[i]; } In this clear…
-
0
votes1
answer58
viewsA: Bitdefender reporting virus when compiling c++ source with Codeblocks
I made a repair of Bitdefender (uninstall and reinstall), updating the entire virus database. This solved the problem!