instruction
stringlengths
71
95.1k
In order to implement an efficient AST visitor preserving the principle of locality, I implemented some reference counting mechanism in C++ with the following set of features: All the newly allocated memory shall be stored in a contiguous allocation memory, so to preserve the principle of locality (minimize the page f...
Programming to an interface is a design principle that enhances the flexibility of software by hiding implementation details. Consider an object tree that only exposes an interface, but you want to add additional behaviour that operates on implementation details. A compositional object structure like that exposes an in...
I'm implementing a std::function like class that uses type erasure. So far it can be used with function objects (functions/function pointers, functors, lamdas) and pointer to member function. But to support pointer to member function I used a C++17 feature, namely constexpr if, to choose at compile time which implement...
I am new and trying to learn programming and have been working on a battle simulator that I hope to eventually develop into a RPG game with characters, areas to explore, etc. I have been working on the battle between you and an enemy and have most of the base mechanics done however I would like to clean up and improve ...
I'm a JavaScript beginner trying to learn by doing. Here I have a table with different values: I have used two for loops. Is there an easier way to achieve this? For example having just one for loop, or instead of it use something else? Even better would be if you could give suggestions to improve the code to be more r...
I'm struggling to find the best way to prevent users from cancelling a routine halfway through (by pressing ESC, break, etc) without making sure the sheet is being locked again. On top of that, I also want to manage potential other errors that this routine could generate. My code is : Private Sub Worksheet_Activate() ...
I created a project using VLCJ and a probability function to create a media player that plays your favorite media more often than the others, because I wanted to hear my favorite music and videos more than my least favorite. This involved a lot of event listeners that were all at the bottom of my main class file where ...
This is supposed to be a depth first search. I just took the idea of what it does and made my own version of it. The bot works it's way through the maze, when it finds a dead end, it moves back to original spot, and continues in a different direction than it's already gone until it reaches E the end. import java.util.S...
Please see the following code. I am using it to calculate the double integration. Please help me to improve the code. import numpy as np from scipy import integrate from scipy.special import j1 from scipy.special import j0 from numpy import sin from numpy import cos from numpy import pi import time import numba as nb ...
Is there any way I can make this code more efficient? I'm new to C, any suggestion is welcome! #include <stdio.h> #include <string.h> #include <math.h> #define LIMIT 1024 unsigned long htoi(char s[], int len); int main(void){ char line[LIMIT+1]; int i=0; for(int c=0; i<LIMIT-1 && (c = getchar()) != '\n'...
I built a very basic blackjack program a couple of weeks ago, but I've learned a lot since then, and would like some input on a couple of basic functions for card games: a build_deck function and a draw_hand function. It seems pretty efficient use of code (at least compared to my previous attempt) but I'm sure there ar...
Well, I'm not going to use it everywhere, as jQuery exists, but still was interested in experience of creating own library. Here are first steps: ;(function() { window["_o"] = function(selector) { if (!selector) { throw new Error("Cannot create Object from " + selector); } var elems; if (sel...
We all know that the famous twitch log site OverRustleLogs is getting shut down. So I decided to do some web scraping to download my favourite streamer's logs using BeautifulSoup. How can make this code run more efficient? import requests import os import shutil from bs4 import BeautifulSoup URL = 'https://overrustle...
I tried to implement printf family functions in C89, after I've read K&R book. The goals are three: Do not use dynamic memory allocation (like malloc); Write a modularized code; Write portable code without use machine dependent behaviour; Avoid undefined behaviour. Performance is not a goal, I used naive algorithm wi...
I am gaining a lot of interest in Game development. I created Chrome Dinosaur game in C++. I have not paid much attention to UI/UX, just trying to see if i can apply some OOPs in game programming. As I'm a beginner, I'm not sure whether I'm using good code design and logic. I could use some code review and tips. Before...
I've some functions targeted to simplify working with strings in some of my other projects. I'd like feedback on this code and whether or not the implementation is efficient and memory safe. I work with both normal strings (char*) and string arrays (char**) in this code. Here's stringfuncs.c #include<stdio.h> #include<...
I have implemented a utility class to perform various random number related task. I am looking for any feedback on design / implementation. I plan to expand the class, and so would like to correct any "bad habits" and or improve the basics before I proceed. Random.hpp #pragma once #include <gsl/gsl> // gsl::narrow (f...
I wrote this code for a PowerShell function that allows you to specify rate limits and makes a script block follow those limits. The script block return value is for specifying if it should be counted, i.e., when a server has rate limits and the request to the server doesn't happen due to a client-side error, the scrip...
I decided to dive into the world of functional programming since my programming so far has been mostly in C/C++, Java, and Python. I've gone through a couple Haskell tutorials and played around in GHCi so I decided to try my first real program. I decided to try one of the easier problems on Kattis.com, Transit Woes. Yo...
Python script that can downloads public and private profiles images and videos, like Gallery with photos or videos. It saves the data in the folder. How it works: Log in in instragram using selenium and navigate to the profile Checking the availability of Instagram profile if it's private or existing Creates a folder ...
I made a statistics calculator based on raw data for my Edexcel IAL Statistics 1 course which I'm going to use in my calculator's MicroPython. I would like some suggestions for ways to further improve my code and become better at Python. Note: MicroPython only supports a subset of the standard library. import math d...
I created the famous Minesweeper-game in Java, for which I used java-swing to create the GUI. Here's the code: Control.java: This class contains the main-method, which just opens the GUI. import javax.swing.SwingUtilities; public class Control { //Just to start GUI public static void main(String args[]) { ...
I have an app that has only one activity and 5 fragments. I removed the navigation component because it was buggy and restored the old navigation, which is simply a BottomNavigationView with OnClickListener. The problem is, that I don't want to recreate the fragment views, because it takes up to a second for 2 of them ...
Recently I posted an answer on a question about Bézier curve calculations. As a micro-synopsis: there are three implementations of De Casteljau's algorithm here, including the original poster's, AJ Neufeld's, and my own. I've also added some non-recursive implementations based on a couple of different forms of the Bézi...
I'm trying to understand an SO answer for this question Golang select statement with channels and waitgroup. The author of the now accepted answer goes on to say that OP's code is almost similar to this, when the function is replaced with the actual code package main import ( "errors" "fmt" ) func main() { ...
Code Review I've recently (within the last month) started learning Python and am now building a few basic apps. One of the apps I've created is a sort of desktop monitoring tool, that attempts to build a list of all applications used within a specified time period. Process - Check whether the current time falls betwee...
Adding Dynamic Slides to a slider used by a client shifts its index, need to account for that so i wrote this simple code, but i think it's pretty lame, is there any way to improve it and accomplish the same output? var slides = { 1: { content: "", group: 1 }, 2: { group: 1 }, 3: { content: ...
I have implemented the Harry Potter Kata and I need your feedbacks. The rules are: A book costs 8 euros. There are 5 different volumes. To get a discount, you must buy books of different volumes: Buying 1 book doesn't give you a discount Buying 2 books applies a 5% discount Buying 3 books applies a 10% discount Buying...
I have code in C that multiplies each element of an array by a number (0-9), resulting in a series of base 10 digits. I compile with gcc -xc -Ofast -msse2 -flax-vector-conversions -ffast-math -funroll-all-loops --param max-unroll-times=50 -ftree-vectorize -fopt-info-vec-missed My processor is core i7 950. My problem i...
Main purpose of this code, Take some information for animal features Clasification of user input print those input into txt file My problem is that, I think coding of animal features takes too much lines. Is there any way to do that in a simple way. Something like putting all the features(nutrition etc) into animal, ...
Following up on my previous Column work: Column File Format Stream It is now available in github: https://github.com/Loki-Astari/ThorsStorage I have incorporated the comment by @L.F. but have done a lot more work since then. Unfortunately the main code is now at 798 lines so too much for a single review. I will break i...
I gave a shot to infamous finding dependency problem. I highly encourage to give it a go yourself before seeing the solution I came up with. Here is the problem statement: Given a list of projects that need to be built and the dependencies for each, determine a valid order in which to build the packages. Here is what...
I made an RPS Game with python with the Crypto and socket modules. I would like you to look at the code and tell me if anything can be improved, and if there are mistakes, etc. The game is working like this, the server is setting up the socket connection, and then listening for 2 clients at least, when there are 2 clie...
I started the CS50 and am at pset4. I completed both the less and more parts for the filter app that takes an image and applies a filter to it. In this pset we need to write the filters code only(greyscale, sepia, reflect, blur and edges). The edges function should apply the Sobel operator to an image so that it detect...
I have 25 branches but I'm only allowed to have 12 branches maximum. The objective of this task was to cancel out unnecessary punctuation, find the common elements that exist in the sentence and dictionary and then to translate the result into English into the other language or the other language to English, depending ...
I currently have two entities, Adress and Company. They both have DTOs to perform CRUD operations. AddressCreateDto: @Getter @Setter public class AddressCreateDto { @NotNull private String address1; private String address2; @NotNull private String city; @NotNull private String state; ...
I'm playing around with making random items and decided to implement the following structure. #include <stdlib.h> //uints #include <limits> #include <random> #include <iostream> class RandomItem { private: struct _physical_properties { uint16_t length; uint16_t width; uint16_t sqew; uint16_t weight; }; struct...
I have a need to use a shared variable among different threads in c/C++. So putting my knowledge of threads and mutexes I have written the below sample code. Can anyone please review the code and provide me review comments so that I can improvise it in a more better way. Also I know about atomic variables but somehow I...
In a method I made this @Override public boolean canEditHq(User user, LocalEvent localEvent) { if (!HQ.equals(user.getUserHierarchy())) { return false; } if (!SECOND_APPROVAL.equals(localEvent.getStatus())) { return false; } final boolean hqCanApprove = this.parameterValueService.f...
This is my second Python program, and I wonder if this code is readable to most people or if it only applies to me. Should I make more distinct functions or use more appropriate names? Are there other ways that lessen the lines of codes and do lesser lines mean more readability? Any suggestions would genuinely be appr...
Problem Statement: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. This is a leetcode problem. I am looking for feed...
As part of a Stack Overflow answer, I whipped up a quick example implementation of a function to set a nested property of an object using a dot notation string. The goal was to show how that could work in a small amount of clean code: function set (object, property, value) { if (typeof property === 'string') property...
I'm learning C at the moment and chose implementing quicksort as an exercise. My code is sorting correctly, but afterwards I looked at some tutorials online about quicksort. And they implement it differently. I don't know, if I misunderstood quicksort, or if I simply implemented it differently. How I understood quickso...
I'm making a code that, starting from an xml file: stores the index of child elements of a tag and the child elements as key, values in a dictionary; deletes keys whose values contain a certain string; joins the dict values and extracts their text; replaces certain values with ""; counts the occurrences of specific re...
Is there a way to make my code more compact or efficient? Testcase example 1 : rabcdeefgyYhFjkIoomnpOeorteeeeet output: ee Ioo Oeo eeeee Testcase example 2 : baabooteen output: aa oo ee import re def find_two_or_more_vowels(string: str): match_obj = list(re.finditer(r'(?<=[qwrtypsdfghjklzxcvbnm])([aeiou]{2,})(?=[qw...
I was trying to write a memory pool interface which: Grants memory of fixed size chunks in linked list style fashion. On returning the memory there is no risk of memory fragmentation. //mem_struct.h #ifndef MEM_STRUCT_H #define MEM_STRUCT_H struct mem_struct { char arr[4]; struct mem_struct *next; }; #endif ...
I have a XML file (test.xml) that can be sum up as follow (I filtered it so it will be more readable): <coverage complexity="0" line-rate="0.66" lines-covered="66" lines-valid="100"> <packages> <package complexity="0" line-rate="0.66" name="."> <classes> <class complexity="0" nam...
I am working on a game engine using CMake, this being the first CMake project I worked on I am looking for some feedback. The project has the following structure: root |--CMakeLists.txt |--Cheetah | |--CmakeLists.txt | |--includes | |--dependencies | |--src | |--out | |--build | |--x64-Debug | |--Cheet...
I am new to Python, so I am interested in knowing if I am efficiently using python for this project. This program is meant to simulate the Central Limit Theorem. It uses sliders to adjust the number of measurements and the number of trials. Central Limit Theorem: Given any distribution, begin sampling by making a serie...
I've looked through a lot of solutions on this topic, but I have been unable to adapt my case to a performant one. Suppose I have a list of dictionaries stored as: db_data = [ { "start_time": "2020-04-20T17:55:54.000-00:00", "results": { "key_1": ["a","b","c","d"], "key_2": ["a","b","c","d"], ...
How do I refactor this mess of if/else conditions so that it's more readable? ( Reverse_Path = [[]] -> Child = [c(New_Score,G1,Pos),P] ; otherwise -> Child = [c(New_Score,G1,Pos),P|Reverse_Path] ), ( memberchk(Child,NewAgenda) -> addChildren(Others,Reverse_Path,Current,NewAgenda,Target,Result) ;...
This code accepts input from the user on a game of Texas Hold Em Poker. It then reports back the odds of winning against a single opponent at each betting stage. The calculation needs to process (50 choose 5) * (45 choose 2) for the pre-flop calculation. The way I know this can be done fast is to randomly sample these ...
I've been listening to some programmers and they use terms like good and bad code. I am not really sure what they mean by that. I mean I went on r/badcode and saw some stuff I knew was definitely bad code. But I don't really understand if bad code is repeatedly typing the same code instead of looping or just bad layout...
I created state change detection for multiple buttons, which is intended to run on my Arduino for a touchpad project. In a nutshell, the code makes sure that the Arduino only reacts to button presses and not to holding in the buttons. My code: unsigned int buttonStates[] = {0, 0, 0}; unsigned int previousButtonStates[]...
I am working with a large dataset expanding > 50 years. Each year has ~10 million lines of records with multiple variables/columns. I need to perform groupby operations by location and time. My code runs extremely slow - it takes 2-5 hours to process 1 year's data depending on the number of stations in the year. I look...
I am writing a generic CacheProvider factory which contains a concurrent dictionary to keep the "Named" cache objects (a custom implementation of memory cache based on concurrent dictionary) to be shared among different state machines/pipelines. I found this article and came up with below implementation public class C...
I wrote a function that merges two linked lists but I seem to have some code duplication I'm not sure what to do with: //merges two sorted linked lists into *merged_out, returns suitable error/success codes ErrorCode mergeSortedLists(Node list1, Node list2, Node *merged_out) { if(!merged_out){ return NULL_A...
I feel like my code is too messy-Im looking for possible way to make it more readable/shorter. Goals: 1)Get three strings from user input. They have to be the same length. a)First must contain only lowercase letters. b)Second must contain only uppercase letters. c)Third must have an even length and the same number of ...
I have the following code that aims to filter those pid (1 and 4) that have at least before_threshold (2) rows with a value of before in the day_type column and at least after_threshold (2) rows with a value of after in the same day_type column. Is there a more succinct way of doing this using the tidyverse packages? ...
I'm making a chess game. On the board the columns go from a-h and rows from 8-1. I made this simple function so when someone inputs 'a' for the row it will give me the right row on an array same goes for columns, 7a would be [1][0]. Is there an easier way someone could point out for me? Thanks in advance. update:added...
Turned in a project a few days ago, and I needed a way to filter and format values off a file. I decided to go for a bash script since it seemed like a good option, and I came up with the following: #!/bin/bash amount=100 awk '{ if($i == "data: 1"){ getline; getline; print $2}}' sensordata...
I'm trying to interact with a bash shell on a router to automate some CLI commands using SSH.NET. I'm not sure if the approach I'm taking is the best one and would like to get some recommendations on how to improve my methology. Although this code does indeed work correctly and does produced consistent results, the tim...
On StackOverflow I got a great answer to a question I had about creating a Date object from an ISO 8601 string with the ability to reposition into local time. From there I wanted to see if I could make it any faster. We process a ton of dates in batches of 10,000 or more sometimes on slow phones. This is the best I cou...
I am trying to write a function to determine whether an array contains consecutive numbers for at least N numbers. For example, the input is [1,5,3,4] and 3, it turns true because the array has 3 consecutive numbers, which is [3,4,5] Here this function requires sorting beforehand and it is not the most eloquent solutio...
I have written a program on Pig Latin converter which I've attached herewith Pastebin. I am still a beginner, and I know that the code works perfectly, but can we make some improvements in this code cause I don't like using break statements too much. Also, is there any way to make this code smaller. Looking for your ki...
I am trying to solve a problem on GeekTrust, called Tame of Thrones (here) Shan, the gorilla king of the Space kingdom wants to rule all Six Kingdoms in the universe of Southeros. There is no ruler today and pandemonium reigns. Shan is sending secret messages to all kingdoms to ask for their allegiance. Your codin...
I implemented a class for relationships with the user (deletion, name change, check for existence), I created this class to remove extra logic from the activity class. Could you talk about how my code can be improved? class UserActionManager @Inject constructor(private val repository : BaseAppRepository, ...
This is my solution for the Credit problem on CS50's (Introduction to CS course) Pset1. It involves using Luhn's Algorithm to test the validity of the Credit Card Number entered and based on a few conditions attempts to identify the Credit Card Company. check_length attempts to find the length of the number entered. ch...
I have designed this by using the stack data structure (similar to balanced parentheses problem) checking if the previous element is decreasing the number or not. package test; import main.algorithms.RomanConversion; import org.junit.Assert; import org.junit.Before; import org.junit.Test; public class RomanConversion...
As I added more features to my chess game, such as an endgame screen. I eventually ended up having a lot of duplicate code, and complex logic with lots of nested if statements in loops. The usual advice is to add more functions, but I cannot think of ways to reorganise this code such that each part has a highly specifi...
Details: I have a code, which does the following: Get data from CSV and insert it into MySQL table Get data from SQL Server and insert it into MySQL table Run this code every 240 seconds - to refresh the data, in order to have up to date infromation. I'd like to know whether the code below, I am about to provide, can...
My goal: to make the already easy task of filling out an excel sheet 1% easier by putting in hours and hours of effort. On a more serious note, I'm currently developing a system to manage inventory at my work. The following is my attempt to smooth out the process of receiving inventory when it arrives. To help visualiz...
I'm trying to remove email names from transcripts because it removes unnecessary info that is not needed in the transcript. The regex below removes email names from a spoken transcript. Examples below are completely made up. You'll note above that "dot" and "at" are the only common terms. Format: token1 tokenN at ...
I'm still learning c#, and I need my code to only run less than 2 seconds to be accepted. I have a look and say sequence and after the last number is found, the code sums it all up, and it takes so long if the element in the sequence is big. Example: Input: 2 Output: takes less than a second Input: 50 Output: takes 4 o...
awhile ago I asked about a thread pool implementation I had made. I took the advice down and modified it a lot over time to fit my needs. It has been serving me extremely well in all of my projects but I was wondering if there was anything else I could improve on? Here is the class: class ThreadPool{ public: /* Co...
I am implementing a functionality in Scala to Copy files from one FileSystem to another FileSystem. And this is what I have implemented. CopyFile.scala Methods are empty. However, they will just call external library and will do error handling. object CopyFiles { def localToHDFS(src: String, dest: String): Unit =...
Related to my code I just put out for review. I wrote some small helper functions for dealing with interactions with the file system. This is not meant to by any type of "File System" wrapper. I just wanted to put my code into named functions to make the code Column formatting code easy to read and the functions did no...
This is a pretty huge question, however, I would appreciate it if you could just review the design and not my implementations of it. The Implementation and test sections could be ignored, they are only there to aid the description of the design, in case I didn't describe it very well. This makes this question have a s...
For my game engine I am implementing ImGui for debugging purposes. In order to manage ImGui I have made a singleton to make sure only one ImGui context gets created. I am not entirely sure if this is a good implementation of a Singleton so I am looking for some feedback, also is using a Singleton here the right way or ...
I'm trying to split an incoming stream of strings into cumulative tokens per line item using a function below, def cumulativeTokenise(string: String): Array[String] = { val array = string.split(" +") var result: Array[String] = Array() array.map { i => ( result = result :+ ( ...
Extending this answer solution, I've wrote the following bash script to get the html of my StackExchange accounts page and parse it to a YAML file. The objective was list for each community I participate its url and my user id. get-stackexchange-info.sh #!/bash/bin NETWORK_PROFILE_URL=$1 # https://stackexchange.com/us...
I'm new to JavaScript and I decided to make a script that allows other developers to show SVG elements in the web browser. (It is just for learning purposes), and it is still under development. I coded it in ES5 first and then I'm willing to upgrade it to ES6+ so I can learn and understand the differences. I really app...
I want to read csv file in to array of structs with NULL ending. test.txt: 11,345,1,k 12,34.23,3,v 13,13.4,5,x 14,15.7,6,c My code: #include <stdio.h> #include <stdlib.h> struct csv_line { int value1; float value3; int value2; char char1; }; struct csv_line *line_pointer = NULL; int main(void) { FIL...
I have a method that I use nested foreach and the same variable call multiple times. I read a lot of optimizing code but I'm pretty sure I can do this with less code and best practices: public async Task<IEnumerable<IssueViewModel>> Get(IssueSelectModel model) { async Task<IEnumerable<IssueViewM...
I was asked to solve the following exercise: Given an input vector<string>, I have to find the anagrams and return a vector<string> with only the strings that are not an anagram from other strings in the vector. Example: Input vector: "code","doce","framy","frame","sad","cat","frema" Output: "code","framy","sad","cat"...
I wrote a simple card game in JavaScript and I wonder if anyone could give me some advice and make some improvements on my code. Here is the demo that I build: https://codesandbox.io/s/cardgame-his95?file=/src/index.js So it is a 2 person card game. Every card has a number and also has a pattern. The game goes like ...
I'm writing a program in Unity and am using a TextMeshProUGUI object (named history) to hold a list of messages to act as a terminal/console. The problem I am having is that I am printing up to hundreds of lines a second, which can be detrimental to performance when I'm doing many string splits and then updating the te...
I am trying to learn the Cartesian Coordinate System, starting with a basic tic tac toe grid for simplicity, then perhaps moving to chess. I was able to make the following code to start out: board = [] def new_board(): for row in range(4): board.append([]) for column in range(4): board[...
I have 2 functions to get the n-th fibonacci number. The 1st one uses recursive calls to calculate the power(M, n), while the 2nd function uses iterative approach for power(M, n). Theoretically (at least what I think), they should have the same speed O(log n), but why when I run both, the 2nd one is much slower than th...
I am total beginner in C and after reading K&R's chapter 5, I felt I was ready to at least make a simple game using C. I know linked-lists, so since I was making an implementation of Snake, why not? main.h #include <SDL2/SDL.h> #ifndef MAIN #define MAIN #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 SDL_Renderer...
(define or-l (lambda x (if (null? x) #f (if (car x) #t (apply or-l (cdr x)))))) (map (lambda (x) (apply or-l x)) '((#t #t) (#f #t) (#t #f) (#f #f))) '(#t #t #t #f) It will be used in a function that evaluates Boolean expressions.
I implemented mergesort in C as an exercise. I have two main questions: Is the code future-proof? 2.1 Will I have problems modifying it to sort float and double? 2.2 What could be problematic for creating a multithreaded version? I haven't learned multithreading in C yet, but I plan on a multithreaded version later on...
I've coded up a Vector class for use in my simulation support code, which I offer up for review. I decided to extend std::array. Now, I know that std::array is an aggregate type, but with C++-17 we can now extend an aggregate base type and still use 'curly brace' initialization. Extending std::array means that each Ve...
I do this as sort of hobby and want to no if I can improve. This is a simplified version of my code that normal works with bootstrap classes and id's. At the bottom there is the input of the classes. I have already a working version connected with SQL Database. but want to take it a step further with object oriented ph...
I have been learning linked lists for the past three days. I feel I have implemented a complete linked list. Are there any more things a linked list should do? Please can you review any or all of my code. I would be most interested in feed back to the more tricky section of the linked list. class Node: def __init__...
I've been meaning to revisit this old code for a long time, and this week finally ended up doing it. The resulting code is on GitHub, and for full context and disclosure I wrote a blog article about this exercise in OOP design. The idea is to abstract away the pain of making secure ADODB queries. This immediate pane co...
I had to solve three problems on graph theory that I solved by implementing a utility function and 3 functions, one for each of the problems. The problem set defines the input for all my functions as a E+1 x 2 matrix (they call this an edge list) where the first row V E contains the number of vertices V in the graph an...
Some background Feel free to skip this if you're not interested. There is a very popular bioinformatics program called tabix that permits interval-based searches for genetic variants in VCF files. To list all variants from position 100000 to 150000 on chromosome 1, one would invoke tabix db.vcf chr1:100000-150000. I cr...
I've got a task to create a readline() function that would have the exact same behavior as read(): ssize_t read(int fd, void *buf, size_t count); (man read) So it should return -1 on error and number of bytes read on success. Also, if the function receives a string with multiple \n chars, it should return only the fir...
I faced a series of problems when unit testing a tool of mine that generates files. They were caused by me putting the files in the same temporary folder and the tests running in parrallel. Here is an exemple of the unit tests (for @shanif) public class OutputWriterTests { [Fact] public async Task WriteToDirect...