Considering the suggestion of using modern string arrays instead of char vectors proposed by Cris Luengo. I am trying to make a code snippet for performance comparison of these two cases.
The experimental implementation
%% Print system information
system('systeminfo');
%% Setup: test parameters
...
This is my first question so please let me know if this is too vague/broad and I will do more research on question asking.
I have implemented a handful of data loaders in C#, and have come to the point where I have what I consider in my limited experience a decent structure, but I'm not confident...
What is a more efficient way of writing this sample code? Its purpose is to create a variable for days of the week based on a numerical value. Fiddle here - https://3v4l.org/Sghnh#v7.4.30
<?php
$classDays = [1,3,5];
if($classDays[0] == '') {
$classDaysD = 'Online';
} else {
if (in_array(...
I vote for re-open. I don't see why it does not fit to SO. Please explain to me and the opener because then we can learn. That it fits better do "CodeReview" doesn't matter. It IMHO also fitts to SO. — buhtz33 secs ago
I have a small mission critical web app that needs to respond to all requests rather fast. I need to run some other code that can potentially take a few seconds. I was trying to use pcntl_fork. If I have the simply script
<?PHP
$pid = pcntl_fork();
if ($pid == -1) {
die('could not fork');
} ...
Practicing objected oriented design. This time, it's designing the TicTacToe game. One difference between the real TicTacToe game is that I've made my TicTacToe game to have variable sized board.
Please review in terms of OOD and I've also left some comments in my code where I want feedback in pa...
I am trying to learn the factory design pattern. I have created a code for creating two animals (for now only dogs and a cats).
I have got an Animal (as a product)
public abstract class Animal
{
public abstract void CreateBody();
public abstract void CreateLeg();
}
Dog and Cat Implements...
Here is my type safe dynamic array. I'm eventually going to make a hash table in C. I'm just wondering if anything seems wrong or out of place. Thanks.
#ifndef DARRAY_HEADER_INCLUDED
#define DARRAY_HEADER_INCLUDED
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#define darray_def...
This is actually my version of a project I'm giving to my class of High School juniors. I'm not the greatest programmer and also a new teacher so I was hoping someone could check out this code and give me any suggestions or advice they see on it.
Please just keep in mind that it's written to be a...
defmodule Combination do
def combine([]) do
[]
end
def combine([head | tail]) do
tail_combinations = combine(tail)
merged_combinations = Enum.map(
[[]] ++ tail_combinations,
fn c -> c ++ [head] end
)
tail_combinations ++ merged_combinations
end
end
This E...
Here is the script that I would like reviewed for the following:
Best practices and design pattern usage
Correctness in unanticipated cases
Possible error checking
import os
import tarfile
import time
# Create backup filename
timestr = time.strftime("%Y-%m-%d:%H%M%S")
output_filename = "minecr...
The following is a Scheme procedure to permute the characters in an input string.
It outputs permutations of all lengths from 1 character up to the number of characters in the input string.
The list returned from the procedure permutations is in lexicographic order.
Duplicates are not part of th...
This is actually my version of a project I'm giving to my class of High School juniors. I'm not the greatest programmer and also a new teacher so I was hoping someone could check out this code and give me any suggestions or advice they see on it.
Please just keep in mind that it's written to be a...
I've been reviewing some code recently, and I came across this wrapper object for the serial port class. I'm trying to understand the advantage of this seemingly redundant object:
Public Class SerialPort_Class
Private WithEvents Serial_Port As IO.Ports.SerialPort
Private SerialPort_ReOpen_Flag A...
I am parsing a document and returning
(1) uniqueness, and
(2) total number occurrence.
I believe my code can still be subjected to review. I would like a review of my code as I have even made it too tightly coupled, and some Dependency Injection would be a nice to have.
links.log file
/help_page/...
Running Rails 7.0.3, Ruby 3.1.2 and rspec-rails 6.0.0rc1
I'm writing out some specs to test for the inclusion of certain data getting sent by my controllers. A random (simple) example from the codebase looks like this:
describe 'POST /create' do
it 'should create and return newly created user' ...
Yes, another php form builder... I wrote this solely to demonstrate OOP principles.
My questions are:
Could this be written better? OOP-wise.
How could i better implement error handling?
Index.php
<?php
require __DIR__ . '/vendor/autoload.php';
use FormBuilder\FormGenerator as Form;
use FormBuil...
I’m voting to close this question because it better fits codereview.stackexchange. It could have an infinite number of valid refactoring answers so I don't think it fits SO. — julealgon15 secs ago
I had a class which creates pdf for various things such as exam, course and subject.
In my pdfmanager class the code was repating itself like :
CreateExamPdfForStudent(somedto){
//do common something
//exam and student code
//do common things..
}
CreateCoursePdfForStudent(somedto){
//do comm...
StackOverflow is a Q&A site for solving programming problems. If your code actually works, and you just want to clean it up, ask on Code Review instead. — Remy Lebeau26 secs ago