Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Hot answers tagged

26 votes
Accepted

Checking if a number is prime in NASM Win64 Assembly

Style: Indent your operands to a consistent column, so mnemonics of different length don't make your code look so ragged. And use local .label labels inside ...
user avatar
  • 2,632
18 votes

Checking if a number is prime in NASM Win64 Assembly

There are numerous small things. You don't have to keep subtracting and adding 32 from rsp. Allocate the space once at the start of the function (...
user avatar
16 votes
Accepted

Windows keylogger in C

You register keydown events for Control and Alt keys, but don't note when they are released. Therefore, you would not be able to distinguish between r and Controlr by reading the transcript. Those ...
user avatar
16 votes
Accepted

Python Back-Up Script

You can simplify paths using forward slashes: ...
user avatar
  • 107k
15 votes
Accepted

2D Collision Detection

Collision detection You can calculate the collision much easier with the Rectangle structure. Use the Contains method if you ...
user avatar
  • 43.8k
14 votes

x64 assembly clearmem / zeromem

The comments in the clearmem procedure for the Linux block look a bit confusing. You could just have a summary of the procedure commented above, and have the ...
user avatar
  • 34.7k
14 votes

Full C++ Snake game

Using constants Rather than using #define and creating a bunch of macros like this: ...
user avatar
13 votes
Accepted

x64 assembly clearmem / zeromem

I can't say I particularly like this code as it is right now. It seems to me that there are two reasonable approaches: if you think most of what you zero will be in main memory, then you probably just ...
user avatar
  • 33.2k
12 votes

Windows keylogger in C

You have some global variables in main.c: bool invisible = true; char fileName[MAX_PATH]; They should be placed in the closest local scope possible and passed to ...
user avatar
  • 34.7k
12 votes
Accepted

Date of latest GitHub project release

You're actually writing in C but using some C++ features, I'd drop C style (and functions) in favor of their C++ counterparts: 1) Even if you're using a C API you should write C++ classes to hide ...
user avatar
12 votes
Accepted

Windows filepath and filename validation

For the if(filePath.Length >= 240) part, you can use the Path object. It throws a ...
user avatar
11 votes
Accepted

First socket class

I think you have too many different responsibilities bound up into one class. That ends up not only making that class more complex, but adding extra complexity overall as well. As a starting point, I'...
user avatar
  • 33.2k
11 votes

Quadratic equation solver in C++

You have committed a grave error here with operator precedence, which should have easily been caught with simple testing: X1 = Sector4Arithmetic / 2 * a; The ...
user avatar
11 votes
Accepted

Text-based User Interface in Python

General Try to comply with PEP-8. PEP-8 is the name of the official Python style guide. Complying with it makes your code easier to read. Ultimately, developers can more easily collaborate on a ...
user avatar
  • 4,492
10 votes
Accepted

How random is this password-generating algorithm?

Copy&pasting code multiple times does not make it more secure. If we clean up your mutate_seed method, we'd end up with this: ...
user avatar
  • 12.4k
10 votes

Date of latest GitHub project release

Your code can benefit from RAII. For example by creating a small HInternet struct with a destructor to hold a single HINTERNET. ...
user avatar
10 votes

Removing multiple slashes from path

Here are some suggestions for how you might improve your code. Use the appropriate #includes This program fragment requires headers, which should be included: <...
user avatar
  • 64.1k
10 votes

Add and enable/disable Windows Firewall rules with Python

I agree with @Ludisposed answer, but you have a few subprocess gotchas: You don't need to spawn a shell in order to run the command, simply build your command as a ...
user avatar
9 votes

Removing multiple slashes from path

Your specification has holes in it. What will be if user passes NULL? Undefined behavior? Return? What if the path is already valid? Copy the string? Return ...
user avatar
  • 9,079
9 votes
Accepted

Add and enable/disable Windows Firewall rules with Python

This seems OK We can add a little flavor to it: Don't use string concatenation, but use f"{strings}" or ...
user avatar
  • 11.4k
8 votes

How random is this password-generating algorithm?

Expected behaviour / User experience Logging passwords to a file in unhashed, unencrypted form is bad practice. Doing so without telling the user is a sin. Using ...
user avatar
8 votes

Lemonade stand menu program

Here's a few things I noted: Don't have using namespace std; in your code. It's almost universally considered a bad practice. The C++ standard states that you ...
user avatar
  • 21.6k
8 votes
Accepted

Find installed and available Windows Updates

Loop like a native I suggest you have a look/read at Ned Batchelder's excellent presentation "Loop like a native". In your case, any time you write: ...
user avatar
  • 28.7k
8 votes
Accepted

Windows Keylogger

A few thoughts: 1. Fix your formatting Code that appears within a function scope should be indented by another set of spaces (tab): ...
user avatar
7 votes
Accepted

Virtual Slots Implementation

The usual improvements we often suggest here on Code Review: Using namespace: Try not to using namespace std. Read a discussion about this here. Instead, just ...
user avatar
  • 17k
7 votes
Accepted

Function "between" for "Everything in One Line" library

There's no need to use the conditional operator here. This would be enough: bool between (WORD n, WORD x, WORD y) { return n >= x && n <= y; } ...
user avatar
7 votes
Accepted

Makefile for C++ OpenGL with GLFW and glad

First of all, good for you for learning how to write a proper makefile. Few people are any good at it, and it's a really fundamental tool. Even when nice tools ...
user avatar
  • 64.1k
7 votes
Accepted

Batch file command looper

If you want an easy way to loop an arbitrary command several times... set /a loop=100 for /L %%P in (1,1,%loop%) do ( echo Looping for one hundred times ) ...
user avatar
  • 225
7 votes

Quadratic equation solver in C++

Separate IO and logic. Group logical parts into classes / functions. Declare variables where they are used. Declare IO routines for classes when appropriate. I'd also seriously reconsider using ...
user avatar
7 votes
Accepted

Platform independent whereis function

A couple of small things: If you're specifically looking for executable files, you might use which instead of whereis command. ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible