Skip to main content
The 2024 Developer Survey results are live! See the results
27 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 ...
Peter Cordes's user avatar
  • 3,346
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 (...
1201ProgramAlarm's user avatar
16 votes
Accepted

2D Collision Detection

Collision detection You can calculate the collision much easier with the Rectangle structure. Use the Contains method if you ...
t3chb0t's user avatar
  • 44.3k
12 votes
Accepted

part of a c++ program which mods a game using code injection

It isn't clear why file_helper.h makes an attempt to be portable since code_injection.cpp is not portable. If you want most of ...
pacmaninbw's user avatar
  • 24k
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 ...
Daniel's user avatar
  • 4,490
11 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 ...
301_Moved_Permanently's user avatar
11 votes

Battleships console game - my first code in c++ using classes

Here are some things that may help you improve your code. Don't abuse using namespace std Putting using namespace std at the top ...
Edward's user avatar
  • 66.5k
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: <...
Edward's user avatar
  • 66.5k
10 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 ...
Ludisposed's user avatar
  • 11.6k
9 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: ...
SylvainD's user avatar
  • 29.2k
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 ...
Incomputable's user avatar
  • 9,504
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): ...
πάντα ῥεῖ's user avatar
7 votes

2D Collision Detection

Just a quick answer. You are calculating s.Width / 2 for each Picturebox two times. Just calculate it once, store the result in ...
Heslacher's user avatar
  • 50.4k
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. ...
Grajdeanu Alex's user avatar
7 votes
Accepted

Tetris game for Windows

I don't have the time to analyse all the code. I suggest fixing these issues mentioned here and then reposte the improved version. Then we could take a look at your logic. Don't use ...
Sandro4912's user avatar
  • 3,076
7 votes
Accepted

My little C++ library for comfortable programming

General Observations Can it be done in other way? For example, I can write code in multiple files, but then compile into one .lib file? If so, how to install it then? Generally it is best to put ...
pacmaninbw's user avatar
  • 24k
6 votes
Accepted

Python Text-To-Speech program

DRY Apply the DRY (Do not Repeat Yourself) method. For instance, the check to remove the file. Since it's being called in two places, we can make this a function. I've re-written your code in a more ...
double_j's user avatar
  • 248
6 votes

wxpython program to clear the Desktop or restore files to the Desktop

Your class name is misleading; it says "Window" as if you are trying to draw a window for a GUI purpose, but that is not what that class actually performs. So you should rename it to something else ...
Billal Begueradj's user avatar
6 votes
Accepted

Game of Life improvement

I'm unsure what you mean by saying "improve the user interface". AFAIK Game of life doesn't have much of a user interface as it's a simulation that only displays the grid and whatever happens on it. ...
yuri's user avatar
  • 4,458
6 votes

Changing the ACL on a folder through Wscript.Shell within VBA

CodeReview Why use the Scripting.FileSystemObject? MyFolder is just returning the folder name MyFolder = Worksheets("...
TinMan's user avatar
  • 4,143
6 votes
Accepted

Printing a string in NASM Win16 Assembly

You have all the elements. The only thing that can be eliminated is jmp .run, as follows: ...
Shift_Left's user avatar
6 votes

Simple Tetris game

Always write source code and comments in English (I'm not a native English speaker either). You will sooner or later need to share code with other people around the world, like you just did here and ...
Lundin's user avatar
  • 4,690
6 votes
Accepted

Network utility tool

Nicely formatted comando[] deserves a greater size ...
chux - Reinstate Monica's user avatar
6 votes
Accepted

Python module to print in printer

Wrong Conceptual Model An interesting module, but you need to rethink it a bit. It is a print context, not a document. A document would hold things like paragraphs, images, charts, and what not. ...
AJNeufeld's user avatar
  • 33.9k
6 votes
Accepted

ds - A directory switcher via tags in Windows command line

Reconsider Your Imports Currently, you’re importing pretty much every identifier from std:: that you use. I actively avoid this for names like ...
Davislor's user avatar
  • 8,071
6 votes
Accepted

Multithread execution times are slow on Ubuntu and fast on Windows

Use C++'s random number generators instead of rand() Not only is this good advice in general, it's actually the main source of your performance problems. You use <...
G. Sliepen's user avatar
  • 58.9k
5 votes

Batch file to backup and update SQL Server DBs

Well, in case anyone is interested, here is what I've come up with: BASICS I like using the :: type of comments over REM ...
carlossierra's user avatar
5 votes

Snake game in C++ for Windows console

Bugs Line 61 and onward: ...
Mast's user avatar
  • 13.4k
5 votes
Accepted

Settings JAVA_HOME with Powershell

For a beginner script there are some There might be more to cover but there are a few things here that could improve the script. Variable and function naming In general functions and cmdlets should ...
Matt's user avatar
  • 2,558
5 votes

Convert an image into characters and colors for the windows console

Here's pretty much my end result for an algorithm. It takes about 20 seconds for a 1024x1280 with (4x6) pixel precision. I switched from primarily using Euclidean color difference to LAB color ...
trigger_death's user avatar

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