body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>The situation is, I have two fields in a database (or that can be derived) - when the message was received (<code>Received</code>, of type <code>DateTime</code>), and the day of the month (but not the month itself) that the message was supposed to be received (<code>DayOfRun</code> of type <code>Integer</code>, whic...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T14:29:02.337", "Id": "513904", "Score": "0", "body": "Feel free to suggest better tags" } ]
[ { "body": "<p>A few suggestions:</p>\n<ol>\n<li><p>You're performing string manipulations, and then extracting numbers out of the string result, which is slow. The best thing to do is to ingest the data in a better format in the first place (so that the number you're extracting will be ingested in a separate nu...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T14:28:45.617", "Id": "260339", "Score": "2", "Tags": [ "database", "data-visualization", "azure" ], "Title": "Simplify a complex KQL Query" }
260339
<p>Is there a way to unify or refactor two methods that do basically the same but the difference being of handling a type of object or a collection of the same type of object?</p> <p>The following is an implementation of two methods that have very similar behavior. They handle a cache for an API, so when someone asks f...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T19:53:27.363", "Id": "513936", "Score": "1", "body": "Guys the code is compiling. If it does not compile (it does) you can abstract the idea of the methods." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-0...
[ { "body": "<p>I'm not sure I fully understand the question, but the first thing that leapt to mind is:</p>\n<pre><code>&lt;T&gt; can encompass a IList&lt;SomeType&gt; already.\n</code></pre>\n<p>I mean, the first 75% of GetValue() <em>already works</em> with using IList as the generic type:</p>\n<pre><code>publ...
{ "AcceptedAnswerId": "260353", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T15:46:02.040", "Id": "260342", "Score": "0", "Tags": [ "c#" ], "Title": "Is it possible to refactor these two similar methods that handle T and List<T>?" }
260342
<p>I am not very familiar with Swing but am attempting to make a Reddit GUI. I've finally got everything to work as expected but I must admit, it's quite mundane and not very nice to look at. I want to add some visually appealing things to it but as I said I am very new to Swing. I got help making the components and su...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T17:39:00.013", "Id": "513917", "Score": "0", "body": "Welcome to Code Review! While you provided a screenshot, it would benefit reviewers to have a bit more information about the code in the description. From [the help center page _...
[ { "body": "<p>About the code itself, you should try to separate the view from the &quot;logic&quot; by applying one of the various patterns (MVC and MVP being the most used), as said by Gilbert La Blanc in his comment,</p>\n<p>About the visual part, it is easier to create components that provide high level func...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-04T16:15:59.120", "Id": "260345", "Score": "2", "Tags": [ "java", "beginner", "swing", "gui" ], "Title": "reddit-like GUI" }
260345
<p>I have ~40,000 JPEG images from the <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification" rel="nofollow noreferrer">Kaggle</a> melanoma classification competition. I created the following functions to denoise the images:</p> <pre><code># Denoising functions def denoise_single_image(img_path): img ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T07:25:27.630", "Id": "513978", "Score": "1", "body": "Welcome to Code Review. What Python version are you using?" } ]
[ { "body": "<p>You may look at opencv <a href=\"https://learnopencv.com/opencv-transparent-api/\" rel=\"nofollow noreferrer\">Transparent API</a></p>\n<pre><code>#\nimgUMat = cv2.UMat(img)\ndst = cv2.fastNlMeansDenoising(imgUMat, 10,10,7,21)\n#\n</code></pre>\n", "comments": [], "meta_data": { "Com...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T03:18:59.100", "Id": "260355", "Score": "2", "Tags": [ "python", "image", "opencv", "multiprocessing" ], "Title": "Multi-core OpenCV denoising" }
260355
<p>I've improved my N-dimensional C++20 matrix project (<a href="https://codereview.stackexchange.com/questions/260197/c20-n-dimensional-minimal-matrix-class">C++20 : N-dimensional minimal Matrix class</a>).</p> <p>Implemented general matrix addition/subtraction, elementwise multiplication/division, dot product, matrix...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T05:57:12.687", "Id": "260359", "Score": "1", "Tags": [ "c++", "matrix", "c++20" ], "Title": "C++20 : Ndim Matrix, broadcasting, np.dot() and np.matmul()" }
260359
<p>I have to find the sum of number after performing square operation in the given input the negative numbers need to be ignored. The input Format is, first line is number of test cases followed by N as number of test inputs in new line followed by N space seperated numbers. The task need to be done using golang withou...
[]
[ { "body": "<p>There is a base case... it's the line <code>if x &gt; 0 {</code></p>\n<p>compare to the for loop version</p>\n<p><code>for x=input: x&gt;0: x=x-1 {</code></p>\n<p><code>findSquareSum(input,a,x)</code> sets x=input</p>\n<p><code>if x &gt; 0 {</code> is the condition check</p>\n<p><code>findSquareSu...
{ "AcceptedAnswerId": "260364", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T06:59:26.657", "Id": "260360", "Score": "0", "Tags": [ "recursion", "go" ], "Title": "Perform sum of squared numbers without using for loop" }
260360
<p>Exactly what the title says, this is a C++ class that attempts to read a file into a null-terminated string as efficiently as possible, using POSIX APIs. Obviously this is not intended to be portable code (other than between POSIX-compliant operating systems and GCC or clang), and the <code>Slurp</code> class would ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T15:20:47.317", "Id": "514007", "Score": "0", "body": "Why do you not trust the efficiency of `fstream`? Have you come to the conclusion that you need your own code based on an actual performance profile?" }, { "ContentLicens...
[ { "body": "<p>This is a good project, one that could be very useful in practice. I’ve had two or three C++ blogs over the years, and every time I spin up a new one, I include an updated version of a very old post I wrote about reading an entire file into a string. It’s not an easy problem to solve efficiently, ...
{ "AcceptedAnswerId": "260590", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T14:26:50.033", "Id": "260373", "Score": "3", "Tags": [ "c++", "linux", "io", "posix", "gcc" ], "Title": "Efficiently read a file into a (C) string using POSIX APIs" }
260373
<p>I've written a method that is going to set a bit array by passing bool parameters to be able send correct command</p> <pre><code>private byte _mode; public void SetConfiguration( bool mode1, bool mode2, bool mode3, bool mode4, bool mode5, ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T07:21:06.373", "Id": "514049", "Score": "0", "body": "Do you know that there is a `BitArray` [ctor](https://docs.microsoft.com/en-us/dotnet/api/system.collections.bitarray.-ctor#System_Collections_BitArray__ctor_System_Boolean___) w...
[ { "body": "<p>You could use a <a href=\"https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/params\" rel=\"nofollow noreferrer\"><code>params</code> array</a> to pass the parameters</p>\n<pre><code>public void SetConfiguration(params bool[] modes)\n{\n var setBits = new BitArray(8);\n\...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T14:55:02.193", "Id": "260374", "Score": "2", "Tags": [ "c#", ".net", "bitwise" ], "Title": "How to refactor a method with many prameters that sets a bit array" }
260374
<p>I've got this algorithm that's &quot;complex&quot;. The comments in code give examples of how large the various data types could be. My CPU usage is less than 10% when running this and RAM usage is good. No leakage or anything.</p> <p>I have a list of arrays, where each array is x coordinates. We are storing a list ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T17:55:31.773", "Id": "514023", "Score": "0", "body": "Can the arrays be sorted prior to calling this code? Being able to do a binary search to find `nearestIndex` would improve performance" }, { "ContentLicense": "CC BY-SA 4...
[ { "body": "<p>The question does not contain an explicit specification of what the code is to achieve.<br />\nThe code presented for review suffers from that very problem - How can anyone tell what deviations are allowable?</p>\n<ul>\n<li>variable names are an odd mix of <em>PascalCase</em> and <em>snake_case</e...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T14:58:53.613", "Id": "260375", "Score": "2", "Tags": [ "c#", "performance", "algorithm", ".net", "sorting" ], "Title": "How to make this algorithm faster. Calculates and s...
260375
<p>I've recently found myself in need of several <code>numpy</code> functions in C++. I've decided to write my own header-only implementation of the <code>numpy.array</code>, including functions that I most commonly use in my projects. The biggest piece of advice I'm looking for is memory management. I create a lot of ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T16:19:45.367", "Id": "514016", "Score": "2", "body": "From a quick look, you're badly mishandling memory and leaking a lot of it. You also have mismatched `new[]` vs `delete` usage (`new[]` needs to use `delete[]`). These should be ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T16:01:09.060", "Id": "260378", "Score": "3", "Tags": [ "c++", "c++17" ], "Title": "Num++: A numpy implementation written in C++" }
260378
<p>I am trying to solve <a href="https://www.interviewbit.com/problems/stringoholics/" rel="nofollow noreferrer">https://www.interviewbit.com/problems/stringoholics/</a> InterviewBit problem.</p> <p><strong>Problem Statement:</strong></p> <blockquote> <p>You are given an array A consisting of strings made up of the let...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T14:50:08.423", "Id": "514071", "Score": "0", "body": "Please include the text of the code challenge in the question, links can break." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-06-07T20:42:15.410", ...
[ { "body": "<pre><code>#define MOD 1000000007\n</code></pre>\n<p>Don't use <code>#define</code>. This should be</p>\n<pre><code>constexpr int MOD = 1000000007;\n</code></pre>\n<p>(and this is assuming that ints are big enough to hold that value!)</p>\n<pre><code>int findSmallestString(string A)\n</code></pre>\n...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T16:49:37.550", "Id": "260383", "Score": "0", "Tags": [ "c++", "programming-challenge", "strings", "interview-questions" ], "Title": "InterviewBit Problem: Stringoholics" }
260383
<p>The problem is to ask the user to guess a number between 1 to 100 and compare it with a random number of that range. If user guessed number is lesser/greater than the random number print &quot;too low&quot; or &quot;too high&quot; accordingly. Take new input asking the user to guess the correct number again. When th...
[]
[ { "body": "<p>This looks to do the job. I would only change the variable naming to be more meaningful in this context to guess for user guess and answer for the generated number.</p>\n<p>I would also try to handle erroneous input such as strings instead of numbers being passed.</p>\n<p>But besides this is still...
{ "AcceptedAnswerId": "260410", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T17:14:30.343", "Id": "260385", "Score": "5", "Tags": [ "python", "beginner", "python-3.x", "number-guessing-game" ], "Title": "Simple number guessing game in python" }
260385
<p>I have been reading through the rust book. I have made it to chapter 13, at the end of the section called (<a href="https://doc.rust-lang.org/stable/book/ch13-01-closures.html#storing-closures-using-generic-parameters-and-the-fn-traits" rel="nofollow noreferrer">Storing Closures Using Generic Parameters and the Fn T...
[]
[ { "body": "<p>Even though I'm relatively new to Rust myself, I'll give this a shot since no one else has responded so far.</p>\n<h2>Is <code>Cacher</code> caching?</h2>\n<p>Let's test that <code>Cacher</code> is working as intended (wouldn't call <code>calc</code> on the same value twice) by adding a log:</p>\n...
{ "AcceptedAnswerId": "260557", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T17:25:58.683", "Id": "260386", "Score": "4", "Tags": [ "rust" ], "Title": "Rust Book Ch 13 Closures with Generic Parameters and HashMap for memoization" }
260386
<h1>Quadratic Probing Hash Map</h1> <p>Looking to improve my quadratic probing hash map. Here are some design considerations and questions.</p> <ul> <li><p>Implementation is made such that the hashing function, probing function and load_factor can be changed. Changing them can be done by switching macros in the header ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T18:51:01.687", "Id": "260390", "Score": "0", "Tags": [ "c", "hash-map", "library" ], "Title": "Quadratic Probing Hash Map - questions about implementation and testing" }
260390
<p>I have finished our first version of bin-packing-problem script, but would like to ask you, if there's a better way to organize boxes? Boxes should be organized to save as much space as possible, to make the &quot;main&quot; (blue) box as small as possible.</p> <p>But in some cases boxes do not organize well.</p> <p...
[]
[ { "body": "<h2>Review Code style &amp; structure</h2>\n<p>I am not going to give a better solution (there are plenty of solutions available online <a href=\"https://en.wikipedia.org/wiki/Bin_packing_problem\" rel=\"nofollow noreferrer\" title=\"Wikipedia article\">Bin packing problem</a>) See Bin Packing under ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-05T19:33:08.057", "Id": "260392", "Score": "0", "Tags": [ "javascript" ], "Title": "Bin-packing-problem - is there a way to do it better?" }
260392
<p>For context, the whole of the project code can be found <a href="https://github.com/gappleto97/job-splitter" rel="nofollow noreferrer">here</a>. This question was created specifically for the <code>progress.py</code> file.</p> <p>The goal behind it is to allow progress of long-running tasks to be reported to a tty t...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T01:13:15.367", "Id": "260400", "Score": "4", "Tags": [ "python", "python-3.x", "multiprocessing", "mapreduce" ], "Title": "Subclass of Python's multiprocessing.Pool which allo...
260400
<p>I have a class called <code>CheckUserUltraSecretInformation</code> that is kind of a Use Case in &quot;clean architecture terms&quot;, this class has a dependency that is responsible for retrieving a couple of information from a cache &quot;provider&quot;, such as Redis, this is a crucial business rule for this use ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T04:32:24.950", "Id": "514043", "Score": "0", "body": "Entity is any data object with an identifier, so I think it's completely valid to call it an entity. On other hand being cached or not is just an implementation detail and thus s...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T03:27:51.140", "Id": "260403", "Score": "0", "Tags": [ "php", "repository" ], "Title": "Should my class \"data\" dependency be a repository, adapter or another pattern?" }
260403
<p>I just finished creating my first bash script that helps me to launch documents from terminal using a pdf viewer. This is very helpful and fast (at least I think so) for people who don't use any files manager (and have lots of documents of course); therefore they launch their pdf viewer and documents from terminal.<...
[]
[ { "body": "<blockquote>\n<p><code>#!/bin/env bash</code></p>\n</blockquote>\n<p><a href=\"https://stackoverflow.com/a/10383546\">Prefer</a> <code>#!/usr/bin/env bash</code></p>\n<hr />\n<p><code>CONF_DOC_DIR</code> and <code>CONF_PDF_VIEWER</code> can be removed and use <code>$CONF_DIR_PATH/config</code> with c...
{ "AcceptedAnswerId": "260483", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T12:22:26.580", "Id": "260412", "Score": "0", "Tags": [ "bash", "linux" ], "Title": "Bash script that helps in opening documents when using terminal" }
260412
<p>So this is my task:</p> <blockquote> <p>You are given an irregular shape on a bitmap. How do you determine if a point is inside or ousdie of the shape?</p> </blockquote> <p>We are allowed to assume that <code>helper functions</code> are already available for us and we don't need to write them as well.</p> <p>So I de...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T17:11:46.367", "Id": "514084", "Score": "2", "body": "I think there are more interesting problematic shapes: what if a shape has a width or height of only 1 pixel? What if two shapes touch each other? What if shapes are not closed (...
[ { "body": "<h1>If shape on bitmap is not filled and only one shape present on bitmap:</h1>\n<p>Start at point <code>(x,y)</code>. For each of the four directions (left, right, top, bottom), keep going until either <code>IsBitIsOn</code> is true or a border of the bitmap has been reached. In the former case, poi...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T12:34:57.007", "Id": "260413", "Score": "2", "Tags": [ "c", "bitset" ], "Title": "Determine if a point is inside or ouside of an irregular shape on a bitmap" }
260413
<pre><code>#include &lt;vector&gt; std::vector&lt;int&gt; Range(int from, int to, int step = 1) { std::vector&lt;int&gt; range; if (step &gt; 0) { for(int i = from; i &lt; to; i += step) { range.push_back(i); } } else if (step &lt; 0) { for(int i = from; i &gt; to; i +=...
[]
[ { "body": "<p>I think the easiest way to solve this is to first calculate how many steps it takes to go from <code>from</code> to <code>to</code>, and then just build an array of that many elements. That also has the advantage that you can reserve the right amount of elements in the vector up front. You also ha...
{ "AcceptedAnswerId": "260438", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T13:54:10.530", "Id": "260416", "Score": "5", "Tags": [ "c++", "algorithm" ], "Title": "Implementing range from_to with step" }
260416
<p>I want to use <code>TIdTCPClient</code> to connect to Redis from a web server application made with Delphi and <code>TWebModule</code>. Currently on WebModule creation I create a new <code>TIdTCPClient</code> and on web module destroy, I disconnect and free the resource. All works... But this way I create a new conn...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T14:20:53.363", "Id": "260418", "Score": "2", "Tags": [ "tcp", "delphi", "connection-pool" ], "Title": "Delphi TIdTCPClient connection pool in a multithread environment" }
260418
<p>I am thinking about the following problem:</p> <p>Consider a 3-numbers lock, i.e. a lock which has three little number wheels that opens whenever the sum of these three numbers equals 75. I know, this doesn't make sense for a lock, but just imagine this. The number wheels have numbers 3, 15, 17, 35, 40, 25, 5, 13. I...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T12:06:01.887", "Id": "514131", "Score": "3", "body": "Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question + Answer style of Code Review. This is not a forum where y...
[ { "body": "<p>you need the function</p>\n<pre><code>public static List&lt;Integer&gt; get_next_highest(List&lt;Integer&gt; combinations, List&lt;Integer&gt; numbers) {\n for(int i=0; i &lt; combinations.size(); i++) {\n if(combinations[i]&lt;numbers.size()-1) {\n combinations[i]++;\n ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T16:35:40.737", "Id": "260422", "Score": "4", "Tags": [ "java", "combinatorics" ], "Title": "Find all combinations of numbers of a set that add up to a given target - avoid for loops" ...
260422
<p>I have made a function which takes a string which can be any of <code>&quot;triangle&quot;</code>, <code>&quot;square&quot;</code> or <code>&quot;rectangle&quot;</code>.</p> <p>Depending on the string I return a pointer to an instance of class <code>Form</code>. My class <code>Form</code> has subclasses <code>Triang...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T13:38:05.150", "Id": "514142", "Score": "5", "body": "It would be better to explain here what problem you are trying to solve instead of making us follow the link to read the question and answer and then come back here." } ]
[ { "body": "<pre><code>Form *func(std::string name)\n{\n std::vector&lt;s_makeForms&gt; allForms =\n {\n {&quot;triangle&quot;, Triangle::createForm}, \n {&quot;rectangle&quot;, Rectangle::createForm},\n {&quot;square&quot;, Square::createForm}\n };\n for (const auto&amp; form : allForms)\n ...
{ "AcceptedAnswerId": "260432", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T18:43:51.053", "Id": "260428", "Score": "2", "Tags": [ "c++", "object-oriented" ], "Title": "Return correct subclass instance, identified by string" }
260428
<p>Is there any way to reduce this code? It repeats itself, but I cannot find any way to reduce it because it is only repeating inside one elif. Sorry I'm a beginner my code is quite bad It repeats here:</p> <pre><code> onze(joueurs) print(&quot;joueur&quot;, a + 1, &quot;a&quot;, joueurs[a]) ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T07:20:01.313", "Id": "514119", "Score": "1", "body": "you can always put code in function and use this function. But for two lines it can be better to keep current version." }, { "ContentLicense": "CC BY-SA 4.0", "Creati...
[ { "body": "<p>It's &quot;Pythonic&quot; to iterate through items, so assuming that <code>len(joueurs) == nb</code>, your main <code>for</code> loop can be:</p>\n<pre class=\"lang-py prettyprint-override\"><code> for a, joueur in enumerate(joueurs):\n</code></pre>\n<p>which means all your <code>joueurs[a]</co...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T19:55:12.660", "Id": "260431", "Score": "2", "Tags": [ "python", "beginner", "playing-cards" ], "Title": "Main loop for a text-based Blackjack game" }
260431
<p>Apologies for the cryptic title, but the problem really is rather simple.</p> <p>I have a 64 bit integer which I interpret as 16 4 bit nibbles, or a nibble array if you wish, and I needed generate a mask covering the nibbles which are zero, or the inverse.</p> <p>I have already come up with a solution, but it seems ...
[]
[ { "body": "<blockquote>\n<p>Intrinsics from bmi and similar are okay, but I haven't found anything that seems useful.</p>\n</blockquote>\n<p>They're not very useful for this. <code>pdep</code> and <code>pext</code> let you do this in a <em>different</em> way, but it's not better (<em>especially</em> not on AMD ...
{ "AcceptedAnswerId": "260442", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T20:39:24.997", "Id": "260434", "Score": "2", "Tags": [ "c", "bitwise" ], "Title": "Generate mask for non zero (or inverse) nibbles in integer" }
260434
<p>Standard code review, tell me what's good, what's bad, and how to improve. Critical suggestions welcomed. This is a content aggregator using bs4 and requests. I did not use any tutorials or help.</p> <pre><code>import requests from bs4 import BeautifulSoup as bs topic = input('Enter the topic: ').lower() print() de...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T21:54:33.720", "Id": "514103", "Score": "0", "body": "Why not use the API?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T22:54:45.113", "Id": "514107", "Score": "0", "body": "Which API? ...
[ { "body": "<p>Your <code>linesplit</code> is... strange? I'm going to ignore that message and pretend it makes sense.</p>\n<p>Whenever there's an API, prefer it. In this case Google has a Custom Search API that allows you to skip past all of the scraping insanity. You'll need to get an API key and configure an ...
{ "AcceptedAnswerId": "260441", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-06T21:12:47.280", "Id": "260437", "Score": "0", "Tags": [ "beginner", "python-3.x", "beautifulsoup" ], "Title": "Content aggregator using bs4 and requests" }
260437
<p>I wrote a fileupload function for my application. Basically the application is a web based folder structure, which has files included.</p> <p>I don't know, but I am not happy with it. Is it too long? Can I do some parts easier? Is the logging ok? So many questions... The FileModel is inerhiting from ParentModel.</p>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T10:05:19.760", "Id": "514128", "Score": "1", "body": "It is messy because you have put everything into a single method. I would suggest to split this function into smaller chunks where each has a dedicated responsibility and scope."...
[ { "body": "<ul>\n<li>Method has multiple mix responsibilities, it should have one responsibility and clearer scope.</li>\n<li>variable naming doesn't follow naming convention (e.g. <code>id</code> , <code>fm</code>, <code>str</code>) you should always pick a clearer names for your variables.</li>\n<li>when pars...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T08:12:23.573", "Id": "260448", "Score": "0", "Tags": [ "c#", "asp.net-mvc" ], "Title": "Use Request with Fileupload in Controller" }
260448
<p>Just want you guys to review my python 3 IRC bot code, it is actually a fork of <a href="https://github.com/Orderchaos/LinuxAcademy-IRC-Bot" rel="nofollow noreferrer">https://github.com/Orderchaos/LinuxAcademy-IRC-Bot</a></p> <p>You can see the <a href="https://github.com/PuneetGopinath/IRCbot/tree/main/bkircbot" re...
[]
[ { "body": "<p>This program - and the program it's forked from - have somewhat severe issues. You may want to be more judicious in the repositories you're using to learn.</p>\n<pre><code>ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n</code></pre>\n<p>needs to be protected with a context management...
{ "AcceptedAnswerId": "260511", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T10:38:43.270", "Id": "260449", "Score": "3", "Tags": [ "python", "python-3.x" ], "Title": "Python 3 IRCbot (library)" }
260449
<p>I originally wrote a rough C++ wrapper of the sqlite3 c library which did not use prepared statements. This code is my attempt at using prepared statements. I have attempted to make the wrapper as generic as possible so can be used in a wide range of applications.</p> <p>How easy to use do you think this C++ class...
[]
[ { "body": "<p>Just a few quick observations:</p>\n<pre><code>/* sqlite constructor */\n</code></pre>\n<p>Duh. Keep comments useful and meaningful. You don't need to explain that the ctor and dtor are those things.</p>\n<pre><code>(const std::string&amp; table_name, \n</code></pre>\n<p>Suggest you use <code>st...
{ "AcceptedAnswerId": "260456", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T11:56:09.423", "Id": "260450", "Score": "2", "Tags": [ "c++", "sqlite", "wrapper" ], "Title": "Thin C++ wrapper for sqlite3 C library" }
260450
<p><strong>Hello everyone!</strong></p> <p>In this task I had to create docstring generator. I'm just wondering how you see this problem, I have to &quot;take data&quot; from the dictionary</p> <pre><code>{'Args': None, 'Returns': None, 'Raises': None, 'Attributes': None, 'Summary': None, 'Description': None} </code></...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T12:44:45.493", "Id": "514134", "Score": "3", "body": "Welcome to the Code Review Community, I hope you get some good answers." } ]
[ { "body": "<ul>\n<li>\n<blockquote>\n<pre class=\"lang-py prettyprint-override\"><code>if (&quot;Summary&quot; in config) and (config[&quot;Summary&quot;] is not None):\n</code></pre>\n</blockquote>\n<p>Can be simplified to:</p>\n<pre class=\"lang-py prettyprint-override\"><code>if config.get(&quot;summary&quot...
{ "AcceptedAnswerId": "260460", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T12:06:05.070", "Id": "260451", "Score": "6", "Tags": [ "python", "generator" ], "Title": "Docstring generator in Google type" }
260451
<p>I'm feeling this code is messy and also repeats between all components that needs to handle backend data. Any comment is appreciated.</p> <pre><code>//the stored version localVersion = undefined; //injecting the redux service and the backend service(in case there is no version defined in reduxService) constructor( ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T14:08:11.023", "Id": "260452", "Score": "0", "Tags": [ "javascript", "typescript", "angular-2+", "redux" ], "Title": "Handling the first value for a variable, with Redux and t...
260452
<p>What do you think about this read only table design, regarding performance?</p> <p><strong>package jsql</strong></p> <p><code>Main.java</code></p> <pre><code>package jsql; public class Main { public static void main(String[] args) { Record head = new Record(&quot;given name&quot;, &quot;family name&quot...
[]
[ { "body": "<p>You should use exceptions to indicate that something fails, rather than just printing something somewhere that might very easily get ignored, while the program goes on with invalid data. Classes should have the responsibility of ensuring valid state (not additional methods or auxiliary attributes)...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T14:16:29.060", "Id": "260453", "Score": "-1", "Tags": [ "java" ], "Title": "What do you think about this read only table design, regarding performance?" }
260453
<p>I have the following code that makes a call to an external API, processes the response and returns a string. The problem is it is taking a very long time to process. I can't do anything to the API, but I was just wondering if there is a better way of doing the rest of the code.</p> <pre><code>foreach(var item in pro...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T21:35:01.833", "Id": "514163", "Score": "0", "body": "`IDisposable`: `using var response = await ...`. It would allow to reuse the opened server connections faster." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate":...
[ { "body": "<p>one way of solving this would be using <code>Task.WhenAll</code> the idea is to add all tasks into a list of tasks then we call <code>Task.WhenAll</code> and await the final results.</p>\n<p>Here is an example of it :</p>\n<pre><code>private async Task&lt;ProductItem&gt; SetSiteLink(ProductItem it...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T14:32:11.490", "Id": "260454", "Score": "1", "Tags": [ "c#", "api" ], "Title": "How can I optimise a foreach calling an API? The code calls an API and returns the first string reponse...
260454
<p>I've made a <code>splitString()</code> function which receives a character and a string and returns a <code>vector&lt;string&gt;</code> containing all the string split by a character in the input string:</p> <pre><code>vector&lt;string&gt; splitString(string input, char separator) { size_t pos; vector&lt;st...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T15:46:38.277", "Id": "514152", "Score": "0", "body": "Welcome to the Code Review Community, we can provide a better code review if you provide a unit test program that you have written the tests the function." } ]
[ { "body": "<p>If you don't want to modify the original string, you can use a <code>stringstream</code>:</p>\n<pre><code>#include &lt;vector&gt;\n#include &lt;sstream&gt;\n\nstd::vector&lt;std::string&gt; splitString(const std::string input, const char&amp; delimiter) {\n\n std::vector&lt;std::string&gt; elem...
{ "AcceptedAnswerId": "260499", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T15:28:09.417", "Id": "260457", "Score": "4", "Tags": [ "c++", "strings", "vectors" ], "Title": "Efficiently splitting a string in C++" }
260457
<p>So I have recently written a bubble sort in java and was wondering if the code is correct and if there was any way to make it even more efficient.</p> <p>Here is my code:</p> <pre><code>void bubbleSort(int array[], int num){ if(num == 1) return; for(int i = 0; i &lt; num - 1; i++){ ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T17:48:30.813", "Id": "514157", "Score": "0", "body": "What's the point of `num`? Did you translate this code from C or something?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T23:17:13.710", "Id...
[ { "body": "<p>The first question you should ask is why implement Bubble Sort in Java? Java has sorting built-in. So you could replace calls to your <code>bubbleSort(data, num)</code> with <code>Arrays.sort(data, 0, num)</code> to get a sorted array. Or if you just want to sort the whole thing, <code>Arrays.s...
{ "AcceptedAnswerId": "260475", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T17:31:45.240", "Id": "260462", "Score": "-2", "Tags": [ "java" ], "Title": "What is the most best way to write a bubble sort in java?" }
260462
<p>Im writing this simple program for school and using NumberFormat on all the variables seems very repetitive (Note that we were asked to use the <code>NumberFormat</code> method). Is there any way to clean this code so it doesn't look so cluttered?</p> <pre><code>import java.util.Scanner; import java.text.NumberForma...
[]
[ { "body": "<p>The most important approach to reduce duplicated code is to put the repetitive code into a <em>parameterized method</em>. In case you use an <em>integrated Development Environment</em> (IDE) like eclipse, IntelliJ or alike they have an <em>automated Refactoring</em> to assist you with that. (looku...
{ "AcceptedAnswerId": "260476", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T18:20:18.357", "Id": "260464", "Score": "1", "Tags": [ "java", "formatting", "homework", "calculator" ], "Title": "Car price calculator" }
260464
<p>I am working on the improvement of the bash-awk workflow designed for the analysis of data in multiple-colums format. The script uses AWK code (which extract numbers from selected columns of the input.csv as well as does some basic stat calculations) integrated into bash script (which operates with the input files l...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T14:32:17.890", "Id": "514254", "Score": "2", "body": "Just a reminder that this is Code Review, we review working code to help you improve that code. We can't help you add new features such as 2 new columns to the output." }, { ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T18:59:20.230", "Id": "260466", "Score": "2", "Tags": [ "bash", "awk" ], "Title": "bash / awk workflow operating on multi-column files" }
260466
<p>After quite some time away from Haskell I am trying to brush up. To do so I am writing some basic linear regression functionality.</p> <p>The code produces the output expected. In essence I am trying to duplicate the functionality of R's lm() function using matrix algebra in Haskell. I appreciate that there is much ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T03:48:12.083", "Id": "514170", "Score": "1", "body": "It all looks pretty good to me! If you were pretending this were a library you could write Haddock-styled comments. I'd also switch to using `Data.Array` for the underlying data ...
[ { "body": "<p>Looks good, matrix operations have been kind of a sore spot for Haskell, but this is example is easy to follow along.\nI would definitely do is get rid of all the calls to <code>error</code>. Instead, you can wrap a lot of things with <code>Either SomeFailure &lt;Success&gt;</code>, where SomeFail...
{ "AcceptedAnswerId": "260687", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T20:27:39.103", "Id": "260469", "Score": "6", "Tags": [ "haskell", "statistics" ], "Title": "Linear Regression in Haskell" }
260469
<p>I've been playing with TypeORM and I wanted to create proper tests for my EventSubscriber. I also wanted those test to be independent from database connection. I believe I managed to achieve my goal. Here is my code:</p> <p>UserSubscriber.ts:</p> <pre class="lang-js prettyprint-override"><code>@EventSubscriber() exp...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T20:53:48.163", "Id": "260471", "Score": "0", "Tags": [ "javascript", "unit-testing", "typescript" ], "Title": "TypeORM EventSubscriber unit testing" }
260471
<p>The rationale behind this code is to implement a runtime-safe number conversions in situations when precision loss is possible, but is not expected. Example: passing a <code>size_t</code> value from a 64-bit code to a library (filesystem, database, etc.) which uses 32-bit type for size, assuming you will never pass ...
[]
[ { "body": "<p><strong>Use non-member functions where possible</strong>:</p>\n<p>The cast functions are all static, and there is no member data in <code>SafeNumericCast</code> and <code>SafeRuntimeNumericCast</code>, so these the classes don't need to exist.</p>\n<p>We could use namespaces, or plain non-member f...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-07T21:47:47.103", "Id": "260472", "Score": "2", "Tags": [ "c++", "c++17", "integer", "floating-point", "casting" ], "Title": "Safe runtime numeric casts" }
260472
<p>My C++20 N-dimensional matrix project now supports basic linear algebra operations: <a href="https://github.com/frozenca/Ndim-Matrix" rel="nofollow noreferrer">https://github.com/frozenca/Ndim-Matrix</a></p> <p>Today I want to get some reviews on computing eigenvalues and eigenvectors. In particular, I don't like so...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T02:28:09.390", "Id": "514168", "Score": "0", "body": "Can you edit your question to include the headers necessary for this to compile?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T02:45:20.657", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T00:55:19.683", "Id": "260478", "Score": "1", "Tags": [ "c++", "matrix", "c++20" ], "Title": "C++20 Ndim matrix, computing eigenvalues and eigenvectors" }
260478
<h2>Description</h2> <p>This is a simple (and hopefully) RESTful API in Golang that uses Redis. I have next to no prior experience in Golang and absolutely no prior experience with Redis. The API is a simple counter service with the feature of disabling &quot;public&quot; updates (cannot create new counter, and cannot ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T03:41:30.627", "Id": "260480", "Score": "4", "Tags": [ "beginner", "go", "http", "rest", "server" ], "Title": "Simple RESTful counting API in Golang" }
260480
<p>I have created the following function which filters a linked list in place (here it removes all instances of the element k), but it could easily be modified to take a function pointer as an argument and filter on something else.</p> <p>Any ideas on how to improve the code?</p> <pre><code>typedef struct list_integer ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T06:31:35.807", "Id": "514174", "Score": "1", "body": "Is the indentation in your question the same as in your original code?" } ]
[ { "body": "<h1>Table of contents (in no particular order)</h1>\n<p>Indent your code properly!</p>\n<p>Don't use goto for something so routine. Unless you're writing a c compiler and intend to compete with gcc or clang or you're Andrei Alexandrescu... don't use goto at all!</p>\n<p>while loop/for loop can be use...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T04:16:35.943", "Id": "260481", "Score": "1", "Tags": [ "c", "linked-list" ], "Title": "Filter a Linked List in Place in C" }
260481
<p>I recently decided to learn how to multithread Java programs, so I made a small program to compare the performance of serial and multithreaded programs that perform the same task.</p> <p>I created a serial program that calculates the number of primes from 1 to 10 million, and timed it 50 times using a test program. ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T06:10:01.540", "Id": "514229", "Score": "6", "body": "Every time I see a prime-counting function program I feel obligated to tell you there are much faster algorithms that run in sub-linear time using https://en.wikipedia.org/wiki/M...
[ { "body": "<blockquote>\n<pre class=\"lang-java prettyprint-override\"><code>threadEnd = (threadEnd + chunk &gt; max) ? max : threadEnd + chunk;\n</code></pre>\n</blockquote>\n<p>Your <code>primeCalculator</code>'s <em>equally sized</em> chunks run in <em>unequal time</em>. The calls to <code>primeCalculator</c...
{ "AcceptedAnswerId": "260486", "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T07:41:22.023", "Id": "260485", "Score": "9", "Tags": [ "java", "multithreading" ], "Title": "Finding number of primes less than 10 million using a multithreaded program" }
260485
<p>I have this function called error, which estimates value based on previous value and rewards in trials. The difference between the estimated value and true value is then calculated, giving the error. I need to run this code 1000 times with different lists of trials, but currently it runs too slowly. How would I opti...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T10:26:19.727", "Id": "514184", "Score": "1", "body": "The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state...
[ { "body": "<ol>\n<li><p>Using list comprehensions instead of numerous <code>.append</code> calls is\noften times faster and more readable.</p>\n</li>\n<li><p>A list of rewards should be called <code>rewards</code> instead of <code>reward</code>. Same goes for <code>values</code> and <code>true_values</code>.</p...
{ "AcceptedAnswerId": "260490", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T10:11:36.320", "Id": "260488", "Score": "3", "Tags": [ "python", "performance", "functional-programming" ], "Title": "Finding the difference between the estimated value and th...
260488
<p>We have a large set of projects at work. It's very important we keep track of those and every so often we need to run a full back-up that's unrelated to the 'normal' back-ups IT is running (snapshots every day, week, month, etc.). Recently we had a big migration on all of the older projects. To make sure nothing is ...
[]
[ { "body": "<p>You can use f-strings instead of <code>.format()</code>. It makes the code more readable, and is also faster (see <a href=\"https://stackoverflow.com/questions/43123408/f-strings-vs-str-format\">here</a>, and even on my system, f-strings are about 4.4 times faster than <code>.format()</code> on my...
{ "AcceptedAnswerId": "262955", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T11:09:41.910", "Id": "260491", "Score": "7", "Tags": [ "python", "python-3.x", "network-file-transfer" ], "Title": "Multi-site backup utility with basic sanity checks" }
260491
<p>I have tried to embody some basic ATM operations in a Object Oriented manner for practice. Would love some review pointers from structure, Object Oriented principles point of view. Also what should be my next steps in order to get good at OO design(I would like to read more code not books/videos, have pushed my mind...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T13:40:07.373", "Id": "514191", "Score": "0", "body": "Your User setter methods should not be doing any error checking. Error checking is done when the information is input and can be corrected. A real financial system would have a...
[ { "body": "<h2>Only submit compilable code to review</h2>\n<p>There is an type-issue in your ATMTest.\nThe <code>printMiniStatement</code>-Method in <code>Iterator&lt;String&gt; itr = savings.printMiniStatement();</code>\nhas return type void, but the variable is expecting an Iterator.\nHence, the code can't be...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T12:36:29.140", "Id": "260493", "Score": "0", "Tags": [ "java", "object-oriented" ], "Title": "OOP ATM Implementation" }
260493
<p>Inspired by <a href="https://codereview.stackexchange.com/questions/260413/determine-if-a-point-is-inside-or-ouside-of-an-irregular-shape-on-a-bitmap">this question</a>, here's some C code to check if a point is &quot;inside&quot; of a shape on a simple black and white bitmap.</p> <p>For this exercise:</p> <ul> <li>...
[]
[ { "body": "<p>This looks like a very reasonable attempt at solving the problem. You are using a flood fill instead of counting the number of shape edges crossed, and that avoids a whole lot of issues, although it therefore won't be very fast.</p>\n<h1>Unnecessary conversion from string to bitmap?</h1>\n<p>Conve...
{ "AcceptedAnswerId": "260509", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T12:59:48.867", "Id": "260494", "Score": "3", "Tags": [ "c", "depth-first-search" ], "Title": "Check if point is inside a bitmap shape" }
260494
<p>I would be grateful for a code review of my first &quot;real&quot; C# project (<a href="https://github.com/michaeljsiena/RockPaperScissors" rel="nofollow noreferrer">https://github.com/michaeljsiena/RockPaperScissors</a>). It's a basic rock, paper, scissors console game. It's probably quite over-engineered for what ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T12:42:17.713", "Id": "514249", "Score": "1", "body": "I don't have expertise for a proper review but I am almost certain you should be using an interface for the `Player` subclasses rather than holding references to them using the b...
[ { "body": "<p>Overall a very good first attempt at a &quot;real&quot; project.</p>\n<ul>\n<li><p><strong>Drop &quot;Manager&quot; class name suffix</strong> — Consider renaming GameManager to simply Game. Similarly rename ScoreManager to something like GameScore. I see the &quot;Manager&quot; suffix frequently ...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T17:10:11.547", "Id": "260502", "Score": "6", "Tags": [ "c#", "rock-paper-scissors" ], "Title": "Rock, Paper, Scissors - Applying OOP Principles" }
260502
<p>I have a <code>dataframe</code> with a column composed by <code>date</code> object and a column composed by <code>time</code> object. I have to merge the two columns.</p> <p>Personally, I think it is so ugly the following solution. Why I have to cast to <code>str</code>? I crafted my solution based <a href="https://...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T03:32:39.717", "Id": "514442", "Score": "1", "body": "i agree it would be nice if they overloaded `+` for `date` and `time`, but your current `str`/`to_datetime()` code is the fastest way to do it (even if it looks uglier)" }, {...
[ { "body": "<p>We can let pandas handle this for us and use <code>DataFrame.apply</code> and <code>datetime.datetime.combine</code> like this:</p>\n<pre><code>df[&quot;TimeMerge&quot;] = df.apply(lambda row: datetime.datetime.combine(row.date1, row.time1), axis=1)\n</code></pre>\n<hr />\n<p>Although the followin...
{ "AcceptedAnswerId": "260504", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T17:19:09.717", "Id": "260503", "Score": "1", "Tags": [ "python", "datetime", "pandas" ], "Title": "Pandas merge a \"%Y%M%D\" date column with a \"%H:%M:%S\" time column" }
260503
<p>I previously posted a question for codereview:</p> <p><a href="https://codereview.stackexchange.com/questions/259824/python-autoclicker">Python Autoclicker</a></p> <p>And I received some great feedback and changes to do in the code.</p> <p>I have done many of the changes mentioned in the answers and here is the fina...
[]
[ { "body": "<p>Your code is generally fine. I suspect you are not doing enough validation (for\nexample, to forbid negative values or multi-character keys). Also, if you want\nto expand your toolkit, you can think about eliminating the duplication in your\ncode by generalizing the input collection process.</p>\n...
{ "AcceptedAnswerId": "260514", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T18:32:36.063", "Id": "260505", "Score": "4", "Tags": [ "python", "python-3.x", "automation" ], "Title": "\"Python AutoClicker\" Part 2" }
260505
<p>I recently needed to detect agents within a certain-field of view and came across <a href="https://gamedev.stackexchange.com/questions/118675/need-help-with-a-field-of-view-like-collision-detector">this</a> question in gamedev stack exchange. To learn how it works, I followed the first answer's guidance and decided ...
[]
[ { "body": "<h1>Avoid using macros</h1>\n<p>Try to avoid macros where possible; usually a better solution is available. For constants, prefer using <code>constexpr</code>:</p>\n<pre><code>static constexpr float PI = 3.14159...f;\n</code></pre>\n<p>Instead of <code>MIN</code> and <code>MAX</code>, just use <a hre...
{ "AcceptedAnswerId": "260526", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T20:09:15.557", "Id": "260510", "Score": "1", "Tags": [ "c++" ], "Title": "Structuring the program that demonstrates collision detection within a field of view" }
260510
<p>I'm working on an implementation of <strong>Monte Carlo Tree Search</strong> in <strong>Swift</strong>.</p> <p>It's not bad, but it could be better! I'm principally interested in making my algorithm:</p> <ol> <li>faster (more iterations/second)</li> <li>prioritize moves that prevent instant losses (you'll see...)</l...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T09:14:45.813", "Id": "514392", "Score": "0", "body": "Performance tests must be done in a compiled project, not in a Playground." } ]
[ { "body": "<p>I've been mulling this over and have some preliminary answers! (But would still appreciate some help!!)</p>\n<hr />\n<p><a href=\"https://hal.inria.fr/file/index/docid/495078/filename/cig2010.pdf\" rel=\"nofollow noreferrer\">F. Teytaud and O. Teytaud (2010)</a> inspired a solution to the &quot;lo...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-08T20:19:59.000", "Id": "260512", "Score": "2", "Tags": [ "performance", "tree", "swift" ], "Title": "Monte Carlo Tree Search Optimization and Loss Prevention" }
260512
<p>I've been learning React for about a month now. I wrote a small <a href="https://calc-solver.com/twin-paradox-under-special-relativity-calculator" rel="nofollow noreferrer">interactive calculator</a> to show the effects of time dilation under special relativity. It's Node/React/Razzle(for SSR)/Typescript/Javascript....
[]
[ { "body": "<p>Let me say first that I haven't actually tried the code or proposed changes, mostly because I don't have the imported files <code>ThreeColumnContainer</code> and <code>TextControl</code>.</p>\n<p>I begin with what I think is the main challenge.</p>\n<hr />\n<p>There are some interdependent values,...
{ "AcceptedAnswerId": "260681", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T00:10:22.240", "Id": "260517", "Score": "0", "Tags": [ "javascript", "node.js", "react.js", "typescript", "jsx" ], "Title": "This code renders a time dilation calculat...
260517
<p>I am trying to learn how to correctly implement an iterator (and its corresponding const variant) using a single template, so I would appreciate any criticism to the following code. It's an forward iterator for a cv::Mat wrapper (a class from OpenCV that stores an image).</p> <p>Edit: Its behavior must be equivalent...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T14:03:57.760", "Id": "514325", "Score": "1", "body": "Try using [Boost.Iterator](https://www.boost.org/doc/libs/1_76_0/libs/iterator/doc/index.html), specifically the `iterator_facade` template." } ]
[ { "body": "<pre><code>template &lt;bool isConst&gt;\nclass ImageIterator\n{\npublic:\n ImageIterator(cv::Mat data, size_t initial_index) : data(data), index(initial_index) {}\n ...\nprivate:\n cv::Mat data;\n size_t index;\n ...\n};\n</code></pre>\n<p>It looks like <code>cv::Mat</code> is a refer...
{ "AcceptedAnswerId": "260551", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T08:03:56.150", "Id": "260519", "Score": "3", "Tags": [ "c++", "beginner", "c++17", "iterator", "opencv" ], "Title": "Image (Const) Iterator using C++17" }
260519
<p>I am writng a JUnit test case for the below methods :</p> <pre><code>public final class LoggerService implements ILoggerService { private Logger logger; private &lt;T&gt; LoggerService(T type){ logger = LoggerFactory.getLogger((Class&lt;?&gt;) type); } public static &lt;T&gt; LoggerService getLogger...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T08:22:09.643", "Id": "514237", "Score": "3", "body": "You could create one timestamp before the call to tested method, and another after the call. Then check that the tested method returned value between those two (inclusive)." },...
[ { "body": "<p>The problem here is the call to the <code>new</code> operator inside your <em>code under test</em> (cut). So the way to go is to <em>inject</em> this <em>dependency</em> into your cut. Of cause the (failed) implementation of the <em>Java Singelton Pattern</em> is a <a href=\"https://williamdurand....
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T08:14:35.200", "Id": "260520", "Score": "0", "Tags": [ "java", "unit-testing", "junit" ], "Title": "Need Feedback on JUnit test comparing two timestamps" }
260520
<p>I've built a login panel, which will submit an email and password via fetch/POST. And I wanted to know the best way to handle network status errors?</p> <p>Reason being, as I want to inject error messages into my login panel for each state/status code.</p> <p>I've written the code below, which works. But I wondered ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T11:47:28.637", "Id": "514246", "Score": "0", "body": "Welcome to the Code Review Community. The title of the question should be an introduction into what the code does, not your concerns about the code. Please read [How do I ask a g...
[ { "body": "<p>I personally think that You can easily handle part of the error handling logic in the <code>catch</code> block however at the moment You are listening for the specific response status do specify what went wrong during the API connection process.</p>\n<p>MDN says:</p>\n<blockquote>\n<p>You can use ...
{ "AcceptedAnswerId": "260532", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T10:19:07.797", "Id": "260524", "Score": "1", "Tags": [ "javascript", "api", "ajax" ], "Title": "Posting data via fetch and handling network errors" }
260524
<p>A few days ago I posted a previous version of my first bash script here to get few tips and reviews so I could improve it. So now it is improved a bit. I also shellchecked it and fixed the warnings. I would love to hear more tips from you guys.</p> <p>Here is the code:</p> <pre><code>#!/usr/bin/env bash declare -r ...
[]
[ { "body": "<h1>Good</h1>\n<ul>\n<li>nice indentation</li>\n<li>good docs for the options</li>\n<li>good variable names</li>\n<li>a reasonable amount of inline comments</li>\n<li>yay for being on top of the shellcheck already</li>\n</ul>\n<h1>Suggestions</h1>\n<ul>\n<li>For conditionals it is safer to use double...
{ "AcceptedAnswerId": "260547", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T10:21:56.560", "Id": "260525", "Score": "1", "Tags": [ "bash", "linux" ], "Title": "Rdoc - a command-line tool for launching documents (improved)" }
260525
<p>I recently put up my C++ class to wrap the sqlite3 c library here:</p> <p><a href="https://codereview.stackexchange.com/questions/260450/thin-c-wrapper-for-sqlite3-c-library">Thin C++ wrapper for sqlite3 C library</a></p> <p>One of the suggestions was rather than to specify a vector for arguments to functions instea...
[]
[ { "body": "<p>Just a quick note: the begin and end iterator might be different types, as a recent improvement in STL provides for <code>end</code> to be a special &quot;sentinel&quot; type that's different from the normal iterator.</p>\n<p>If you're using C++20, you can use Concepts to declare the template arg...
{ "AcceptedAnswerId": "260561", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T10:56:54.273", "Id": "260527", "Score": "2", "Tags": [ "c++", "iterator", "sqlite" ], "Title": "Adding iterators to C++ sqlite wrapper class" }
260527
<p>I read some answers here on stack exchange, but none really &quot;hits the nail on the head&quot; about where to throw exceptions, where I shouldn't and where to catch them.</p> <p>the idea that an exception should be thrown in exceptional cases is very vague, for example, if I can't find a user in my data source (r...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-06-08T15:04:13.247", "Id": "518776", "Score": "2", "body": "We don't do general \"best-practice\" questions or example code on Code Review. Please see [Why is hypothetical example code off-topic for CR?](//codereview.meta.stackexchange.c...
[ { "body": "<blockquote>\n<p>the idea that an exception should be thrown in exceptional cases is very vague, for example, if I can't find a user in my data source (repository) I can't continue the flow of my code, can this be considered exceptional?</p>\n</blockquote>\n<p>My personal approach is to raise an exce...
{ "AcceptedAnswerId": null, "CommentCount": "17", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T13:45:37.830", "Id": "260529", "Score": "4", "Tags": [ "php", "object-oriented", "error-handling", "repository" ], "Title": "Should i throw exceptions in the service layer or...
260529
<p>I wanted to write a program in python which it scans the RAM of a computer, by displaying the services and the executables.</p> <pre><code>import psutil import wmi from time import sleep from progress.bar import Bar # Connecting c = wmi.WMI() # stock here Process Id proc = [] # function to get the Size def get_siz...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T15:00:29.547", "Id": "260530", "Score": "1", "Tags": [ "python" ], "Title": "scan the RAM of a computer, displaying the services and executables" }
260530
<p>I want to have dynamic continuous block of memory for different types, that inherit from single base class. I've written structure for that purpose. I know I play with a fire here, but I would like to know how dangerous it is to use this structure. Each element stored in DynamicPool must inherit from Base to support...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T14:09:24.197", "Id": "514326", "Score": "0", "body": "Just a quick comment: use `std::byte` instead of `uint8_t`." } ]
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T18:18:36.703", "Id": "260536", "Score": "2", "Tags": [ "c++", "memory-management", "memory-optimization" ], "Title": "Dynamic heterogeneous container" }
260536
<p>I was working on an Limit Order Book structure in JS and came up with this algorithm. I am pretty sure this must have already been implemented but couldn't even find a clue over the web.</p> <p>The thing is, it's very fast especially when you have an array of many duplicate items. However the real beauty is, after i...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T14:19:14.447", "Id": "514328", "Score": "2", "body": "The radix sort in https://jsben.ch/s6Ld2 is very poorly written. This https://jsben.ch/96YZc bench has a better (not best) example of a radix sort" }, { "ContentLicense"...
[ { "body": "<p>I think you re-invented <a href=\"https://www.geeksforgeeks.org/counting-sort/\" rel=\"noreferrer\">counting sort</a>, but with some small differences. Also you probably need to sort your sparse array keys before iterating over them so that's O(k log k) at least unless your possible range of value...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T18:40:28.113", "Id": "260538", "Score": "3", "Tags": [ "javascript", "sorting", "radix-sort" ], "Title": "Sorting an array of positive integers including 0 much faster than Radix ...
260538
<p>Hello I don't have any specific problem but I'm just interested how someone who is experienced in JavaScript would write this small toy program. it's a simple Todo List app, there are many approaches to writing something like this but I'm not sure if the way I wrote it is the most optimal. I want to see how others w...
[]
[ { "body": "<p>If you had not written this code but were trying to use it, how would you know that the square on either side was a button or what the function of that button was? Buttons need labels and they are generally oval shaped.</p>\n<p>When you design or write code for the web you need to consider the use...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T20:47:14.263", "Id": "260541", "Score": "2", "Tags": [ "javascript", "beginner", "to-do-list" ], "Title": "What is the optimal way to write this small Todo List app" }
260541
<p>I have an IoT device with accelerating and gyroscope sensors. before my device can be used it needs to be calibrated.</p> <p>Basically, it means that I do measures for XYZ axes and for the gyro movements and save the findings in JSON file.</p> <p>With this script, I want to assure the calibration process has occurre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T20:14:27.340", "Id": "514364", "Score": "0", "body": "This is not complete - you're missing at least one import" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T21:56:27.523", "Id": "514368", "...
[ { "body": "<p>You're using logging - great! You should encapsulate your logging setup so that you don't pollute the global namespace, something like</p>\n<pre><code>def make_logger():\n logger = logging.getLogger(__name__)\n logger.setLevel(logging.INFO)\n formatter = logging.Formatter('%(levelname)s -...
{ "AcceptedAnswerId": "260580", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T21:55:47.640", "Id": "260542", "Score": "3", "Tags": [ "python" ], "Title": "Verifying calibration process on IoT device, python script" }
260542
<p>There are things that I am not 100% sure. Is it possible that dangling references can be create in <em>add_task</em> method? Is it possible that this implementation will deadlock? I had to use <em>shared_ptr</em> in order to store <em>packaged_task</em> in the queue. Is there a better way to do it?</p> <pre><code>cl...
[]
[ { "body": "<pre><code>~ThreadPool() = default;\n</code></pre>\n<p>We need to call <code>stop()</code> in the destructor!</p>\n<hr />\n<pre><code>template&lt;typename Func, typename... Args&gt;\ndecltype(auto) add_task(Func&amp;&amp; func, Args... args) {\n using ReturnType = decltype(func(args...));\n</code>...
{ "AcceptedAnswerId": "260550", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T22:35:09.730", "Id": "260544", "Score": "2", "Tags": [ "c++", "c++17" ], "Title": "Is this thread pool implementation OK?" }
260544
<p>I have a Direct3D 11 application and recently I've started to implement a new feature on it, the UI(User Interface).</p> <p>It seems to work well, but I'm having one problem with optimization when it comes to moving stuff on my window, currently I can create a 2D square with textures and a 300x300 resolution.I can d...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T13:07:06.373", "Id": "514319", "Score": "3", "body": "This question is more suited towards the [Computer Graphics](https://computergraphics.stackexchange.com/) or [Gamedev](https://gamedev.stackexchange.com) stackexchanges. Anyway, ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T00:26:27.353", "Id": "260546", "Score": "0", "Tags": [ "c++", "graphics" ], "Title": "How can I make my resource mapping faster?" }
260546
<p>I'm new to Go and I completed the first challenge from Gophercises. Any feedback would be highly appreciated.</p> <p>There are some things that I am unsure of if they are made in an optimal way.</p> <p><a href="https://github.com/anthonygedeon/gophercises/tree/main/quiz-master" rel="nofollow noreferrer">Github repo<...
[]
[ { "body": "<p>from what I saw there are a few changes that could be done to the program</p>\n<ol>\n<li><p>while parsing command-line arguments I think it's better to put them inside a function cause it makes the code look clean and simple and as it is returned as a pointer you would have to keep getting the val...
{ "AcceptedAnswerId": "260708", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T03:02:36.050", "Id": "260548", "Score": "1", "Tags": [ "programming-challenge", "go" ], "Title": "Improving my solution to the Quiz project from Gophercises in Golang" }
260548
<p>I am trying to optimise my remove-erase functions by using some attributes of C++ containers. This function should delete all indices defined in std::set form given vector. I am pretty sure that algorithm is functionality-wise working, but every time I see STL implementation or any code using STL I see a lot of chec...
[]
[ { "body": "<p>There are a few things I would improve:</p>\n<ul>\n<li>Clearly separate the three distinct phases:\n<ol>\n<li>Skip until the first index in the set</li>\n<li>Copy/delete until we reached the last index</li>\n<li>Copy the remainder until the end of the container is reached.</li>\n</ol>\n</li>\n<li>...
{ "AcceptedAnswerId": "260558", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T11:11:13.147", "Id": "260553", "Score": "3", "Tags": [ "c++", "stl" ], "Title": "Remove indicies from vector" }
260553
<p>For the real time control software I need square root calculation. I have heard that the sqrt function from the standard library isn't good choice due to the unpredictable number of iterations used during calculation. Based on that information I have decided to implement the sqrt function in my own based on the Newt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T21:36:14.017", "Id": "514429", "Score": "2", "body": "For what values of `a` do you expect to get? Negatives? Small positives? Integers? What is min and max value? What is the error threshold?" }, { "ContentLicense": "CC BY-...
[ { "body": "<blockquote>\n<p>I have heard that the sqrt function from the standard library isn't good choice due to the unpredictable number of iterations used during calculation.</p>\n</blockquote>\n<p>The goal of standard functions do not generally include a uniform time requirement.</p>\n<p>Far more often, a ...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T13:43:41.773", "Id": "260559", "Score": "2", "Tags": [ "algorithm", "c", "mathematics", "signal-processing" ], "Title": "Implementation of the square root for real time applic...
260559
<p>I am learning C from <em>C Primer Plus</em>, and am still a beginner. I have been introduced to only two functions for input, <code>scanf()</code> and <code>getchar()</code>.</p> <p>According to me, when <code>stdin</code> is associated with input from a keyboard, there are 4 possibilities for user input in this pro...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T22:08:03.880", "Id": "514370", "Score": "2", "body": "I believe your `(a == 1)` check is redundant, since it is in the 2nd part of an `||` expression. (This comment is redundant, given @Reinderein's reply below, but I include it for...
[ { "body": "<h1>General Observations</h1>\n<ul>\n<li>The code is quite readable.</li>\n<li>Using void in the function declarations is good.</li>\n<li>Using stdlib.h for <code>EXIT_FAILURE</code> is good, but the <code>return</code> from <code>main()</code> should be <code>return EXIT_SUCCESS;</code></li>\n</ul>\...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T14:19:28.223", "Id": "260562", "Score": "7", "Tags": [ "c", "validation", "io" ], "Title": "Input validation" }
260562
<p>This is intended as a simple layout for an auto showroom site:</p> <p><strong>Disclaimer</strong> <em>Details changed from original for privacy</em></p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css ...
[]
[ { "body": "<p>I think u can use ul tag after <code>&lt;h3&gt;20 minutes from Dublin town centre&lt;/h3&gt;</code> and then use li tag instead of article tag, becuase you have the list of cars in this page, and for list we should use ul and li tag which html is provide for us. <a href=\"https://developer.mozill...
{ "AcceptedAnswerId": "260605", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T16:17:16.320", "Id": "260574", "Score": "2", "Tags": [ "html", "css" ], "Title": "Code for car sales platform designed with flexbox in HTML5" }
260574
<p>I am attempting to build an Android APP with the ability to connect specified FTP server in Java. The connection operation has been performed in <code>FTPconnection</code> class and the network call of FTP has been separated from main thread via <code>java.util.concurrent.Executors</code>.</p> <p><strong>The experim...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T17:13:52.360", "Id": "260576", "Score": "3", "Tags": [ "java", "multithreading", "android", "networking", "ftp" ], "Title": "Android APP connect to FTP server in Java" }
260576
<p>I want to use only one for Loop for this code. Is this possible? If not then how can I optimise my code further?</p> <p>It works well for the constraint 1 ≤ T ≤ 10, 2 ≤ N ≤ 10^3, 1 ≤ M ≤ 10^5, but I am getting time limit exceeded for 1 ≤ T ≤ 100, 2 ≤ N ≤ 10^5, 1 ≤ M ≤ 10^5.</p> <pre><code>#include &lt;iostream&gt; u...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T17:45:20.670", "Id": "514349", "Score": "6", "body": "Welcome to Code Review! The current question title, which states your concerns about the code, is too general to be useful here. Please [edit] to the site standard, which is for ...
[ { "body": "<p>I'm sure the puzzle intends you to use more math and less brute force. But here's a 2x speedup right away: Any loop of the form</p>\n<pre><code>for (int a=1; a &lt;= n; ++a) {\n for (int b = 1; b &lt;= n; ++b) {\n if (a &lt; b) {\n do something\n }\n }\n}\n</code></...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T17:30:08.760", "Id": "260577", "Score": "-3", "Tags": [ "c++", "performance", "time-limit-exceeded" ], "Title": "Is there any way to use a single for Loop for this code?" }
260577
<p>I've added some methods to a basic BST implementation for integers - if anyone can point out some ways that this could be written in a more efficient or clean manner, please let me know.</p> <pre><code>public class BST { /* * 1) Node inner class */ private class Node { i...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T12:13:28.700", "Id": "514403", "Score": "0", "body": "You're looking to optimize, is the code too slow right now? Have you done any profiling? It's a very common fallacy for new coders to want to optimize the ever living daylight ou...
[ { "body": "<p>I am not a Java devloper, so take review with a grain of salt.</p>\n<hr />\n<p>There are a lot of unncessary comments:</p>\n<blockquote>\n<p><code>3) Methods: size</code></p>\n<p><code>4) Methods: isEmpty</code></p>\n</blockquote>\n<p>We can already see that it is a method and what it's name is by...
{ "AcceptedAnswerId": "260587", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T19:44:30.030", "Id": "260579", "Score": "1", "Tags": [ "java", "performance", "object-oriented", "binary-search", "binary-tree" ], "Title": "How can I optimize this Bi...
260579
<p>I was given a spreadsheet of data that I turned into a CSV file and then converted it into a JSON file.</p> <p>I threw it into my application and I am processing it in the following manner:</p> <pre><code>const fs = require(&quot;fs&quot;); class DataRepository { constructor(filename) { if (!filename) { ...
[]
[ { "body": "<p>Some issues:</p>\n<ol>\n<li><p>The constructor recognizes an error if the file doesn't exist but, after logging, just behaves as if nothing is wrong. It does not communicate back an error. Probably, you should just let the exception go back to the caller or don't test it at all in the constructo...
{ "AcceptedAnswerId": "260586", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T20:49:42.487", "Id": "260582", "Score": "1", "Tags": [ "javascript", "node.js" ], "Title": "Is this file a good starting point for accessing data inside this json file via javascr...
260582
<p>I'm starting out with Rust and decided to implement a game of Hangman. Can you please provide general feedback on the code?</p> <p>I've already identified some lines (see comments <code>[A]</code>, <code>[B]</code>, <code>[C]</code>) where I cannot find a better way; feedback regarding these would be much appreciate...
[]
[ { "body": "<p>The biggest improvement that you can make is to not store your state in a String. You'll find things much easier if you store your state in appropriate data structures.</p>\n<p>It'll also be easier to understand you code if you organize the current state of the game into a struct rather then acros...
{ "AcceptedAnswerId": "261016", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T20:53:28.700", "Id": "260583", "Score": "1", "Tags": [ "beginner", "rust", "hangman" ], "Title": "Simple Hangman implementation in Rust" }
260583
<p>I have made an AVL tree in C and coded the basic functionality of insertion, deletion, and search. I would love some criticism on my implementation especially on the insertion and deletion section of the code. Furthermore I think I could have used one less variable in the Node structure as you do not need a height f...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T00:17:16.110", "Id": "514375", "Score": "1", "body": "I would look at a way to rename the functions a little bit - all your main functions are calling a corresponding `helper` function, which feels too generic and vague. Helping wit...
[ { "body": "<p><strong>Height</strong></p>\n<p>The usually AVL tree needs to only record the height difference or <a href=\"https://en.wikipedia.org/wiki/AVL_tree#Balance_factor\" rel=\"nofollow noreferrer\">balance factor</a>: [-1, 0, 1]. Instead of 2 <code>int32_t</code>. A <code>signed char</code> will do. ...
{ "AcceptedAnswerId": "260878", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T21:01:58.373", "Id": "260584", "Score": "3", "Tags": [ "c", "tree", "binary-tree", "binary-search-tree" ], "Title": "AVL Tree in C Criticism" }
260584
<p>This is my implementation of an AStar-like algorithm for maze solving.</p> <p>A quick summary of the problem I am trying to solve with my algorithm might be:</p> <blockquote> <p>A simple binary maze is given to you to solve, you may only go in the standard cardinal directions: north, east, west and south. There is a...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-10T22:01:33.707", "Id": "260585", "Score": "2", "Tags": [ "python", "performance", "pathfinding" ], "Title": "AStar Implementation and Efficiency" }
260585
<p>This is a fully functional PowerShell script I wrote not long ago that converts data (numerical data) among 4 data formats: binary, decimal, hexadecimal and ipv4.</p> <p>It supports 12 conversions, it can convert number from each type to the other three type, it can convert:</p> <pre class="lang-powershell prettypr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T06:11:57.637", "Id": "514387", "Score": "2", "body": "you state that you want to avoid all the optimized methods available in PoSh and in dotnet ... and then ask for optimization help. that does not make sense to me. [*grin*]" }, ...
[ { "body": "<p>I don't have enough score to comment, so i'll write an answer instead:</p>\n<p>Its a interesting idea. I'm suprised there isn't any command that does this already?</p>\n<ol>\n<li>Function should always be <code>verb-job</code>. To get a list of approved verbs, do <code>get-verb</code> in the conso...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T02:54:15.340", "Id": "260592", "Score": "3", "Tags": [ "performance", "beginner", "programming-challenge", "converting", "powershell" ], "Title": "PowerShell script binary...
260592
<p>Here's the Rabin-Karp implementation that I've written in Python:</p> <pre class="lang-py prettyprint-override"><code>from functools import lru_cache from itertools import islice from typing import List, Optional BASE = 139 MOD = 2 ** 31 - 1 @lru_cache(maxsize=None) def char_to_int(c: str) -&gt; int: return ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T10:39:11.477", "Id": "514395", "Score": "1", "body": "pow() is quite slow operation ... dunno if you can find good enough pow() approximation for the job..." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-0...
[ { "body": "<p>Disclaimer: I did not get any noticeable performance improvements but here are a few ideas nonetheless. Also, your code looks really good to me and there is not much to improve.</p>\n<p>In <code>calculate_hash</code>, you compute a power in the body of the loop. Based on the way the exponents is c...
{ "AcceptedAnswerId": "260609", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T05:05:17.903", "Id": "260595", "Score": "1", "Tags": [ "performance", "python-3.x" ], "Title": "Python Rabin-Karp Code Optimization" }
260595
<p>I want to improve performance for api. I design cache in dao layer. I use caffine cache. Basic code is:</p> <p>CacheConfig.java</p> <pre><code>@Configuration public class CacheConfig { @Autowired private AppDao appDao; @Bean(value = &quot;appCache&quot;) public LoadingCache&lt;String, App&gt; appCa...
[]
[ { "body": "<p>Well if you want to distinct classes, you should create two classes:</p>\n<pre><code>class CahedDao {\n AppCache cache;\n getByKey(String)\n} \n\nclass DbDao {\n getByKeyFromDb(String)\n}\n</code></pre>\n<p>Notes:</p>\n<p><strong>A.</strong> Codereview is to review working code, if you want to ...
{ "AcceptedAnswerId": "260599", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T07:00:11.920", "Id": "260596", "Score": "0", "Tags": [ "java", "cache", "spring", "framework" ], "Title": "How do I divide Dao and Dao-Cache into different modules?" }
260596
<p>I wrote two template functions to serialize and deserialize structs representing messages to be sent and received via a TCP socket:</p> <pre class="lang-cpp prettyprint-override"><code>/* * Convert a byte string into a packet. */ template &lt;typename PacketType&gt; PacketType deserialize(std::string &amp;buf, boo...
[]
[ { "body": "<p>Your code produces no memory leaks since you're not manually allocating and deleting memory.</p>\n<hr />\n<h2>Include all headers</h2>\n<p>Always include all the headers. In this case, you need <code>&lt;iostream&gt;</code>, <code>string</code>, and <code>cstring</code>.</p>\n<hr />\n<h2>Pass by c...
{ "AcceptedAnswerId": "260603", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T08:36:26.327", "Id": "260597", "Score": "4", "Tags": [ "c++", "c++17", "pointers", "serialization", "template-meta-programming" ], "Title": "De-/Serialization of struc...
260597
<p>I need to iterate over a list of IP addresses, to check if the elements inside are subnets/supernets between them, for this I use the <a href="https://docs.python.org/3/library/ipaddress.html#module-ipaddress" rel="nofollow noreferrer">IP-address</a> library.</p> <p>Currently I have the following problem: my second...
[]
[ { "body": "<p>This section:</p>\n<pre><code>fileobj=open(&quot;test.txt&quot;)\nfor line in fileobj:\n lines.append(line.strip())#create the list from the txt file\nlines.pop(0)#remove line &quot;name&quot;\n</code></pre>\n<p>has an alternate representation as an iterator-adjustment to skip one line:</p>\n<p...
{ "AcceptedAnswerId": "260610", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T09:04:18.840", "Id": "260598", "Score": "2", "Tags": [ "python-3.x", "ip-address" ], "Title": "Check if IP address list has subnet or is supernet" }
260598
<p>I'm trying to build a response cache with custom key values (from headers and cookies). Here's the code I have so far, and it kinda works, but I need a second opinion or suggestions for improvements.</p> <p>Are there any possible errors, faster key generation methods etc.</p> <p>Here's the code for middleware and ca...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T14:49:47.857", "Id": "514408", "Score": "0", "body": "Could you please elaborate on this: *something about all this feels wrong*?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T14:51:52.157", "Id...
[ { "body": "<p>I can see a few improvements that can be made. First, you can make <code>ResponseCacheKeyProvider</code> static. and rename it to something like <code>HttpCacheProfileProvider</code> so you can control all Requests/Responses headers, and can be related to the <code>CacheProfiles</code> class as we...
{ "AcceptedAnswerId": "260616", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T14:46:40.063", "Id": "260606", "Score": "1", "Tags": [ "c#", "asp.net" ], "Title": "Asp.net core response caching with custom key values" }
260606
<p>This is an Relative Strength Index algorithm able to buy and sell stock based on values from basic stock CSVs. It works correctly and well, but I'm not sure if it can be better optimized as it basically repeats itself twice to operate on the two stock values it's given. I can only use python itself, no numpy or anyt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T15:48:22.097", "Id": "514412", "Score": "0", "body": "The indentation looked wrong - I believe I've corrected it, but do please check that I got it right!" } ]
[ { "body": "<blockquote>\n<pre><code>if file1_length &gt;= file2_length:\n length = file2_length\nelse:\n length = file1_length\n</code></pre>\n</blockquote>\n<p>Or more succinctly as <code>length = max(file1_length, file2_length)</code></p>\n<hr />\n<blockquote>\n<p><code>tday</code></p>\n</blockquote>\n<...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T15:14:02.700", "Id": "260613", "Score": "0", "Tags": [ "python", "performance", "algorithm" ], "Title": "Relative Strength Index algorithm for stock values" }
260613
<p>I'm trying to design a chain of responsibility pattern.</p> <p>It slightly differ from traditional way when handler does only one action on a request, f.e. handles http response considering status code.</p> <p>But my handlers have to do two actions. Below is an (dummy) example where handler asks a question first and...
[]
[ { "body": "<p><em>Chain of Responsibility</em> pattern (hereby &quot;CORP&quot;) includes two things: iteration and &quot;handling&quot;.</p>\n<p>IMO, the iteration part, at least in modern programming languages such as Python and Java, can be easily &quot;extracted&quot; to an external iteration. So eventually...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-11T19:20:28.323", "Id": "260624", "Score": "2", "Tags": [ "python" ], "Title": "Chain of Responsibility design" }
260624
<p>I am looking to improve the performance of my code through best practices and cleaner code.</p> <p>My goal here is just to perform a conversion whenever there is a keyup.</p> <p>But I noticed that my code looks very repetitive. In your view, what should I do to simplify it?</p> <p><div class="snippet" data-lang="js"...
[]
[ { "body": "<p>The use of non-ASCII character <code>º</code> in variable names is surprising to me</p>\n<hr />\n<p>There is a lot of repeated <code>* 1</code> that is presumably used to convert <code>string</code> to <code>number</code>. <code>parseFloat</code> or <code>parseInt</code> will make intention more c...
{ "AcceptedAnswerId": "260652", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T00:16:45.810", "Id": "260631", "Score": "2", "Tags": [ "javascript", "formatting", "html5", "unit-conversion" ], "Title": "HTML/JavaScript temperature converter with round...
260631
<p>I've written this <strong><a href="https://github.com/ytliuSVN/crypto-app/blob/bd36ecb67538d25fe1be401f7030b4338433cd28/app/components/CoinList.js" rel="nofollow noreferrer">Card component</a></strong> which is composed of <code>thumbnail image</code>, <code>name</code>, <code>symbol</code>, <code>total_volume</code...
[]
[ { "body": "<p>It is equivalent to:</p>\n<pre><code>const renderPriceChange = (price) =&gt; {\n return (\n &lt;Text style={price &gt; 0 ? styles.rise : styles.drop}&gt;\n &lt;AntDesign\n name={price &gt; 0 ? 'caretup' : 'caretdown'}\n color={price &gt; 0 ? '#03AE9D' : '#fb2c33'}\n s...
{ "AcceptedAnswerId": "260634", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T02:38:19.060", "Id": "260633", "Score": "2", "Tags": [ "javascript", "react.js", "jsx", "react-native" ], "Title": "React component to render price change" }
260633
<p>Description of the App:-</p> <ol> <li>A React app that shows the public Github repositories of a user.</li> <li>The app shows an input field where we can enter a Github username and a submit button. {It provides users the feedback while getting the data in the background.}</li> <li>The repositories are shown as a li...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T09:35:44.587", "Id": "260640", "Score": "1", "Tags": [ "javascript", "react.js", "redux" ], "Title": "Working React App to display public Github Repositories of a user" }
260640
<p><strong>Hello everyone!</strong></p> <p>Here is the thing. So I wanted at first to create Robot class, I want him to move around some board. Maybe 10x10 or something like that, then i wanted to invent a Robot fights class, I want to add class players (becuase i want to play between player 1 and player 2) but here it...
[]
[ { "body": "<p><strong>Type annotations</strong></p>\n<p>Using type annotations will make your program a lot more readable and easier to debug. For example:</p>\n<pre><code>def __init__(self, name, place, start = (0,0), power = 9):\n # assignments\n</code></pre>\n<p>becomes</p>\n<pre><code>def __init__(self, ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T09:44:46.780", "Id": "260641", "Score": "0", "Tags": [ "python", "object-oriented" ], "Title": "Robot OOP Class in Python" }
260641
<p>I am trying to sort an associative array by following this scheme:</p> <ol> <li>Sort by 'qt': positives first, non-positives after. Magnitude does not matter, only sign.</li> <li>In positive part: sort by sa DESC</li> <li>In negative part: sort by sa DESC</li> </ol> <p>I managed to have the desired result but by ti...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T12:14:46.517", "Id": "514456", "Score": "0", "body": "So in your example you expect qt values [ 10, 5000, 1000, 0, 0 ] ? These are not sorted. Are you sure your example is valid?" }, { "ContentLicense": "CC BY-SA 4.0", "...
[ { "body": "<p>You are not actually sorting on <code>qt</code>, only using it to separate two sets (positive <code>qt</code> coming first). Only within each set you are actually sorting (on <code>sa</code>). Therefore, the usort() comparator function could look like this:</p>\n<pre class=\"lang-php prettyprint-o...
{ "AcceptedAnswerId": "260650", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T10:42:58.213", "Id": "260642", "Score": "3", "Tags": [ "php", "array", "sorting" ], "Title": "PHP Sort Associative Array first by relativity of value then by other value desc"...
260642
<p>This is a challenge from CodeSignal.</p> <p>For</p> <pre><code>image = [[1, 1, 1], [1, 7, 1], [1, 1, 1]] </code></pre> <p>the output should be <code>boxBlur(image) = [[1]]</code>.</p> <p>To get the value of the middle pixel in the input 3 × 3 square: <code>(1 + 1 + 1 + 1 + 7 + 1 + 1 + 1 + 1) = 15...
[]
[ { "body": "<p>Some suggestions on coding style:</p>\n<ul>\n<li><p>Your choice in variables is somewhat confusing <code>i</code>, <code>j</code>? For an algorithm operating on a 2D image, the names <code>x</code> and <code>y</code> would be better. And <code>dx</code>, <code>dy</code> for the offsets in the inne...
{ "AcceptedAnswerId": "260645", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T11:22:13.200", "Id": "260644", "Score": "2", "Tags": [ "javascript", "algorithm" ], "Title": "Box Blur algorithm" }
260644
<p>I am trying to translate the book Game Coding Complete by Mike McShaffry 4E to modern C++17 standard and faced with the code of Mersenne Twister by Takuji Nishimura and Makoto Matsumoto. Is it right to convert random generator code from book like that:</p> <p>from:</p> <pre><code>#include &lt;ctime&gt; #define CMATH...
[]
[ { "body": "<p>The short answer is (mostly) yes. Your use of C++17 and std::mt19937 looks mostly correct.</p>\n<p>However:</p>\n<ul>\n<li><p>You have <code>std::uniform_int_distribution&lt;unsigned int&gt; distr(0, n)</code>, and this generates random values from <code>0</code> to <code>n</code> inclusive. Your ...
{ "AcceptedAnswerId": "260677", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T12:46:38.787", "Id": "260646", "Score": "2", "Tags": [ "c++", "random", "stl" ], "Title": "convert GCCRandom(Mersenne Twister by Takuji Nishimura and Makoto Matsumoto) to stl ...
260646
<p>Im planning to use Strategy design pattern to put it in ScheduledExecutorService.scheduleAtFixedRate. I can use create as many scheduleAtFixedrate depends on the data to be pulled. Will this cause a race condition?</p> <pre><code> public abstract class DefaultStrategy { protected Map&lt;String, Strin...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T13:04:31.293", "Id": "260647", "Score": "1", "Tags": [ "java" ], "Title": "Race Condition in ScheduledExecutorService.scheduleAtFixedRate" }
260647
<p>Is it right it convert ID3DXMatrixStack to DirectXMath like that:</p> <pre><code>#include &lt;stack&gt; #include &lt;iostream&gt; #include &lt;DirectXMath.h&gt; class MatrixStack { std::deque&lt;DirectX::XMFLOAT4X4&gt; m_MatrixStack; public: MatrixStack() { DirectX::XMFLOAT4X4 identity; Dir...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-14T11:11:39.800", "Id": "514604", "Score": "0", "body": "It might be worth considering to replace deque with a vector" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-14T11:35:03.110", "Id": "514605", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T13:36:27.397", "Id": "260648", "Score": "0", "Tags": [ "c++", "matrix", "windows", "graphics", "hlsl" ], "Title": "convert ID3DXMatrixStack to DirectXMath" }
260648
<p>I have been writing a discord.py bot, running on replit.com. I gotten to the music bot part after finishing the queue part. My code is logically correct; however, the code is way too inefficient causing the bot to crash when someone adds another song to the queue. How can I program my bot to be more efficient? If my...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T15:30:21.220", "Id": "514478", "Score": "0", "body": "Please can you include the entire traceback for the error you're getting. Having the traceback can help us identify the issue and increases the potential for you to get you the f...
[ { "body": "<ul>\n<li>Prefer four-space indentation instead of a mix of four and two</li>\n<li><code>queueurls</code> should be <code>queue_urls</code></li>\n<li><code>else / pass</code> is redundant and can be deleted</li>\n<li>It's not a great idea to use a single, statically-named temporary file for your play...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T14:05:40.827", "Id": "260653", "Score": "1", "Tags": [ "python", "discord" ], "Title": "Very slow Discord bot to play music" }
260653
<p>Im fairly <strong>new to Golang</strong> and I appreciate any feedback about how to make the code cleaner.</p> <p>The code is called by <code>go-routine</code> and should update status (fail/success etc) of several installation process.</p> <pre><code>package avss import ( &quot;context&quot; &quot;sync&quo...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-20T13:43:56.427", "Id": "515019", "Score": "0", "body": "I think it is proper.. changes that could be made are (\"installed\" or \"reconcile\" -> if this value is being used elsewhere I would suggest you define them as constants in a c...
[ { "body": "<p>Overall this looks like a pretty sensible file. Some minor points you might want to consider follow.</p>\n<h3>Imports</h3>\n<p><code>logr</code> is not imported in the file. I presume this is <a href=\"https://github.com/go-logr/logr\" rel=\"nofollow noreferrer\">https://github.com/go-logr/logr</a...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T14:25:56.907", "Id": "260654", "Score": "4", "Tags": [ "beginner", "go" ], "Title": "Golang keep installation status for multiple installations process" }
260654
<p>I have a situation where I've used the strategy pattern but got many different strategies that are available to the client code that needs to select the appropriate strategy, this is because there's a lot of different usages to the strategy depending on the machine that's being calculated, because of the domain it's...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T16:08:23.913", "Id": "514481", "Score": "3", "body": "Do not prefix your variable names with the class name. `machine.Name` is plenty clear, `machine.MachineName` is overkill. Also, `MachineName` doesn't seem to be a name but a type...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T14:40:53.193", "Id": "260656", "Score": "1", "Tags": [ "c#", "design-patterns" ], "Title": "Filtering what strategy to use in strategy pattern" }
260656
<p>As you may know, C++20 has added <code>std::atomic&lt;std::shared_ptr&lt;T&gt;&gt;</code> specialization to the standard, but sadly, most compilers have not implemented it yet. So I decided to implement it myself.</p> <p>I want to know if I can improve this code or not. In addition, I'm not sure if my implementation...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-12T15:07:57.810", "Id": "260658", "Score": "5", "Tags": [ "c++", "pointers", "atomic" ], "Title": "Implementation of std::atomic<std::shared_ptr<T>> for C++20" }
260658