Posts by epx • 8,191 points
241 posts
- 
		0 votes2 answers139 viewsA: Raw socket in CSOCK_RAW allows both receiving and sending packages. The main utility of SOCK_RAW is to implement new transport protocols in userspace (outside the kernel). For example, a program that uses ICMP… 
- 
		3 votes2 answers57 viewsA: Reference is making a variable change the value of anotherWhy should it be null if you assigned 2? When you did const params = Parametros you just created another reference to the same object. The reference will be const(ante), but the object will not. The… 
- 
		0 votes1 answer47 viewsA: Delete from duplicate recordsThis command seems to do what you want: delete res1 from REGISTRO res1 inner join REGISTRO res2 where res1.numero = res2.numero and (res1.dt_data < res2.dt_data or (res1.dt_data = res2.dt_data… 
- 
		10 votes2 answers764 viewsA: What is the difference between a map, a dictionary, an associative array and a hash table?Associative array (Javascript, PHP), dictionary (Python) and Map (Java, C++) are the same thing. They are also called "hash", but this is a metonym, the hash function is the heart of an efficient… 
- 
		0 votes1 answer100 viewsA: Revert a commit that hasn’t been pushed yet, and with multiple comits waiting to get pushedYou can make a git rebase -i d67a194ca^ and will open a screen where you can change the order of the commits, change the description, etc. It is a very powerful command. From what I understand you… 
- 
		1 votes1 answer42 viewsA: C program working but not continuing, gives error at the endJust look, this program has numerous errors, clearly you need to study the language from the beginning, before trying to make programs. Verbi gratia: 1) Its function ler_clientes() expects a matrix,… 
- 
		5 votes2 answers139 viewsA: How to test if the free(); function worked correctly?There’s no way. free() does not return value, therefore has no way to report success or failure. In fact, you can only call free() with a valid pointer, allocated by malloc() and company; or NULL,… 
- 
		2 votes1 answer42 viewsA: How do I remove characters from even positions in a string?You can use a little trick list: >>> a = "01234567" >>> a[::2] '0246' >>> a[1::2] '1357' I put the 2 options because I don’t know if you consider the first position as odd… python-3.xanswered epx 8,191
- 
		0 votes2 answers102 viewsA: How does the pthread_cond_timedwait() function work?That’s how it works: int main() { pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; time_t T; struct timespec t; time(&T); t.tv_sec = T + 2;… 
- 
		3 votes1 answer175 viewsA: Test end of file in CThe problem is that the reading has not yet hit the end of file (EOF) when the loop goes to the third cycle, and feof() still returns FALSE. Testing EOF right after trying to read the first line… 
- 
		1 votes2 answers81 viewsA: What is it, Farmhash?From what I understand, they’re hashes for non-cryptographic purposes. Like, they might be good for a hashmap, for a database index, but not for encryption. "Common" hashes, in the sense of popular,… 
- 
		0 votes1 answer215 viewsA: Replace letter by positionString in Python is immutable, but you could replace, for example, the 5 position character of a string as follows: s = s[0:5] + c + s[6:] If performance is needed, it is best to use a (mutable)… 
- 
		2 votes1 answer25 viewsA: Error on a JS PromiseYou forgot to pass "act" as parameter when calling check(). By using the same name "age" as parameter name in function definition, the parameter "hid" the global variable. Just change line 13 to… 
- 
		2 votes3 answers690 viewsA: What is a mainframe?The main feature of the mainframe is that it lacked microprocessors, in the style of modern computers. The circuits that constituted the CPU (central Processor Unit) were large and modular,… 
- 
		1 votes1 answer47 viewsA: Complexity of simple algorithmAll f(n) does is return -n. Calculating the negative of a number is a constant complexity operation, it is equal for all numbers. And a constant complexity algorithm (large or small) is O(1). 
- 
		-1 votes4 answers634 viewsA: What is the difference between i += 2 and i = i + 2?In the case of a number there is not much difference, but if it was a more complex type, it may be that += would be more efficient than + because it does not need to create a new object. For… 
- 
		0 votes1 answer28 viewsA: Function return -0Ideally you would have put in an example code. But you’re probably using floating point numbers (float or double) and they have two zeros: +0 and -0. Useful for preserving the signal in boundary… 
- 
		0 votes1 answer53 viewsA: What’s wrong with using reinterpret_cast on C++?With it you can convert a pointer of any type to any other type, it is similar to the cast of normal C, the one with (parentheses*). His main problem(s) is that the compiler has no way of checking… 
- 
		1 votes1 answer39 viewsA: File list gives errors when going through . Decode()The error is that you are assuming that recv() will only receive bytes sent by a send() command. But TCP doesn’t frame the messages, it’s all a byte casing, so your recv() is getting the file name… 
- 
		1 votes1 answer128 viewsA: Release External Mysql ConnectionChange the bind-address to 0.0.0.0, which means "all network interfaces". The value 127.0.0.1 refers to the loopback network interface, which allows only local connection, on the server itself.… 
- 
		1 votes1 answer95 viewsA: Receive data input as Python 3 literal valueIf I understand correctly, you want the user to type xbb3 and Python to understand this as a special character, correct? Actually this is just one way to do it, you could adopt any other convention,… 
- 
		1 votes1 answer24 viewsA: Submit data p/ database via SOCK_STREAMIn http_msg, there seems to be a gap between %s and HTTP/1.1 missing. This is enough for the server not to recognize the page you are trying to access. Fixing this example seems to work and the… 
- 
		1 votes2 answers28 viewsA: Adding 0.1 to a setInterval gives rounding problemsThis is normal, the cause of this is that floating point is represented internally in binary, and 0.1 is a periodic binary titer. Some simple solutions you can adopt: 1) increment 'total' from 1 to… 
- 
		1 votes1 answer76 viewsA: How to save samples before and after an event in a circular buffer?I would initially load a 2x block the window size at a time, run the window over the buffer. Then, load 1x more window. Pseudocode, considering a window of 50 samples: byte amostras[100] // carrega… 
- 
		-1 votes1 answer68 viewsA: Doubt about date manipulation using time. hTry to allocate the tm structures using calloc, or wipe them completely using bzero, the structure has other fields than what you filled in and some dirt in them may be influencing the result.… 
- 
		3 votes2 answers46 viewsA: Android - Is it good practice to use the default.xml strings for national applications?All XML files are UTF-8, so in theory any file of any language can contain any character. Ideal is that the default language is English, but auto school really is a market that only has in Brazil,… 
- 
		1 votes2 answers80 views
- 
		1 votes2 answers551 viewsA: PHP Warning: mysqli_close() expects Parameter 1 to be mysqli, Boolean GivenProbably mysqli_connect() is failing, which assigns FALSE to the $Conn variable. I suggest putting a test after the connection, something like if (mysqli_connect_errno()) { echo "Falhou ao conectar… 
- 
		1 votes2 answers213 viewsA: Hexagon Grid - return neighborsI think there are two possible solutions; 1) find a mathematical formula that, based on the size of the super-hexagon, returns the numbers of the neighboring hexagons. It would be very fast, but not… 
- 
		1 votes1 answer61 viewsA: Configure Virtual Web ServerI think you are confusing concepts because you spoke of DNS and most likely the solution of your problem lies in the configuration of the Web server. But the options are as follows:: 1) DNS CNAME -… 
- 
		1 votes1 answer101 viewsA: How to get the Gmail source code using Python3Not to rain on your parade, but... Sites that use AJAX do not return content in HTML, they generate content dynamically, after loading, using Javascript. You would have to use a radically different… 
- 
		1 votes2 answers208 viewsA: Is it always good to de-locate the memory before a "sudden" output of the program with the Exit function call?The memory allocated by the program belongs to the process; when the process dies, all the resources used by it are released. So, a short running small program can "relax" in memory management… 
- 
		1 votes5 answers12449 viewsA: How to separate a digit from an integer?One solution is to divide integer by a power of 10, and use the rest of the split operation by 10. For example, in Python 2 to get the third digit from right to left: >>> 9912345 / 100 % 10… 
- 
		2 votes1 answer3545 viewsA: How to make a query in the database with Javascript?Your question is a little broad, but come on, it’s a perfectly valid question for a beginner. It is not the language that accesses the database, it is some library or framework made for that… javascriptanswered epx 8,191
- 
		-1 votes2 answers217 viewsA: What’s the difference between git reset -- <file_name> and git reset HEAD <file_name>?Git reset allows you to specify the commit. That’s what you’re specifying in HEAD, because HEAD is the latest commit. It could be any other commit from the past. 
- 
		1 votes2 answers5464 viewsA: Segmentation failure: Recorded core imageShort answer: you are using N to create the matrix x[N] before the value of N is set, so it is random (but usually it will be zero). Declare x[N] after scanf(). In C99 it is allowed to declare… 
- 
		2 votes2 answers120 viewsA: How to format strings and store them in a dynamic vectorTry the asprintf() function, which allocates and returns the buffer needed to accommodate the result. Besides returning the right size, it is much safer. As an extension of GNU libc, you need to… 
- 
		2 votes1 answer1802 viewsA: Dereferencing Pointer to incomplete typeWhen using the type, you are using "struct cadastro", when you should only use "cadastro", since the registration type is already properly defined as struct. If the struct were defined this way:… 
- 
		0 votes1 answer91 viewsA: Extract the cover of an MP3, and other information with PHPWhat you need is a library or function that reads the ID3 tags of an MP3 file. It seems to have something in the standard PHP library itself: http://php.net/manual/en/function.id3-get-tag.php… 
- 
		2 votes2 answers607 viewsA: Is it possible somehow to overload functions in C?In C, no. In C++, yes. You can develop in "C" and compile as C++ just to use the C++ resources that interest you, in the case of function overload. 
- 
		6 votes1 answer4020 viewsA: Maximum character limit of an e-mail addressRFC 5321 specifies (section 4.5.3): maximum 256 characters for a complete email. Other limits: 255 for the domain, 64 for the username (part that comes before the @). However, the recommendation is… 
- 
		-1 votes3 answers5033 viewsA: Use UTF-8 or Latin1?In Mysql you have the types MEDIUMTEXT (16M characters) and LONGTEXT (4B), so there is no need to worry about limitations imposed by encoding. Standardize in UTF-8 and be happy :) 
- 
		2 votes1 answer82 viewsA: How to start Python code correctlyYou mean this test? if __name__ == "__main__": # faz algo What this test determines is whether the execution is happening on main scope, i.e., it is the script that was directly executed from the… 
- 
		3 votes2 answers254 viewsA: Create files in the Home folder with C++You can uasr the function getenv() to get the value of $HOME: const char* s = getenv("HOME"); 
- 
		1 votes1 answer543 viewsA: How can I kill a ThreadThread doesn’t kill itself, it has to stop on its own, so you don’t escape using a signal or flag mechanism. 
- 
		0 votes1 answer131 views
- 
		7 votes2 answers1076 viewsA: What is Microsoft Access for?MS-Access is more or less equivalent to Excel and Word, but for database. It has its own database format (MDB) where data, screens, reports, programs, etc. come together. But it can also be client… 
- 
		5 votes2 answers15220 viewsA: How to clear the screen in C++?Deleting the screen is an operation dependent on the environment in which the program operates. For example, a graphical program does not even have this operation, because it is not running in a… 
- 
		0 votes1 answer35 viewsA: Call to the system dup2 vs. write&readpipe() seems to be being used correctly in the code. The goal of dup2() is to duplicate the file Descriptor to a set number. In the case of code, the child-process is putting a pipe in place of file… 
- 
		6 votes2 answers104 viewsA: Is there a performance benefit in replacing the operator "==" with the operator "=="?I did a little test on Node.js V9.8.0: "use strict"; let t0, t1, dummy; t0 = (new Date()).getTime(); dummy = true; for (let i = 0; i < 10000000; ++i) { let j = "" + i; let k = 0 + i; dummy =…