Posts by epx • 8,191 points
241 posts
-
0
votes1
answer18
viewsA: Check if two keys were pressed at the same time python
You would have to have a list, outside the "press" and "release" functions. When a keydown is registered by "press", add it to the list (if it’s not already there). When a keyup is registered by…
-
0
votes2
answers48
viewsA: C Language - Read binary file in its full size
sizeof() is not appropriate for this task. sizeof() is a pseudo-function that calculates the size of a type at compile time. To find out the file size, you need to test the fread() return value. In…
-
-2
votes1
answer26
viewsA: How to store special characters in strings and print to files?
The problem is that you are setting the locale to an encoding (probably ISO 8859-1, which uses only one byte per character) but the terminal must be using UTF-8 (variable number of bytes per…
-
1
votes1
answer18
viewsA: C - String comparison with strcmp does not work
The typed string, received by fgets(), contains the end-of-line character ( n, r or r n, depending on the operating system). Your comparison string would have to include this character, or else you…
-
0
votes1
answer10
viewsA: Initialization list of members with attributes from another class (inheritance)
What’s the mistake? This would be important to include in the question. I see that you stated intNum with lowercase "i" in the parent class, but are trying to initialize Intnum (with uppercase "I"…
-
1
votes1
answer38
viewsA: How to read two vectors and place the values in a third vector and in ascending order?
The error is that when j reaches the "M" value, all vector values have already been used, so vector A[j] is pointing to a random value, outside the matrix boundary. The program could break, but for…
-
0
votes1
answer8
viewsA: How to add items to a dictionary without overwriting the previous item
Among other errors, you are resetting self.cadastro_mes as empty at each call of the horas_worked() method. The line self.cadastro_mes = {} should be moved to __init__(), that creates the class and…
-
0
votes1
answer25
viewsA: error with Insert and mysql
According to an example in https://zetcode.com/csharp/mysql/ you need to add the parameters to the command. Taken from the example: var sql = "INSERT INTO cars(name, price) VALUES(@name, @price)";…
-
0
votes1
answer46
viewsA: Is there a difference between corroding, fiber and green threads?
I see green threads and fibers as something a little more "ancient" than corollaries. When operating systems started supporting threads, a thread cost almost equal to a process. There was then an…
-
-1
votes2
answers53
viewsA: How to check if a variable received a new python value?
There is the Queue module and the Queue class that allows you to do this safely. Communication between threads is technically complicated, don’t try to create your own schema from scratch. In fact,…
-
-4
votes2
answers84
viewsA: Is there a difference between "accuracy" and "precision" in computing contexts?
A clock that advances 15 seconds a day is inaccurate. But if he at all times advance the same 15 seconds a day, it is necessary. The article…
-
3
votes1
answer60
viewsA: What’s the difference between using input() and using sys.stdin.readline()?
Straight from the horse’s mouth: >>> input() bla 'bla' >>> input("digite algo: ") digite algo: bla 'bla' >>> import sys >>> sys.stdin.readline() bla 'bla\n'…
-
0
votes1
answer40
viewsA: failed . append attribute when entering list entry - (Python)
If I understood what the goal was (increase the chances of those who collaborated more), it worked doing the end like this: print('LISTA DE SORTEIO:') for nom in lista_cadastro: nomeSorteio =…
-
-1
votes1
answer22
viewsA: Pick up api information with local socket
Do not use sockets, use any module that implements a real HTTP server, such as Simplehttpserver (Python 2.x) or http.server (Python 3.x).
-
0
votes2
answers68
viewsA: Automatic null value check versus types like "Option<T>"?
Both solve the same problem. Option<Tipo> x is more explicit, and looks more like a collection that can contain 0 or 1 elements. Tipo? x is less verbose, more ergonomic when the underlying…
-
-1
votes3
answers104
viewsA: Syntactic difference between classes and constructor functions in Javascript?
No Javascript vanilla really there is no. You have a proposal to accept membership declaration of a class, more or less as you expected, but it is not yet supported on all Javascript machines:…
-
0
votes1
answer44
viewsA: How can I use python with c++?
You have to define whether to) call C++ code from Python and/or b) call Python code from C++. In case (a) you should search on how to extend Python and develop Python modules in C/C++. The beginning…
-
1
votes1
answer44
viewsA: Command is not working
The block that eliminates the item should be something like: remover = vet[K]; for(int k = K; k < size() - 1; k++) { vet[k] = vet[k+1]; } The idea is to do a "chair dance", eliminating item K by…
-
1
votes3
answers70
viewsA: Because I would do Downcasting and Upcasting on C#
Let me give you an example that is not specific to C# but occurs in every framework with graphical interface. Each element on the screen is a View. There are elements composed of subviews, that is,…
-
1
votes1
answer48
viewsA: Variable defined with Let/const is not "identified" by this
When you access "this.name", you are actually accessing "window.name" (outside the context of an object, "this" is simply the window). The keyword "var" in the global scope adds the variable as…
javascriptanswered epx 8,191 -
1
votes1
answer31
viewsA: Asymptotic complexity of function
It is only x 4 because it clearly dominates for large values of x.
-
4
votes1
answer107
viewsA: What are the advantages and disadvantages of encapsulated errors types like "Result"?
Exceptions are difficult to implement in C++ and Rust-type languages, which do not have "garbage collector" and compile for binary. A program that uses exceptions gets a little slower, and…
-
2
votes1
answer73
viewsA: I can’t find the problem in the code
It is a feature of C, that a bug in the program will manifest itself quite differently on different computers, or even running several times on the same computer. In the specific case of your…
-
6
votes2
answers1355
viewsA: What is SSL Pinning?
An SSL certificate has a signature chain, which starts at a root certification entity (CA root), which signed certificate A, which signed certificate B, until it reaches the final certificate.…
-
0
votes1
answer82
viewsA: What is the difference between running the program on the emulator and on a physical device?
You never make a mistake if you prefer to run your app always on the physical device. Android emulators are slow and do not implement all devices. For example, simulate GPS, camera, sensors... all…
-
0
votes3
answers60
viewsA: Shorten Object Method Call
Shorten how? One possibility is to loop a list to content the objects and call the common methods that everyone has, something like for atleta in [atleta1, corredor1, nadador1, ...]:…
-
1
votes1
answer446
viewsA: Struct with string in C
strlen() is for measuring the length of the string. To compare, you should use some function of the strcmp family, for example strcmp(sexo, "F") == 0 strcmp() returns -1, 0, or +1 as the string is…
-
0
votes5
answers5742
viewsA: Is it possible to develop websites with C/C++?
The critical component, which is the web server itself, is already written in C or C++. As for the application code, you will spend 100 times more to develop in C than in PHP or Javascript. In fact…
-
2
votes2
answers907
viewsA: How to work with lock in SQL records?
Using lock is asking to bother. The really decent solution will require collaboration between database and application. One idea: 1) There must be a timestamp column that is updated in Insert and in…
-
0
votes1
answer29
viewsA: I can’t get the last day of the month. What’s the mistake?
Dateperiod excludes the end of the interval (in this case, $to). If you want to include the last day of the month, make $to the same as the first day of the next month.
-
1
votes1
answer36
viewsA: Query to find duplicate by DATETIME (MYSQL)
It’s an interesting problem of intervening mathematics. One thing you’ll need is a primary key, a single ID per line, so a schedule doesn’t conflict with itself: mysql> select * from teste;…
-
2
votes2
answers105
viewsA: How does an array of functions recognize the position of the next element?
A list of pointers for functions contains only pointers, not the "body" of the functions. And usually the function pointers have the same size as the pointers for any other object. Nor is there an…
-
1
votes1
answer269
viewsA: C - Exception thrown to scanf_s ler string
Ask the teacher to explain again about pointers. The member 'name' of the 'account' structure is a pointer, it needs to be allocated, to have space that receives the string inserted. Also, because…
-
5
votes1
answer385
viewsA: Would "Promise.all" (and other similar functions) be an example of Javascript parallelism?
In fact, parallelism (or non-existence of it) resides in the Precedents themselves, not in Promise.all(). A Promise’s work begins when it is created, which Promise.all(doubles) does is create a file…
-
0
votes2
answers665
viewsA: Mailer Error: SMTP connect()
This means that the email server parameters (Config::EMAIL_HOST and the like) do not point to a functional SMTP server. The problem does not seem to be in the code posted.
-
-2
votes1
answer80
viewsA: What is the difference between function and method?
Method is a function associated with the data structure of an object. When you call a.b(), it is assumed that b() will read and/or write data on object "a". This can happen indirectly if a.b() calls…
javascriptanswered epx 8,191 -
1
votes1
answer244
viewsA: Sort lists without Sort
The name of this algorithm is 'Balance Line', it was something usually implemented in the times of COBOL, where the data came from ordered magnetic tapes, I believe. #!/usr/bin/env python3 def…
-
1
votes1
answer87
viewsA: Is it possible, somehow in python, to create attributes in a class that is common to all objects?
In the language itself, you do not have this feature. To access a class variable, you must be explicit. Have some alternatives to abstract to some extent: properties and use __class__ to not need to…
-
-1
votes1
answer63
viewsA: Asynchronous Communication
Use socket on localhost, in general the operating systems are much more optimized in the sockets/network part than in Pipes: if bobear will be faster the socket than the pipe. And you can repurpose…
-
3
votes1
answer62
viewsA: Find out which Encode was used in a form
The Encode appears to be ISO-8859-1, because it is using only one accented sign character. If it were UTF-8 it would use two or more. By the way, this transformation from "á" to %E1, among others,…
-
2
votes2
answers90
viewsA: Is there a possibility of versioning files other than code?
You can browse anything (in git at least), including binary formats. It’s customary to include assets like images in Git of a source code, after all they are an integral part of the program. What…
versioninganswered epx 8,191 -
1
votes1
answer83
viewsA: Picking up values in a $post array
By default, each run of a PHP program starts "clean stone", virgin. To persist data across multiple client accesses, you need to create a session. At the beginning of the program, call…
-
0
votes1
answer52
viewsA: Error while sending email
The error is that you are invoking a UI function on a thread that is not the main one. Try surrounding this call to Toaster as follows: runOnUiThread(new Runnable() { @Override public void run() {…
-
1
votes1
answer20
viewsA: Is it possible to retrieve fields other than the foreign key?
It would be something like select Pessoa.Nome, Carro.Marca from Pessoa inner join Carro on Pessoa.Carro_id = Carro.Carro_id ?
-
1
votes2
answers162
viewsA: MYSQL - How to return records that exist in one table and do not exist in another?
Assuming an example CUSTOMERS & ORDERS. A customer may or may not have orders, but every order belongs to a customer. To find customers without any request: select clientes.codigo from clientes…
-
5
votes5
answers527
viewsA: What is programming logic and computational thinking?
A computer is capable of only a handful of basic operations. The Turing machine was the first model of a computational machine, and there is still no computer inherently more capable than the Turing…
computer-scienceanswered epx 8,191 -
0
votes1
answer42
viewsA: How to increment primary and foreign keys in Postgresql using SERIAL
In the table 'client' should work, in the table 'phone' I think it is wrong to classify cd_client as serial, it should be integer, after all it is the client code that should be in INSERT, it should…
-
0
votes1
answer217
viewsA: Receiving numerous data with Python socket
Its implementation of recvall() has to call recv(1024) within a loop and accumulate the received buffers. When recv() returns zero, it is because the other side closed the connection and the…
-
-1
votes2
answers409
viewsA: Python algorithm complexity with two loops
When we don’t understand a concept, it’s interesting to make a model: n = 3 for a in range(0, n): for b in range(0, n): print ("a", a, "b", b) The output of this program is: a 0 b 0 a 0 b 1 a 0 b 2…
-
0
votes2
answers33
viewsA: Forwarding of domains
Can be without using mod_rewrite? <VirtualHost *:80> ServerName webfreela.com Redirect 301 / https://www.webfreela.com/ </VirtualHost> (repeat this block for each alternate domain that…