instruction stringlengths 71 95.1k |
|---|
I am curious to know if there is a cleaner/better way to write this. Any suggestions would be greatly appreciated! I do ask some questions in comments within the code specific to certain functions/lines of code.
What the Code does:
Import files from Excel as character
Creates a nested tibble/data frame (two columns wo... |
Code is posted after explanation.
Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused.
Post 1 of 3, Core: Newspaper Bill Calculator CLI with Python (1 of 3, Core)
Post 3 of 3, Database: Newspaper Bill Calculator CLI with Python (3 of 3, Database)
... |
Here is a Lexer for a programming language I am working on. Any feedback would be appreciated. I only started learning C# a couple of days ago, so please excuse my newbie code :)
namespace Sen
{
enum TokenType
{
IDENTIFIER,
NUMBER,
STRING,
SEMICOLON,
PLUS,
MINUS,
... |
Code is posted after explanation.
Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused.
Post 1 of 3, Core: Newspaper Bill Calculator CLI with Python (1 of 3, Core)
Post 2 of 3, CLI: Newspaper Bill Calculator CLI with Python (2 of 3, CLI)
What is th... |
I started learning Rust today and figured, I could ask for some code reviews to learn to make my code idiomatic and learn about its code generation. I spend my days writing highly optimized Java and C++, so interested in Rust from that perspective.
This is the first problem from leetcode:
// Sorts a vector, so that eve... |
I needed a function to find the first and last indices into a sorted list corresponding to a given value (roughly similar to C++'s equal_range()).
This is the solution I came up with:
function findSol(target, arr){
var i, len, first_found, first_i, last_i;
first_i = -1;
last_i = -1;
... |
I want to count the number of bits set to 0 at the beginning of a byte array. So far the code I have is this:
public static int getPrefixLength(byte[] bytes) {
int prefixLength = 0;
for (byte b : bytes) {
if (b == 0) {
prefixLength += 8; // 1 byte = 8 bits
}... |
Here is a program I wrote to take an image and do weird things to it. Is there any more weird things I can add?
Right now I have:
Chop the image
Flip the image (up/down and left/right)
Rotate the image by a random amount of degrees
Roll the image by a random offset
Negate the image
Add a randomly colored border around... |
This is Comma-Separated Values to Tab-Separated Values converter written in C, with yacc(1) and lex(1).
I'm remembering how to use yacc (the first (and last) time I used it was while reading «The UNIX Programming Environment», but I have forgotten almost everything).
This code is based on an example from begriff's blog... |
I've decided to implement the ID3 Decision Tree algorithm in Python based on what I've learned from George F. Luger's textbook on AI (and other secondary readings). As far as I know, the code is working correctly:
import math
from random import choice
from collections import defaultdict, namedtuple
class TreeNode:
... |
This is a web socket client wrapper with auto reconnect capabilities.
First of all, I know I should avoid working with strings to reduce allocation, that's on test purpose. So, ignore the fact that it is an unbounded Channel<string>, which is not directly parsing to JSON from ReadOnlyMemory<byte> (stringifies instead) ... |
I am reading the book The Linux Programming Interface and I have reached the exercise in which the implementation of the chattr command in C is required.
I would like to receive feedback on the implementation, to criticize my solution
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#inclu... |
This (minimal demo) code obviously works, but I am a bit taken aback by the hoops I needed to jump through (and little to no mention in Angular (v13) documentation about the technique). I'm still inexperienced with Angular in this regard...
I need to validate a form (Angular reactive form pattern) on both the field lev... |
I'm trying to write a program that will check if a window is opened or not, during a given time. I was able to do that, but now I'm trying to make my code look cleaner. I don't like how I implement the way I handle all possible error cases. Here is my current code:
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_I... |
I have written this backup utility to keep incremental backups by copying new and modified files, and hard linking unchanged or simply moved files. In an attempt to speed up the comparisons, I save a record of the file stats from the previous backup to avoid iterating over the old backup directory. The backup is called... |
I'm a newbie in programming. Could you please check my code and give any refactoring ideas, tips, etc... how it can be improved.
I wrote a code to perform the following task:
Find in randomly filled square matrix M x M max element which located in given sector, where M - is matrix size.
Here is the image of how sectors... |
Problem
We have a tool which produces output as json array
We have another tool which anticipates input as ndjson (newline delimited json)
I need to write a converter to transform json array to ndjson
Sample json array
[
{
"Property1": true,
"Property2": 0.1,
"Property3": "text"
},
{
"Property1"... |
I'm trying to develop some kind of in-memory store for my entities. These entities are representations of the devices available on the system. There may be eg. 3 leds, 1 temp sensor, 2 engines etc. Some of the devices can be dynamically discoverable, e.g. they can be connected through RS485, USB etc.
I created two solu... |
I made this scraper to pull the prices of pokemon cards off tcgcollector, using a csv file from the same site. Because for some reason they don't export price. I'm looking for any kind of noobie mistakes I made or maybe obvious ways I can improve the code that I'm unaware of. This is my first time using Selenium and pa... |
I have a function returns a random integer number. This function only accepts these three numbers 1,2 and 3(there's another function in my code which is make sure of this otherwise that function will raise ValueError and re-prompt the user again). If the function gets 1 it should generate a random number between 0-9. I... |
The code below is my first purpose built asynchronous recursive function. It took me a while to figure out how to write the thing, and I would like a second opinion.
It's part of a project for The Odin Project, a simple book log. I don't have the site live yet, I want to implement a few more features first.
I was hopin... |
I have solved the pascal's triangle problem. I am not good at writing efficient programs, hence any suggestions/ comments shall be welcomed.
# pascal's triangle through list
heightOfTriangle = int(input()) # input height of triangle
powerOf2 = 0 # setting the initial power of ... |
The following code is a conversion from some old java I wrote to python.
It shows the beginnings of a simulation of an ant colony.
I am finding the animation speed very slow - and I'm wondering if I am doing something wrong - or if it's nothing to do with the animation, and everything to do with not exploiting the vect... |
I'm trying to increase the number of elements in the #source div from two to three and so on. But in order to increase it each time, I will need to create a lot of new lines of code with pretty much the same data (const three=, new fuction appendIt2(), and add an extra if in the window.onload).
Maybe you can advise how... |
I have written alphabet rangoli code in python and would like to get it reviewed. The goal is to print concentric diamond shapes made of letters, with "a" at the center, "b" forming the next layer, then "c", etc.
Any comments on making it more logical or concise shall be appreciated.
import math
# input the size of ... |
I would like to know if there are any benefits of one of the following 2 methods which insert an object into a database
The first function calls the Model method statically, creating a new instance of the Insert function on the call.
foreach ($model_data as $data) {
$row = \Models\ModelData::createRow($data, $u->dn... |
Comments on optimizing the code or improving the code are requested. The input parameters to the class constructor are a one dimensional array of job ID's and the second argument is a list of vectors each vector containing two elements which specifies a constraint that the first job should be scheduled before the secon... |
I am managing an OAuth implementation for Puredata (Pd), which is written in C. OAuth can accept RSA keys, but Pd cannot send messages with newlines, so placing private keys will come as a list of strings with spaces acting as separators.
Basically this function looks into the different parts of the block and adds eith... |
I have a HTML5 range slider. i.e. <input class="range-slider" type="range" id="points" name="points" min="0" max="220">
I am showing, hiding, and changing some content based on the selected range slide values.. with Vanilla JS, I have all my functionality logic done, but I hate how much code it is. Is there a better, l... |
I've been experimenting with wiring up a vanilla web component in a reactive manner to a state box. The goal is that when something changes on the state object, the web component reacts. I realize that there are frameworks and libraries for this, but I want to understand fundamentally what goes on underneath. After two... |
I wrote a Python code for a device that generates an hotspot and communicates with an app using a TCP socket. The communication is managed by a process that opens a socket and uses two threads to send and receive data. The data is shared with the main process using two queues. An additional queue allows the main proces... |
The solution I have written is working as expected, but here is my function:
const dataExtraction = () => {
const { id, name, sprites, types } = data;
const pokemonType= types[0].type.name;
const { front_default } = sprites;
const animated= sprites.versions['generation-v']['black-white'].animated.front_default;... |
I program python as a hobby and wanted to learn how to apply databases in a functional program, while at the same time make something useful. so I made a to do application with some basic functionalities.
add new to do task
look at all tasks
delete a task
This is the first time I used sqlite3, and I'm not very experi... |
This is the List to Dictionary Function for Fantasy Game Inventory project in Chapter 5.
The project is as follows:
Write a function named addToInventory(inventory, addedItems), where
the inventory parameter is a dictionary representing the player’s
inventory (like in the previous project) and the addedItems parameter... |
I'm learning Rust, and I have a simple program that I hope to use as a learning exercise. My goal here is to get a better idea of the proper way of doing things.
I'm trying to use the fastq crate to do some manipulation of fastq files - these are simple text files that are standard for storing high throughput [DNA/RNA]... |
I've encountered a paginated API route where there is no way to know the number of available pages. The only way to retrieve every pages is to check on each page if a next page exists. To do so, the HTTP response of any query contains a header called x-next-page, if it holds an integer bigger than the current page nu... |
Recently I have been learning Python after years of putting it off, and I am having a really fun time with it. However after I spent a few hours making something that I thought was pretty cool, I decided to share it to one of the Discord servers that I am in. And then from there on everyone just kind of mocked me, and ... |
I've got a working implementation of a go program to talk UDP to
TimeMachinesCorp POE clocks.
This code is also in a github repo which notes things I know aren't implemented yet. I feel like there's enough working functionality now to get a code review and work with those suggestions before building out the rest of wh... |
The code:
excluded_columns = ['sort_id', 'weekday', 'sort']
for pct_col in sort_df.columns:
if pct_col in excluded_columns:
continue
else:
sort_df[pct_col + '_pct'] = (sort_df[pct_col] / sort_df['volume'] * 100)
There are no specific concerns I have with this code, it just looks off. I know p... |
I would like to know does this code follow common best practices in C++ using STL.
Goal of the code:
There are 10 players that were playing a game 1000 times. Each time someone has won they have put winners name into the binary file data.bin. Each name takes 20 bytes of data in the binary file and uses \0 as a string ... |
Tired of always having problems in reading arbitrary length lines from file under Windows, I tried to write a POSIX getdelim() and getline() implementation for MSVC. Let me know if you have any suggestion for improving this:
getline.h
#ifndef GETLINE_H
#define GETLINE_H
#include <stdio.h>
#define restrict __restrict
... |
I wrote a simple tic-tac-toe game in Python. I'm pretty much a novice, but I do have some experience with coding other things in Python. I just wanted to see if I was capable of writing a simple tic-tac-toe game, since I never really went through that rite of passage. I realized it wasn't that difficult for me, but I t... |
In this project I was supposed to add and delete books by author and title by pressing the submit and delete button.
There is a video that illustrates how my project works.
I did it using two functions which saves the added books into an array of objects. I'm just starting to learn how to code so I'm looking for some o... |
Below is my code for building a call-flow graph from a Python abstract syntax tree. I'm not satisfied with it because the algorithm is very complicated. Perhaps much more complicated than it needs to be. So I want suggestions on how to simplify the algorithm and also on how to make the code more readable.
class BasicBl... |
I am new to Python but not new to PHP. I've started porting PHP APIs to Python hoping to learn the Python language along the way, currently trying to grasp List, Dict, Set, Tuple. I tried writing PHP's array_push() in Python:
def array_push(array: list | dict, *args: any) -> int:
if isinstance(array, list):
... |
I'm very new to OCaml, and as an exercise I decided to implement the nth Fibonacci algorithm (return a specific Fibonacci number, given an index) in different ways, using what I've learned so far.
I also want to start practicing test-driven development in OCaml, so I also included some basic tests using assertions.
Her... |
This exercise comes from Automate the Boring Stuff CH 10 - second edition. The exercise is called "filling in the gaps," and the instructions are as follows:
Write a program that finds all files with a given prefix, such as spam001.txt, spam002.txt, and so on, in a single folder and locates any gaps in the numbering (... |
The project outline:
Write a function named printTable() that takes a list of lists of
strings and displays it in a well-organized table with each column
right-justified. Assume that all the inner lists will contain the same
number of strings.
My code:
def demo():
tableData = [['apples', 'oranges', 'cherries', 'b... |
I wrote a sorting program so that if the optional argument -i is present then the sorting should be done without taking into account lowercase / uppercase letters.
The program uses the standard library qsort() algorithm; case-insensitive option is handled by getopt() if the -i flag is supplied to the program.
Please cr... |
I have been given the following task to complete. I am not sure if my solution is the most efficient. Are you able to take a look and suggest any changes?
task:
An application that finds all pairs of natural numbers whose sum is 12. Once a number is used to create a pair it cannot be part of another pair.
Input values:... |
I don't feel too comfortable with the use of object oriented programming and the related advanced topics. That's why I went through this exercise of using Python's abstract class to implement an abstract Ansatz class. (An Ansatz is basically something like a mathematical assumption, i.e. we might assume that our soluti... |
I'm working on a string manipulation code in C++ for my internship project, where I have to find a substring within a string and essentially replace it and some characters following it with a newly computed sequence based on other inputs (here, the string vector 'patterns'). I have been trying to find a better way to m... |
I am working on my Python skills and would like some feedback on this problem I have tried to solve. I would like to return a boolean if two knights at their current position can attack each other using standard chess notation example (4,'A')
from itertools import product
class ChessPosition:
def __init__(self, nu... |
I'm new to learning OOP in python and played around with it, making this quick battle terminal based game-ish, but I'm wondering how I can optimize this to maybe less lines of code and just overall being more elegant?
import random
class Enemy():
def __init__(self, species, enemy_health):
self.species = sp... |
I implemented the tee command from linux. The program also handles the -a option for adding text to the end of a file if it already exists.
I would like you to find some weaknesses, bugs or anything else in the implementation.
#define _POSIX_C_SOURCE 2
#include <errno.h>
#include <err.h>
#include <stdbool.h>
#include ... |
I build a function(A kind of puzzle) that counts from a matrix the number of valid count (Explanation below).
The matrix is made up of 0,1.
Input-
a matrix- list of lists
row number
column number
Output-
valid count.
Valid Count - This is the number of cells that are in the same row and column that we got in the In... |
After many years away from writing in Python, I am getting back into it. Specifically, I am trying to teach myself dataclasses. As an exercise I wrote a Wordle-solving program. I downloaded the list of possible Wordle solutions and began writing.
There are two functions. The first simply asks for a five-letter stri... |
This is a simple program that parses a menu specification and creates a menu tree.
Why?
I want to create a menu application, where the user can select an entry in the menu, and either a submenu can pop up (where the user can select another entry) or a command is run.
But before writing this menu thing (which requires s... |
I have to implement an interface which returns a List:
List<Foo> getAllTheFoos()
The Foos come from a DB, and there may be a lot of them. I know exactly how many there will be before I make the query. Once getAllTheFoos returns them, the caller will do something involving IO with each Foo in turn. (Obviously it would ... |
Let's say we have two aggregates:
public class Order : IAggregateRoot
{
public Address Address { get; private set; }
public int? BuyerId {get; private set}
public OrderStatus OrderStatus { get; private set; }
public string Description {get; private set;}
}
and
public class Buyer : IAggregateRoot... |
I'm struggling to find a proper name for a specific method (in code named NameOfExtension), and would also like some feedback about its implementation.
I am writting an extension method that must return the next enum value given a specific enum item (order is given by GetValues method). If it reaches the end, it should... |
I have some predicate objects that take some value and return the result of some criteria. (My real implementation is more complex, this is only a minimal example):
Run on Compiler Explorer
struct PredEven
{
bool passes(int x) const { return x%2 == 0; }
};
struct PredGreaterThan
{
int limit;
bool passes(int... |
This is the first ever bit of front-end code I have ever written, I have tried to adapt the existing call that is there to the backend using axios, so I check on of the response object value using the key like so:
if (result.data.is_cached) { ...
Then I create a function called getStatus, and use a setTimeout to keep ... |
I have been provided a text splitter class that will take a text input and use re.sub to make replacements when matches are found and also splits sentences up and stores them in a list.
I had an idea to improve the code by storing the expressions in a list and iterating over the list and for each expression looking for... |
I know that this program is not very outstanding, but I'm learning "Python" and decided to publish this code in order to get some advice and parting words and overall evaluation of the program. This is a simple timer with the ability to enter the desired number of minutes, start and reset functions.
As a beginner, it i... |
For this task, I don't think that the Observer Pattern can be used in its classic form. Those who have received the requests and those who choose to accept the request are not the same group. Those who choose to accept
the request could be viewed as the observers, and they can stop accepting the request at any time a... |
Just started learning Rust and here's a program that has caused me some agony to implement in Rust. This is very easy to implement in C++, but Rust's borrow checker is causing all sorts of trouble. My program tries to solve the following challenge:
You are given an integer array nums and an integer k.
In one operation... |
Before showing-off the code, here is a bit of an explanation.
I have a Spring component that spawns a thread for watching a directory for new files.
In this context, I have a method that runs in a Java Thread and performs operations that might be interrupted (especially if the container class is being close()d). The Sp... |
Here's the code:
"""A proof of concept that shows how to use Gitlab CI's "parallel" keyword
in order to parallelize a large battery of unit tests across many nodes.
In order to give it a try, create a test project with more than one job
available and create a .gitlab-ci.yml file with the following contents:
test:... |
I have created an algorithm which calculates the value of PI in JavaScript.
Can this algorithm to be improved?
let PI = 0;
for(let i=0; i<80; i++){
let numerator = Math.pow(factorial(i), 2) * Math.pow(2, i+1);
let denominator = factorial((2 * i + 1));
PI += numerator / denominator;
}
function factorial(n){
... |
This is a small library I wrote to make event callbacks with variadic templates work like C#'s event system (placeholder template by "dyp" at http://stackoverflow.com/a/21664270).
Just like in C# you can subscribe/unsubscribe/call multiple function callbacks to a single event (invokable class in my library) using the =... |
I wrote a program that implements an algorithm that converts from decimal to binary and octal
Please criticize my implementation. What else can I do to improve?
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <string.h>
int n, option, flagOctal;
int a[100];
void baseConversion10Base2(long long x)... |
I have complete my minesweeper game using Tkinter and would like to know ways to improve. I also have a question for extra features: does anybody know a way to have a opening start, like google minesweeper does where it breaks open a bunch of squares? Here is my code, accepting all comments:
Please criticize, readabili... |
I have this function that should take some array of objects and sum up the values of the inner objects based on some keys, and conditionally add to it some values from another object.
Is there a way to optimize this code?
function sumUpKeys(objects, totals = undefined) {
const totalsSum = totals?.reduce((tot... |
I am new to parallel programming. I have been playing around with multi-threading and for some reason, multi-threading the Mandelbrot set is slower than running a single thread. I have been trying to figure it out for hours. Are there any improvements that you could suggest or perhaps something is wrong with some parts... |
I have an implementation of a Quantum CNN on the MNIST dataset but right now, the code is just a bunch of standalone functions that call one another:
# Dataset preparation
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
# Normalizing the data between range of 0 and 1
x_train = x_train[..., n... |
Background
I was looking at some programming Olympiads the other day, and I found this ACM-ICPC Ukraine 2013 pdf.
The part I am working on is Problem D, which consist of finding out how many rectangle can you nest within another rectangle.
Assume a sequence of \$N\$ rectangles \$a_1 \times b_1,a_2\times b_2, ..., a_N \... |
Please check over my Python code for a HTTP GET operation using the requests library, and provide any potential pointers for improvement.
import requests
token = input()
payload={}
headers = {
"Accept": "application/yang-data+json",
"Content-Type": "application/yang-data+json",
"Authorization": "Bearer {... |
I need some review for this CPP Linked list implementation.
This is my first time implementing such a data structure in CPP.
Thanks in advance.
/*
**
** author: Omar_Hafez
** created: 12/05/2022 05:15:38 PM
**
*/
#include <bits/stdc++.h>
using namespace std;
template<class T>
struct Node {
Node<T... |
This app only creates a chess board set to the start-of-game state. It does nothing else. I'd appreciate feedback on the files that are relevant to this board setup (all shown below: board.cpp, pieces.cpp, board_view.cpp). Although the project uses SFML, I'm hoping for C++ feedback, not SFML best practices per se.
Belo... |
It has been a long time since I have gotten into OOP with python. I made this short little program. Are there any ways that I can make it more clear or concise (pythonic if you may)?
############################################################################## Blackjack
##############################################... |
I recently made a program with C++ and ASM. Can anyone help me make this code a more efficient one, in the ASM part or both.
I would really appreciate it because I don't know every ASM instruction and probably I am using way too many. BTW the program sums two integer vectors with any size.
The code that I have:
C++:
in... |
I have a column with variable length text in each of the cells. I have written some code to add padding to the top and bottom of the cells. While the code works well it becomes quite slow when the number of rows is extremely large. Is there a better way of achieving the desired result without looping through each cell?... |
I just solved a problem from leetcode that is faster than 28.42% of the PHP codes, so the main review target is not the performance or alternative ways to solve this problem. I wrote the code thinking about DX, how readable and clear my code is, but currently I don't have anybody to judge my code.
A particularity of th... |
I followed a tutorial that goes through different practical examples and challenges using vanilla Javascript, HTML and CSS. I just completed a simple rock, paper, scissors game; however the tutorial does not really focus on code quality but rather on understanding first. Before I move on to the next challenge I want to... |
I am looking to obtain the partitions of coins that sum to a target amount
So I tried search online, but every single website loves to use this problem to show the benefits of dynamic programming. However, they all only show the number of ways to sum to the target, or the minimum amount of coins.
I am not interested in... |
I've built a small slug generator that will take an input from a user and replace all of the spaces with dashes to create a nice looking slug. I'd appreciate any tips to make my code better.
<input id="nameValue" type="text"><br>
<input id="slugValue" type="text">
<script>
let nameValue = document.getElementById("nam... |
I have two indices in Elasticsearch which are brands, and categories, and I have a very simple script that generates brands from the categories index. I've split my code into separate functions to make it cleaner. I have also benefited from multiprocessor, but I want to know if there is a pythonic way to make my script... |
I wrote logic for "Wordle" game but I think it's too heavy and not very readable.
Is there any way to improve it?
Simple wordle game with conditions:
1) Green colour - "G" if string1 and string2 indices values are equal.
2) Yellow colour - "Y" if string2 indices value appears in string1.
3) else statement Grey colour ... |
This is my console simulation of the Slot Machine in C#. Please take a look at this code and point out possible ways of improvement.
using System;
using System.Linq;
namespace Casino
{
class Program
{
public static void Main()
{
SlotMachine slotMachine = new SlotMachine();
... |
I am really, really new to coding in general and especially c++. To get more familiar with c++ I am trying to do a series of projects with c++ console apps. One of my projects is with a database that uses a password to authorize entry of the database. I read a post talking about using fstream to create a text file to c... |
I have a complete graph with n vertices, set W (let's say W = {1,2,3}) and a path path (let's also say path = {1,2,3}). Every edge of my graph is randomly labeled with one of the elements of the set W.
For better understanding, that's one of the examples for n = 5.
What I need is to find the number of paths path in thi... |
I am a beginner to Clojure and I made a little script that prints out every prime number from 1 to 1000. Let me know if there are any improvements that I can make:
(loop [i 2]
(loop [j 2]
(when (= j i)
(println i))
(when-not (= (mod i j) 0)
(recur (inc j))))
(when (< i 1000)
(recur (inc ... |
I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as shown below.
During server startup, it calls read function below to populate two concurrent map.
And also periodically every 30 seconds, it calls read function again to read new s3 files and pop... |
Introduction
We have std::map<key,std::vector<std::string>> m; where the key is represented by std::tuple<std::string, std::string,std::string>. But there is a constraint, the last field of the tuple can be an empty string. If the last element of the tuple is an empty string then we should merge it with the with eleme... |
I am always super interested in both science and art, science and art are two different ways to describe the objective reality, they are two sides of the same coin, in many areas they overlap, and mathematics is the most prominent one of such areas.
So I used the last three days to write a bunch of functions that gener... |
Description: I would like to sample n_points points from k circles whose radii and centers are given as lists.
Note: This is my first question :) And k is not a very large number, usually k<7.
My code: I guess the parts where I compute the number of points for each circle, and the for loop can be improved. Perhaps with... |
The following program uses a parent program to determine the PIDs of multiple child processes. A function is called to return them to a dynamic vector (with the children's pids, but also the elements in the vector)
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
in... |
I have attempted to implement a "fast Pimpl" idiom based on the talk slides and further sources, which is essentially an aligned storage of some size that can be used as a drop-in replacement for std::unique_ptr when implementing the Pimpl idiom:
// ...
private:
// std::unique_ptr<Impl> pimpl_; // allocation and poin... |
I'd like to have a standard test template to copy from when solving coding puzzles. Typically, I would need to write multiple test functions to check if my function is working as expected. However, it's easier to write table-driven tests. In this case, all I would need to do to add a new test case is define the name, i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.