Skip to main content
23 votes
Accepted

File Automation Using Python On Linux

Addressing your questions: Readability The docstrings are generally fine. Not too long, not too short. Type hints: Your type hints should not go into the first line of the docstring. That line is ...
Alex Povel's user avatar
  • 1,226
18 votes
Accepted

Tetris in C, in 200 lines

Minimize math operations ...
mdfst13's user avatar
  • 21.7k
18 votes
Accepted

C++ Linux TCP client/server socket wrapper

Design This is a very thin C like wrapper around sockets. In my opinion there are a lot of style changes that are need to make this good C++ or usable by modern C++ library. Main issues: Two phase ...
Loki Astari's user avatar
  • 95.7k
18 votes

Tic-Tac-Toe for the terminal

First of all: nice work! It's easy to read and understand. Program organization It's very good that you split the task to small functions. Reading the body of main...
janos's user avatar
  • 111k
17 votes
Accepted

Linux Commands in Python

Here are a few comments. In general, your code deviates in surprising ways from the UNIX commands (and not just by missing flags or options): Your ls command does ...
Graipher's user avatar
  • 41k
16 votes
Accepted

Light task-processing systems with zero dependency for Linux systems

It's a good idea for worker.c to include "worker.h", preferably as the very first line. That ensures that the declarations are ...
Toby Speight's user avatar
  • 79.2k
15 votes

malloc() and free() for Linux with system calls

Names beginning with _ are reserved for the implementation; I'm surprised that -Wpedantic doesn't help with this! Include what ...
Toby Speight's user avatar
  • 79.2k
13 votes

Light task-processing systems with zero dependency for Linux systems

Make sure Doxygen picks up comments after struct members It's good to add a comment after each member in a struct declaration to describe what that member does. To make Doxygen pick up the member ...
G. Sliepen's user avatar
  • 60.1k
13 votes
Accepted

Bash script to automate dev environment setup

I think you could benefit from using Ansible in this scenario then you can easily deploy your configuration to other machines and you will have learned a valuable IT skill. And rather than use bash ...
Kate's user avatar
  • 7,338
12 votes

Reporting new USB storage devices on Linux and macOS with Python

This script might get the job done, but it is a rather crude and inefficient hack. Ideally, you should avoid polling every quarter second (or polling at all). Also, I see no reason to write any ...
200_success's user avatar
12 votes

Bash script to automate dev environment setup

First of all, I would suggest using shellcheck when writing bash https://www.shellcheck.net/, it will point out many many errors, some trivial and some not so trivial. ...
Countingstuff's user avatar
12 votes

Securing my password wallet

Avoid calling system() If possible, avoid calling system(). There are almost always issues doing this: It is slow: ...
G. Sliepen's user avatar
  • 60.1k
11 votes
Accepted

Parsing the lsblk output

lsblk The -s option to lsblk was introduced to util-linux rather recently, in release 2.22. You may experience compatibility ...
200_success's user avatar
11 votes
Accepted

C program for 'Reverse DNS lookup'

It's generally best to divide your code into separate sections (possibly separate functions) for argument handling and actual computation. Errors should be printed to standard error rather than ...
Toby Speight's user avatar
  • 79.2k
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

Linux screen dimmer based on battery level

Let's start with the obvious, coding best practices: You should strive to make variable names easy to remember and meaningful. I think you could improve a bit on this, e.g. ...
Daniel's user avatar
  • 4,500
10 votes
Accepted

Implementation of Linux cp in modern C++

I see some things that may help you improve your code. Fix the bug The program loops infinitely (actually, as @CrisLuengo correctly points out in a comment, it's not actually infinite. However, it ...
Edward's user avatar
  • 66.5k
10 votes

C program for 'Reverse DNS lookup'

Use getaddrinfo() getnameinfo() has a counterpart: getaddrinfo(). Prefer to use that ...
G. Sliepen's user avatar
  • 60.1k
10 votes

Wi-fi scheduler written in C

I will offer some suggestions. Please note I have no experience with Mac OS, but I believe most of it will still apply. Using system is not particularly bad in ...
Lev M.'s user avatar
  • 1,081
10 votes
Accepted

Securing my password wallet

There's quite a few beginner problems here: using namespace std; This is a really bad idea. It means we no longer have any control over the names in the global ...
Toby Speight's user avatar
  • 79.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,534
9 votes
Accepted

NASM tutorial (Linux syscalls, 64 bit) code with CI-build and test

When the function has finished it's logic, these registers should have their previous values The normal x86-64 System V calling convention allows functions to clobber RAX, RCX, RDX, RSI, RDI, and R8-...
Peter Cordes's user avatar
  • 3,346
9 votes
Accepted

Bash script to truncate subject line of incoming email

Be sure to read the relevant RFCs that govern e-mail headers! Specifically: RFC 2822, Section 1.2.2: Header names are case-insensitive. RFC 2822, Section 2.2.3: Header fields may be line-folded: 2....
200_success's user avatar
9 votes

Tic-Tac-Toe for the terminal

There's two things I'd change to simplify your code: Use a two dimensional array. Sure you can do the conversion from a 2d position to 1d easily, but the compiler can do and ...
Voo's user avatar
  • 525
8 votes

My own little memory manager in C

You should separate your declarations into three parts: The public interface. malloc calloc ...
Deduplicator's user avatar
  • 19.3k
8 votes
Accepted

Basic shell in C

Avoid a hacker exploit: What happens when the first character read is a null character? ...
chux - Reinstate Monica's user avatar
8 votes

Connect 4 in C++

Assuming you'll fix your bug. Let's analyze your code. #include <iostream> #include <cstdlib> #include <unistd.h> I notice you've tagged your ...
Snowbody's user avatar
  • 8,462
8 votes
Accepted

Connect 4 in C++

This is an excellent start for a starting programmer. There are many things to comment on, of course. I'm going to focus on what I think is most important for a new programmer to work on. Compiler ...
Cris Luengo's user avatar
  • 6,217
8 votes
Accepted

Bash script to temporarily run a shell without certain group memberships

It's not an error to ask for help When -h is passed, the help() function shouldn't exit with non-zero status, because it's done ...
Toby Speight's user avatar
  • 79.2k

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