muru
  • Member for 6 years, 11 months
  • Last seen more than a week ago
Create a C style char** from a C++ vector<string>
18 votes

I can see a few potential problems here: Since you allocated a char* array of input.size() elements, result[input.size()] is out of bounds. Similarly, std::string's size() is the number of characters ...

View answer
Markov country name generator
15 votes

Looping over lines of a file Probably a minor nitpick, but when using a file object returned by open(), you can just iterate over the object, instead of calling readlines(), like so: # Read names ...

View answer
Interactive bash script to create new permanent swapfiles
Accepted answer
5 votes

fallocate and swap files You should not use fallocate for creating swap files. It's not supported. From the mkswap manpage: Note that a swap file must not contain any holes. Using cp(1) to ...

View answer
A Neural Network
4 votes

A few points that stood out to me from a cursory glance: level_of_debugging doesn't seem to serve any purpose as an attribute. The __init__ function doesn't accept an argument to set it. The only ...

View answer
Bash script to change network interface parameters/configuration and start virtual machines
Accepted answer
3 votes

Much of this seems ... unidiomatic for a shell script. It feels rather like a C program converted to shell. You don't need to declare -f functions before hand. In fact, declare -f func_pause is an ...

View answer
Bash script to deploy a mongodb cluster on local machine
Accepted answer
3 votes

To begin with, I agree with Jesse_b that command substitution should use $(). There's no reason to use backticks in a bash script that uses arrays (that's to say, you're not particularly aiming for ...

View answer
Shell POSIX OpenSSL file decryption script follow-up #2
Accepted answer
2 votes

POSIX The script is a strange mixture of POSIX and non-POSIX. On the one hand, openssl definitely isn't POSIX, but it's essential since that's what the entire script is about. On the other hand, many ...

View answer
Checking the status of a ZFS pool
Accepted answer
2 votes

You can simplify the zpool command, by specifying the volume name as an argument: /sbin/zpool list tank | grep ONLINE This will avoid cases where tank might be part of another volume's name. Better ...

View answer
JSON Parsing in Bash
1 votes

Redirect the entire loop, instead of redirecting individual commands. Instead of opening and closing the file for each iteration of the loop, you can have the file open for the duration of the loop. ...

View answer