body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>Am experimenting with the <a href="https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8" rel="nofollow noreferrer">IAsyncEnumerable interface</a> and <a href="https://docs.microsoft.com/en-us/dotnet/standard/io/pipelines" rel="nofollow noreferrer">P...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T08:39:15.843", "Id": "529084", "Score": "0", "body": "Why do you call the `pipeReader.AdvanceTo` in a `final` block? Why do you want to advance in case of exception?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate"...
[ { "body": "<p>Whenever you see 3+ levels of indentation then it is a good sign to do some refactoring :D</p>\n<p>After making some simple transformations I've ended up with this version</p>\n<pre><code>public static async IAsyncEnumerable&lt;ReadOnlyMemory&lt;char&gt;&gt; DecodeAsync(this PipeReader pipeReader,...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T16:01:02.047", "Id": "268298", "Score": "2", "Tags": [ "c#", "asynchronous", "iterator" ], "Title": "Using the Decoder class in a streaming context" }
268298
<p>I wanted to allow my website visitors (any Tom, Dick &amp; Harry) submit their links to my webpage for output on my page. I thought it's best to parse user submitted urls before echoing their submitted urls on my page. Best to parse the urls as I won't know what urls they will be submitting nor the structures of th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T23:24:47.577", "Id": "529196", "Score": "0", "body": "So are we mostly reviewing third party code?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T20:12:23.160", "Id": "529321", "Score": "0", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T18:45:55.140", "Id": "268303", "Score": "1", "Tags": [ "php", "html5", "integer" ], "Title": "Displaying Submitted Links Securely On Your Pages" }
268303
<p>First, some background on what I am actually trying to do here: I am trying to open an Excel Workbook from Python, then run certain macros within that workbook, but with a timeout feature, so that, if any macro takes longer than a specified time limit, the execution will be stopped. I have been using as a starting p...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T21:41:40.040", "Id": "529069", "Score": "0", "body": "Welcome to Code Review! Is the code working correctly to the best of your knowledge?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T01:56:38.750"...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T21:14:56.703", "Id": "268307", "Score": "0", "Tags": [ "python", "multiprocessing" ], "Title": "Running an Excel Macro from a Child Process Using Multiprocessing Cannot Access Excel O...
268307
<p>I have written the following class used to get the metadata out of an internet radio station. It takes a Node Stream and transforms it to grab the metadata out of the mp3 stream and then removes the metadata bytes from the stream so it isn't audibly heard. If you need to know the Shoutcast metadata protocol, see her...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T21:24:28.173", "Id": "268308", "Score": "1", "Tags": [ "node.js", "typescript", "stream", "audio" ], "Title": "Getting metadata out of a Shoutcast stream" }
268308
<p>I'm working on creating code with a nice balance between concise and readable. How would you improve this Laravel code block to make it more compact and readable?</p> <pre><code> public function canEdit(Request $request) { $canEdit = Permission::canEdit( $request-&gt;user(), $...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T08:43:32.673", "Id": "529085", "Score": "1", "body": "I don't see much to review here. Outside of declaring `$payload['can-edit'] = ...` and removing the parentheses from `$statusCode`, I don't think there is anything to change. I ...
[ { "body": "<p>I agree with mickmackusa that your code is pretty good overall. If you wanted to condense it, you can refactor to something like below:</p>\n<pre class=\"lang-php prettyprint-override\"><code>public function canEdit(Request $request) {\n $canEdit = Permission::canEdit($request-&gt;user(), $reques...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T22:00:01.883", "Id": "268311", "Score": "1", "Tags": [ "php", "laravel" ], "Title": "Method in Laravel to give a JSON response indicating whether the user may edit" }
268311
<p>Following is my working application that contains a Search Container, a Sorting Container and a listing Container.</p> <p>Based on Search and Sort the listing data changes in the listing container.</p> <p>The application works fine though I noticed in my Search container whenever I am changing the input value in an ...
[]
[ { "body": "<p>I was able to resolve this by adding a <code>memo</code> wrapper around the components' <code>export</code> statements, then passing in a compare function that returns <code>true</code>. The components were re-rendering each time the <code>eventHandler</code> function was re-created when the state...
{ "AcceptedAnswerId": "268407", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-23T22:35:45.513", "Id": "268313", "Score": "4", "Tags": [ "javascript", "performance", "html", "react.js", "jsx" ], "Title": "Reduce multiple re rendering of components i...
268313
<p>So, I just managed to finish a problem that was proposed to me, and I find it very difficult since I started learning looping with <code>for</code> and using <strong>lists</strong> recently, I thought about sharing the problem and my solution with you guys so you could give me some advice on how I should make my cod...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T07:44:27.363", "Id": "529082", "Score": "0", "body": "You may be interested in the SO question [What is the cleanest way to do a sort plus uniq on a Python list?](//stackoverflow.com/q/2931672/4850040)" }, { "ContentLicense"...
[ { "body": "<p>It's a good start. Depending on what class this is for, the person (teacher?) who proposed this question to you might care about time complexity of your solution. Your solution is going to have a number of problems there, since:</p>\n<ul>\n<li><code>del z[y]</code> is linear-time (&quot;O(n)&quot;...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T01:09:09.133", "Id": "268315", "Score": "6", "Tags": [ "python", "beginner", "python-3.x" ], "Title": "Remove repeated numbers from a list" }
268315
<p>I am using the following one-liner to remove duplicate non-empty lines without sorting:</p> <pre class="lang-sh prettyprint-override"><code>perl -ne 'if ( /^\s*$/ ) { print } else { print if ! $x{$_}++}' </code></pre> <p>Empty (whitespace-only) lines are to be retained.</p> <p>However, this code seems bulky, special...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T07:12:15.673", "Id": "529080", "Score": "2", "body": "I'm not sure what you mean by `$x{$_}++` being bulky. It seems pretty small for what it does. Does it take too much memory? What's bulky about it? In terms of readability, is...
[ { "body": "<p>Why not just</p>\n<pre><code>print if /^\\s*$/ || ! $SEEN{$_}++\n</code></pre>\n<p>I don't see the point of nesting here. You want to print if the line is empty or if it has not been seen previously. So say that. If you still don't find this readable and readability is your main concern, change...
{ "AcceptedAnswerId": "268324", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T05:08:30.477", "Id": "268320", "Score": "6", "Tags": [ "perl" ], "Title": "Remove duplicate lines without sorting or removing empty lines" }
268320
<p>I'm wondering if there is a nicer way to acomplish what I want:</p> <p>I do have an array with object like that:</p> <pre><code>let data = [ {val1: [1,2,3,4], val2:[6,7,8,9] } ] </code></pre> <p>What I want is an object like:</p> <pre><code>let limit = { minX: 1, maxX: 4, minY: 6, maxY: 9 }; </code></pre> <p>My ...
[]
[ { "body": "<p>The original code looks more like traditional JS, it does not benefit from typing features provided by the <em>TypeScript</em> language.</p>\n<p>The solution I suggest below is not necessarily <em>shorter</em>, but its main goal is to put the things in order using the TS style.</p>\n<p>First of al...
{ "AcceptedAnswerId": "268399", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T10:13:17.537", "Id": "268329", "Score": "0", "Tags": [ "typescript" ], "Title": "Shorthand of compiling min and max values from an array with object into new object" }
268329
<p>This is a Python 3 script I have written over three days that transliterates (not translating) English orthography written in Latin alphabet to the Cyrillic alphabet, the Greek alphabet or a mixed of those two above.</p> <p>The script transliterates the text, meaning it doesn't translate the meaning of the text from...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T14:54:45.860", "Id": "529140", "Score": "0", "body": "\"ionization\" appears differently on my machine, as `'айаνаζεϋσаν'`. Is that intended?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T15:38:36.6...
[ { "body": "<p>This is cool! I wonder how pronounce-able the results are by a native Greek speaker. Is that your language?</p>\n<p>Things that could be improved:</p>\n<ul>\n<li>It's not all that useful to represent the values of <code>TRANSLITERATION</code> as dicts. Given that they're all two items long, it's s...
{ "AcceptedAnswerId": "268361", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T10:27:23.840", "Id": "268331", "Score": "3", "Tags": [ "python", "python-3.x", "converting" ], "Title": "Python 3 script to phonetically transliterate written English to Cyril...
268331
<p><strong>Shared below is a functionality test. I would love to get some review from the community. Thank you.</strong></p> <p>The idea of the system is a simple CLI application which can be used to download PDF from a given URL. For more information please visit <a href="https://github.com/PythonCheatsheet/downloadpd...
[]
[ { "body": "<p>It's good to learn to write tests.</p>\n<p>That said, these tests are more complicated, error-prone, and breakable by far than your actual logic, so consider whether they would be worth it in a real project. They are also longer than the code, which is perfectly normal for tests.</p>\n<h3>General ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T11:56:40.963", "Id": "268333", "Score": "3", "Tags": [ "python", "python-3.x", "unit-testing" ], "Title": "Functional tests of downloadpdf, a python CLI app" }
268333
<p>I have written the following cli tool.</p> <pre><code>import sys import argparse parser = argparse.ArgumentParser(prog='remove-duplicate-lines-except-blank-lines', usage='%(prog)s [options] [files...]', description='Remove duplicate line except white...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T11:17:08.093", "Id": "529440", "Score": "5", "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>A few comments in no particular order:</p>\n<ul>\n<li>When reading, you are doing just fine, as you are processing one line at a time. However, you are storing the lines you read in memory. This could cause the program using lots of memory if reading long files.</li>\n</ul>\n<p>This has a simple s...
{ "AcceptedAnswerId": "268350", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T13:00:21.333", "Id": "268336", "Score": "4", "Tags": [ "python", "python-3.x" ], "Title": "Template For a CLI Application" }
268336
<p>This was my solution to an interview question:</p> <p>Q: Implement an std::vector style container (does not have to be exactly compatible) with a fixed buffer and the following requirements and restrictions:</p> <ul> <li>The fixed buffer size should be provided by a template parameter.</li> <li>No dynamic memory all...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T15:29:54.280", "Id": "529152", "Score": "3", "body": "Have a read of the 5 articles I wrote about creating your own vector class. https://lokiastari.com/series/" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "20...
[ { "body": "<p>This is not a bad attempt at making a vector-like container, except it is lacking support for <code>const</code> and makes unnecessary copies (see below for a more detailed explaination). The variable names are quite well chosen. It's also good to see Doxygen documentation.</p>\n<h1>Use <code>std:...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T13:17:53.187", "Id": "268337", "Score": "4", "Tags": [ "c++", "c++11", "template", "vectors" ], "Title": "C++11 Custom Vector Implementation" }
268337
<p>I'm a mathematician who is new to programming and I'm currently reading the book &quot;Theory of Neural Networks&quot; by Rojas. To become better, I try to program every algorithm that is described in the book using javascript (to be precise: the p5js editor). Let <span class="math-container">\$X=\{x_{1},\ldots,x_{N...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T14:47:09.723", "Id": "268340", "Score": "2", "Tags": [ "javascript", "algorithm", "machine-learning", "neural-network" ], "Title": "Unsupervised competitive learning algorithm...
268340
<p>I have created a VBA macro to create a pivot table automatically. But taking 15 to 20 minutes of time to complete the macro.</p> <p>Especially at the point of below code taking half of the time. Review Code below</p> <pre><code>With .PivotFields(&quot;NTS USD ACT Previous Year&quot;) .Orientation = xlDataField ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T15:13:44.223", "Id": "529147", "Score": "0", "body": "The line(s) `With .PivotFields ... End With` are taking 7-10 minutes to execute? My guess is that it's in `.Function = xlAverage` and it will probably take this long if you were ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T14:56:11.493", "Id": "268341", "Score": "0", "Tags": [ "vba", "excel", "macros" ], "Title": "Creating Pivot Table taking time at average vales" }
268341
<p>This very short piece of code is a migration in which a column name is changed to be more descriptive. It is part of a larger bioinformatics application written in RoR that parses the output of multiple bioinformatics tools, then summarizes and stores the results in PostgreSQL database. The goal is to analyze next g...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T15:30:38.360", "Id": "529153", "Score": "1", "body": "I don't know RoR but the class name is making my eyes water =)" } ]
[ { "body": "<blockquote>\n<p>Does this code follow common best practices in Ruby regarding block vs line comments?</p>\n</blockquote>\n<p>No, <a href=\"https://github.com/rubocop/ruby-style-guide#no-block-comments\" rel=\"nofollow noreferrer\">it doesn't</a>.<br />\nAnd with the fear of starting a flamewar here,...
{ "AcceptedAnswerId": "268412", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T14:59:34.700", "Id": "268342", "Score": "3", "Tags": [ "ruby", "ruby-on-rails" ], "Title": "Migration in a bioinformatics application that changes a column name and explains the r...
268342
<p>My first language is Python and I learned considerably a good amount of it. So now I started learning C++. I know the basics of C++ and about classes and inheritance.</p> <p>This is my first serious project with classes. (I am thinking of adding an ai)</p> <p>I wanted to know where I could -</p> <ul> <li>Optimize th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T10:23:02.923", "Id": "529229", "Score": "1", "body": "Since you mention knowing Python, would you use a class to implement this in Python? I'm asking because, just like in Python, you would usually *not* use a class here in C++, as ...
[ { "body": "<p>in <code>print_board</code>:</p>\n<ul>\n<li>instead of checking against all <code>i</code>s I would try to find a formula (probably containing a modulo) to check against once</li>\n<li>if you want to <code>cout</code>, don't put an <code>endl</code> at every line (it flushes the buffer to screen),...
{ "AcceptedAnswerId": "268358", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T16:47:23.890", "Id": "268345", "Score": "4", "Tags": [ "c++", "performance", "tic-tac-toe", "classes" ], "Title": "Tic Tac Toe in C++ with classes" }
268345
<p>On my page I have a <code>mouseup eventlistener</code> on <code>document</code>. I want to be able <em>catch</em> if the <em>clicked</em> elements has a specific <code>id</code> in any of their parents.</p> <p>What I'm doing now is to <code>loop</code> over the <code>e.path</code> and only <code>push</code> the ids ...
[]
[ { "body": "<blockquote>\n<p>I feel this is not optimal or the right way of doing this. How can I make it so I don't need to each time loop over all the e.path and push to the array and than do the include.</p>\n</blockquote>\n<p>Another approach would be to use the element method <a href=\"https://developer.moz...
{ "AcceptedAnswerId": "268395", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T17:05:07.027", "Id": "268346", "Score": "1", "Tags": [ "javascript", "ecmascript-6", "event-handling" ], "Title": "Javascript - On mouseup check if any of the parents has/incl...
268346
<p><strong>The problem</strong></p> <p>I am working towards improving my Python coding. I am checking that I am doing the best in terms of the Python code, not necessarily the algorithms. Having looked at one of my previous attempts in C++, I learned about Sieves for prime numbers.</p> <p>I want to know that I am follo...
[]
[ { "body": "<p>Your code is readable, consistant and adheres to all the PEP8 standards I have to follow. I wouldn't worry about any further nit picks.</p>\n<p>One preference I have - If I am defining the parameter type, I would also define the return type:</p>\n<pre><code>def is_odd(number: int) -&gt; bool:\n</c...
{ "AcceptedAnswerId": "268433", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T20:18:05.733", "Id": "268354", "Score": "3", "Tags": [ "python", "beginner", "python-3.x" ], "Title": "Prime number finder in Python3" }
268354
<p>I'm scraping posts from various discussion forums and storing those posts, along with some metadata, into a relational database (SQL). My actual use case is a bit more complex, but I think I can give you the idea by using just two fictitious forums, one focusing on fishing (&quot;Fish Forum&quot;) and another focusi...
[]
[ { "body": "<p>If the <code>post_id</code> is unique, why not make it a primary key? Sometimes it is justified to have an internally-controlled primary key like <code>id</code> but here the justification is unclear. One catch is that if the two forums are from different websites, their ID sequences will be diffe...
{ "AcceptedAnswerId": "268362", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-24T20:30:52.817", "Id": "268355", "Score": "1", "Tags": [ "sql", "sql-server", "database" ], "Title": "Database schema for discussion forum scraping" }
268355
<p>I'm a Kotlin engineer looking to get into web dev. I thought it'd be fun to make a Todo app w/o help from the internet. Just looking for some critiques and feedback, as I'm new-ish to the language.</p> <p>Here's the JS, HTML, CSS. Looking for criticism on all of it. No mobile support btw.</p> <p>JS:</p> <pre><code>c...
[]
[ { "body": "<h2>Too complex</h2>\n<p>You have over engineered the objects.</p>\n<p><code>Column</code> should not care what it contains. All it should do is add and remove items.</p>\n<p>Inheriting from <code>Column</code> to create <code>Done</code> and <code>Todo</code> columns has just made more work for the ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T00:16:45.663", "Id": "268363", "Score": "3", "Tags": [ "javascript", "html", "css", "to-do-list" ], "Title": "Simple Vanilla JS Todo app" }
268363
<p>I tried to write the program so that it runs without error but I want to improve the program so that it follows the Single Responsibility Principle. What changes can I make to improve this program? I am a beginner in programming and not good at pseudocode or commenting so if there is anything I can do to also impro...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T05:29:11.917", "Id": "529207", "Score": "0", "body": "I'm not sure why you removed the Python part of your program, since it makes your question off-topic. If the Python code works, you can put it back. If it doesn't work, the quest...
[ { "body": "<h2>Pseudocode</h2>\n<p>First, your block-quoted pseudo-code is too much like code, and not enough pseudo. The purpose of pseudo-code is understanding. If it doesn't help you to understand, or if it doesn't help someone else (like a professor) to understand, then you're doing it wrong. In general, I'...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T00:22:30.063", "Id": "268364", "Score": "2", "Tags": [ "python", "beginner", "python-3.x", "functional-programming" ], "Title": "Garden simulator" }
268364
<p>The problem states that you have to rob the maximum money stashed in the houses but you cannot rob two adjacent houses. array[i] denotes the money in the (i)th house. I got the following code submitted but Is there a more optimised aprroach. I saw a very small solution on the YouTube Channel 'NeetCode' but couldn't ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T05:45:58.323", "Id": "529208", "Score": "0", "body": "Hello, I added the two test scenarios included in the link to the description of the problem for a better understanding of the task." }, { "ContentLicense": "CC BY-SA 4....
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T05:02:48.327", "Id": "268367", "Score": "0", "Tags": [ "java", "performance", "programming-challenge", "dynamic-programming" ], "Title": "Better Approach for the House Robbery...
268367
<p>So, I just finished Problem 10 on Project Euler, but it took about 3 to 4 minutes for my output to come out, due to bad coding, I guess, any suggestions on how could I optimize my code?</p> <p><strong>Question</strong></p> <p><strong>The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.</strong></p> <p><strong>Find ...
[]
[ { "body": "<p>The main problem I see is, that you don't use the number one rule in software development, which is: <em><strong>split the problem</strong></em>.</p>\n<p>When you want to know the sum of primes up to <em>n</em>, you basically have two distinct parts to solve:</p>\n<ol>\n<li>know the primes up to <...
{ "AcceptedAnswerId": "268371", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T05:11:52.377", "Id": "268368", "Score": "1", "Tags": [ "java", "performance", "beginner", "programming-challenge", "primes" ], "Title": "Improving Project Euler code p...
268368
<p>I don't know why there's no such function in std (at least I didn't find one). I need a conditional template function to return a reference to an object of <code>T</code>. <code>T</code> might be passed as a pointer or a smart pointer or by reference:</p> <pre><code>template &lt;typename T&gt; void do_foo(T &amp;t) ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T08:28:12.030", "Id": "529217", "Score": "0", "body": "Can you explain the motivation for this a bit more? I'm guessing that it's a helper for other templates which you want to use with pointer-like types, but at some point there ha...
[ { "body": "<h1>It is probably a bad idea</h1>\n<p>Your <code>dereference()</code> will even work if you don't give it a pointer-like type:</p>\n<pre><code>int foo = 42;\nstd::cout &lt;&lt; eld::traits::dereference(foo) &lt;&lt; '\\n';\n</code></pre>\n<p>That prints out 42. Maybe it's still simple when we deal w...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T06:42:50.563", "Id": "268370", "Score": "1", "Tags": [ "c++", "template-meta-programming" ], "Title": "template function for conditional dereference" }
268370
<p>Dabbling a bit more with arm assembly, I wrote a few functions to handle string splitting. The goal was to write a few reusable functions that could be combined to emulate (roughly) what C <code>strtok()</code> does. The approach was essentially to write <code>strspn()</code> and <code>strcspn()</code> approximation...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T06:59:38.400", "Id": "268372", "Score": "4", "Tags": [ "assembly", "arm" ], "Title": "Arm Assembly Tokenize String (strtok()), Load Move, Add Efficiency" }
268372
<p>I was watching <a href="https://www.youtube.com/watch?v=MacVqujSXWE" rel="nofollow noreferrer">Computerphile's video on using genetic algorithms</a> to solve <a href="https://en.wikipedia.org/wiki/Knapsack_problem" rel="nofollow noreferrer">the Knapsack problem</a>, and I decided to give it a whack.</p> <p>For anyon...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T11:31:04.100", "Id": "268376", "Score": "1", "Tags": [ "python", "simulation", "genetic-algorithm", "knapsack-problem" ], "Title": "Solving the Knapsack Problem With a Genetic...
268376
<p>I recently was asked to upgrade some C++11 code to add a feature by which the user can set a time duration from the command line of the program. The requirement was to have a default time of 1500 ms but to allow it to be overridden by the command line parameters if the parameters are valid; invalid conditions shoul...
[]
[ { "body": "<p>Looks pretty good; these comments are mainly nitpicking:</p>\n<p>Error messages should be streamed to <code>std::cerr</code>, not <code>std::cout</code>. Whilst that's correctly done in <code>main()</code>, we're using the wrong stream in <code>parseDuration()</code>.</p>\n<p>I'm not a fan of bot...
{ "AcceptedAnswerId": "268387", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T11:42:47.903", "Id": "268377", "Score": "6", "Tags": [ "c++", "c++11", "timer" ], "Title": "Time duration conversion with units" }
268377
<p>The python code simulates an environment of an X number of persons with an Y number of places they can go to, puts the persons randomly in the places and calculates how many persons get infected, die or recover. It mostly work with lists, if you can optimize it in any way, thanks in advance!</p> <pre class="lang-py ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T14:40:21.943", "Id": "529251", "Score": "1", "body": "_persons get infected, die, recover, die_ - so like... zombies?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T15:09:18.373", "Id": "529252",...
[ { "body": "<h2>Readability ,Data Types, Potential Bugs</h2>\n<ul>\n<li><p>The code is quite hard to follow. We should break it up into functions and let's add a <code>if __main__==..</code></p>\n</li>\n<li><p>I'm renaming a couple of variable like place to rooms</p>\n</li>\n<li><p>Multiple assignments with such...
{ "AcceptedAnswerId": "269227", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T14:21:18.197", "Id": "268382", "Score": "5", "Tags": [ "python", "performance", "python-3.x", "simulation", "generator" ], "Title": "The python code simulates an envir...
268382
<p>Please find below my code. Any recommendations/suggestions on how to improve it and make it more readable will be hugely appreciated. I've tried to comment it as much as possible so everyone can understand what my purpose was in every part of the code, but please feel free to ask me for more clarifications.</p> <pre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T16:53:08.010", "Id": "529258", "Score": "2", "body": "I understand if you don't want to publish SFTP details for your server here, but short of that, could you post the header and ten or so representative rows from an example excel ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T15:46:55.303", "Id": "268385", "Score": "1", "Tags": [ "python", "python-3.x" ], "Title": "Wrangling and reading several xlsx files from sftp server and concatenating them into a sing...
268385
<p>This is just a practice exercise, I'm trying to understand dynamic programming as deeply as I can. I solved this using recursion, though I am not sure if it will always work. If anyone could tell me a case in which my solution does not work. And I would also appreciate knowing the time/space complexities of this sol...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T19:05:43.643", "Id": "529265", "Score": "0", "body": "There are some obvious errors in your code. In `dup_trees()`, inside the `if(root.right)`, you store `root.left.value` in the map. You also don't correctly handle the case where ...
[ { "body": "<p>First off, for pure data, I've been getting into using dataclasses for my values. This will take care of doing that <code>__repr__</code> method and the constructor for you. Even better, if you can use a frozen dataclass, then it can also be used as a key in a dictionary, because it is safely hash...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T18:23:39.507", "Id": "268388", "Score": "2", "Tags": [ "python", "recursion", "tree", "dynamic-programming", "binary-tree" ], "Title": "Find ALL duplicate subtrees. using ...
268388
<p>Gave myself the challenge of solving the Gilded Rose with pure functions in C#. All one-line lambdas, all static, all the time. The original kata assumed the code would mutate the given array-- I've opted not to, for better or for worse. Let me know what you think!</p> <p>Linking to the GitHub repo since I broke the...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-25T20:51:23.793", "Id": "268393", "Score": "0", "Tags": [ "c#", "functional-programming", "asp.net-core" ], "Title": "Gilded Rose with pure functions in C#" }
268393
<p>I'm trying to implement a recursive+momoize version for <a href="https://leetcode.com/problems/dungeon-game/" rel="nofollow noreferrer">leetcode's dungeon game</a> question.</p> <p>I tried to use <code>@lru_cache()</code>:</p> <pre><code>________________________________________________________ Executed in 14.22 se...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T03:58:41.067", "Id": "529286", "Score": "0", "body": "This sort of problems would best be solved using a game-tree traversing algorithm such as minimax." } ]
[ { "body": "<p>With your example input, the function <code>helper</code> gets called with <code>400568</code> different parameters. According to its <a href=\"https://docs.python.org/3/library/functools.html\" rel=\"nofollow noreferrer\">documentation</a> <code>lru_cache</code> by default caches the parameters a...
{ "AcceptedAnswerId": "268406", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T03:22:24.093", "Id": "268396", "Score": "2", "Tags": [ "python", "performance", "algorithm", "cache" ], "Title": "Python: lru_cache make leetcode's dungeon game more slowe...
268396
<p>Recently, I had to write a code to classify and rename lots of image files based on their content. So, I wrote a Python script which displays all those images as a slideshow to the me, and I can classify and rename them with one button click, instead of renaming every file manually.</p> <p>The directory structure lo...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T07:32:24.520", "Id": "268398", "Score": "1", "Tags": [ "python", "async-await", "tkinter" ], "Title": "Event handling with async await in Python" }
268398
<p>I have written following code for the this C++ Problem:</p> <p>Write a program to add only odd numbers between one to ten.</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int num = 1, n = 0; int odd_num; while(num &lt;= 10) { if(num % 2 != 0) { o...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T18:20:38.200", "Id": "529399", "Score": "3", "body": "`odd_num` is a lousy name (if you'd used 8 instead of 10, `odd_num` would end up being 16, which is odd (strange) to call odd (not even)). Better would be `running_sum`." } ]
[ { "body": "<p><code>using namespace std;</code> is a poor practice and can be harmful, so it's good to rid yourself of that habit early on.</p>\n<p>The loop's structure is</p>\n<blockquote>\n<pre><code>int num = 1;\nwhile(num &lt;= 10)\n{\n ⋮\n num++;\n}\n</code></pre>\n</blockquote>\n<p>That is more fami...
{ "AcceptedAnswerId": "268402", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T12:21:38.710", "Id": "268401", "Score": "5", "Tags": [ "c++" ], "Title": "Adding Odd numbers in C++" }
268401
<p>My goal is to safely consume an API without getting <code>429 Too Many Requests</code> error, activating DDoS protection or going over system limit of maximum open file descriptors. To achieve that I wrote this simple wrapper around <code>http.Client</code> using worker pool pattern:</p> <pre><code>package client i...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T15:19:20.910", "Id": "268404", "Score": "1", "Tags": [ "web-scraping", "go", "concurrency", "connection-pool" ], "Title": "golang http.Client wrapper with rate and concurrency...
268404
<p>I have recently learned Merge Sort algorithm in C++ with 2 ways of writing it.</p> <p>1st Way:</p> <pre><code> void merge(int arr[],int low,int mid,int high){ const int n1=(mid-low+1); const int n2=(high-mid); int*a=new int[n1],*b=new int[n2];//dynamically allocated because of MSVC compile...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T16:10:30.077", "Id": "529307", "Score": "0", "body": "`printArray()` seems to be undefined." } ]
[ { "body": "<p>I haven't got time to do this comprehensively but here is a start...</p>\n<p>Which method is better must be decided by what is important to you.</p>\n<p>Both methods are <em>recursive</em>. The pro's and con's of that are worth reading up about. At its heart <em>recursion</em> hammers the <em>c...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T15:25:03.393", "Id": "268405", "Score": "1", "Tags": [ "c++", "comparative-review", "mergesort" ], "Title": "Comparison of 2 different ways of writing Merge Sort Algorithm" }
268405
<p>In work I was asked to fix a bug which involved me making changes in a class. To fix the bug I needed to add a collection of a class that looks like this.</p> <pre><code>public class Branch { public int StartNode { get; set; } public int EndNode { get; set; } } </code></pre> <p>The collection</p> <pre><...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T22:18:02.090", "Id": "529325", "Score": "0", "body": "I think that KISS applies in this scenario. `_visitedBranch` is not a public-facing property, and is used in one place purely for validation. Writing more code to try and hide th...
[ { "body": "<blockquote>\n<p>Do I make a class out of the collection</p>\n</blockquote>\n<p>You did - <code>List&lt;Branch&gt;</code>, but it is not being used. Everywhere <code>_vistedBranch</code> (spelling?) is iterated something like <code>_vistedBranch.Find(&lt;expression&gt;)</code>, <code>Contains(item)<...
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T19:07:57.577", "Id": "268409", "Score": "0", "Tags": [ "c#", ".net" ], "Title": "Whats the best way to refactor a POCO class" }
268409
<p>I code in Rust, but one doesn't need to be familiar with Rust to understand the question.</p> <p>We are given the two vectors, <em>first</em> and <em>res</em>. Our goal is to append <em>res</em> to <em>first</em>, and then to assign the result to <em>res</em>.</p> <p>Let's consider the following two approaches. The ...
[]
[ { "body": "<p>Actually, you want:</p>\n<pre><code>res = [first, rest].concat(); // require your type to be cloneable\n</code></pre>\n<p>Or:</p>\n<pre><code>res.splice(0..0, first);\n</code></pre>\n<p>Or:</p>\n<pre><code>res = vec![first, rest].into_iter().flatten().collect();\n</code></pre>\n<p>But it seems odd...
{ "AcceptedAnswerId": "268418", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-26T20:42:43.700", "Id": "268411", "Score": "0", "Tags": [ "rust" ], "Title": "Concatenate two vectors and store the result" }
268411
<p>I wrote this bash script to try to make sure save games don't get mixed between different steam users using the same Ubuntu account.</p> <p>It uses inotify to try to figure out when a user changes and a soft link to point to the correct folder.</p> <pre><code>#!/bin/bash link_name=~/.factorio check_username=$(awk -F...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T00:09:37.467", "Id": "268413", "Score": "2", "Tags": [ "bash" ], "Title": "Reliable separation of Steam users" }
268413
<p>I'm looking to develop a validation library which can be extended by adding custom validation rules. To write a custom rule, simply write a class and apply the ValidationRule decorator like so:</p> <pre><code>@ValidationRule('array') class IsArray { constructor(a?: number, b?: number, c?: number) { } evalu...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T07:43:37.637", "Id": "529344", "Score": "0", "body": "Welcome to Code Review! Asking about code that you haven't written yet is specifically [outside the scope](/help/on-topic) of Code Review. Can you confirm that the requirements ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T02:09:44.227", "Id": "268414", "Score": "0", "Tags": [ "typescript" ], "Title": "Extendable Validation Library" }
268414
<p>I'm working on a user-pairing algorithm using socket.io, and it is running on Node.js. I want to make sure that no repeated pairings will happen when people connect in.</p> <p>The steps of the algorithm as follows:</p> <ol> <li>Divide the players into two rooms, one for retailers and the other for suppliers.</li> <l...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T02:53:13.900", "Id": "268415", "Score": "0", "Tags": [ "algorithm", "node.js", "socket.io" ], "Title": "Socket.io: Pairing from two rooms without repeated pairing?" }
268415
<p>I am once again attempting another CP problem, and I have ONCE AGAIN run into an optimization issue because of the time limit of one second: <a href="https://open.kattis.com/problems/doctorkattis" rel="nofollow noreferrer">https://open.kattis.com/problems/doctorkattis</a></p> <blockquote> <p>It is common for cats to...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T07:04:35.130", "Id": "529339", "Score": "2", "body": "Welcome to Code Review! Could you clarify what you mean when you say the program \"failed\"? If it gives incorrect results, it's not yet ready for review (we require _working_ ...
[ { "body": "<p>I'm just reviewing the C++ code here.</p>\n\n<h1>Pass by reference where appropriate</h1>\n<p>Unlike Python, C++ by default passes parameters by <em>value</em>. This means that with your version of <code>findEntryWithLargestValue()</code>, a copy of the whole map is made every time you call it. In...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T03:33:20.280", "Id": "268416", "Score": "4", "Tags": [ "python", "c++", "performance", "hash-map" ], "Title": "Prioritise injured cats for treatment (dictionary/map search opt...
268416
<p>Just experimenting some things with css, I made a centered circle div (inner) which is inside a circle div (outer). <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTY...
[]
[ { "body": "<p>instead of the margin and padding, you can declare the outer circle as a grid, which allows you alignment control of its children:\n(note that <code>place-items</code> aligns vertically and horizontally)</p>\n<pre><code> display: grid;\n place-items: center;\n</code></pre>\n", "comments"...
{ "AcceptedAnswerId": "268427", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T06:28:34.227", "Id": "268419", "Score": "2", "Tags": [ "html", "css" ], "Title": "A circle in a circle" }
268419
<p>My code runs exactly as it should. However, I would like to make it run a bit faster. I have tried defining some variables as <code>Long</code> to run it faster but it is still a bit slow.</p> <p>Is it possible to remove some code to make the macro run faster?</p> <pre><code>Sub sortiereninl() Dim sort As Workshee...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T10:54:47.817", "Id": "529352", "Score": "2", "body": "What is the code solving? We can only help you optimize the code when we know what it is doing. Please read [How do I ask a good question?](https://codereview.stackexchange.com/h...
[ { "body": "<h2>Turn Off ScreenUpdating and Calculations to Optimize Performance</h2>\n<p>This stops VBA from having to want for Excel to recalculate formulas and refresh the screen.</p>\n<p>Turn Off ScreenUpdating and Calculations:</p>\n<pre><code>With Application\n .Calculation = xlCalculationManual\n .S...
{ "AcceptedAnswerId": "268432", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T09:12:03.747", "Id": "268422", "Score": "3", "Tags": [ "performance", "vba", "excel" ], "Title": "Sorting worksheet by a given column" }
268422
<p>I wrote a minimal CSV parser for my machine learning toy project.</p> <pre><code>class CSV { public: using data_type = std::variant&lt;int32_t, float, std::string&gt;; using row_type = std::vector&lt;data_type&gt;; private: std::vector&lt;row_type&gt; rows; std::vector&lt;row_type&gt; columns; s...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T14:23:05.737", "Id": "529373", "Score": "0", "body": "I'm wondering why you have a 2-D array for `rows` _and_ for `columns`. Does it hold the same data twice?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "202...
[ { "body": "<p>It's surprisingly efficient. If I were to implement it myself, I would have gone with a <code>while(std::getline(...))</code> loop, so I always know I am dealing with a whole line at a time, and can pass a <code>std::string_view</code> into the line buffer instead of making a copy of each item int...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T11:01:39.227", "Id": "268428", "Score": "2", "Tags": [ "c++", "csv" ], "Title": "C++ Minimal CSV parser" }
268428
<p>I created an input that accepts and formats phone numbers into XXX-XXX-XXX. The user should be able to type numbers and the dashes should insert themselves automatically.</p> <p>Example #1: The user types 1 2 3 4. The input shows 123-4.</p> <p>Example #2: The user types 1 2 3 4 BACKSPACE. The input shows 123. Note t...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T06:41:18.563", "Id": "529493", "Score": "0", "body": "Why not use one of the many libraries that are available? https://www.npmjs.com/search?q=react%20phone%20number" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate"...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T12:21:43.767", "Id": "268430", "Score": "3", "Tags": [ "react.js", "formatting", "typescript" ], "Title": "Use formats phone numbers into XXX-XXX-XXX" }
268430
<p>I'm new to C++ (not to programming in general), which I want to learn to participate in some programming contests.</p> <p>I solved the <a href="https://onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;category=13&amp;page=show_problem&amp;problem=1130" rel="nofollow noreferrer">Online Judge Mineswee...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T20:19:34.010", "Id": "529549", "Score": "0", "body": "PS. Your code fails for the online Judge." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T20:53:46.817", "Id": "529551", "Score": "0", ...
[ { "body": "<p><a href=\"https://stackoverflow.com/questions/1452721\">Don’t</a> write <code>using namespace std;</code>.</p>\n<p>You can, however, in a CPP file (not H file) or inside a function put individual <code>using std::string;</code> etc. (See <a href=\"https://github.com/isocpp/CppCoreGuidelines/blob/...
{ "AcceptedAnswerId": "268442", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T14:52:25.353", "Id": "268436", "Score": "3", "Tags": [ "c++", "beginner", "programming-challenge", "minesweeper" ], "Title": "Online Judge 10189: Minesweeper (C++)" }
268436
<p>This code replaces each element in an array with the product of every other element in the array but the current element, without using division. So, for the array [5,2,3], the program outputs [6,18,108].</p> <p>The code is below, but in essence, it iterates through each element, and sets the element to the product ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T23:38:12.343", "Id": "529483", "Score": "5", "body": "I'm not convinced that the result you are aiming for is the result that the \"question\" is aiming for. I'd expect `[5, 2, 3]` to be `[6, 15, 10]` by the description ..." } ]
[ { "body": "<p>The <code>productOfArray</code> could be implemented by <a href=\"https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce\" rel=\"nofollow noreferrer\"><code>reduce</code></a>.</p>\n<pre><code>function productOfArray(array: number[]): number {\n return array.red...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T14:58:46.427", "Id": "268437", "Score": "2", "Tags": [ "typescript" ], "Title": "This code replaces each element of an array with the product of every element of the array except the curr...
268437
<p>I want to check null values in excel files where there are many sub folders. I have wrote a python code to check the null values in excel files in each and every folder and the code was working fine but I need to simplify the code.</p> <pre><code>import os ,uuidtre import numpy as np import pandas as pd import loggi...
[]
[ { "body": "<p>Use <code>print()</code> or <code>write()</code> for normal program output. The <code>logging</code> module is generally for recording information about how the program is running, e.g., for debugging, performance monitoring, etc.</p>\n<p>I'd recommend using <code>pathlib</code> in the standard l...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T15:07:35.237", "Id": "268439", "Score": "1", "Tags": [ "python-3.x" ], "Title": "Python code to check the null values in excel files" }
268439
<p>After implementing a serial CLOCK second-chance cache in C++ without having enough rope to shoot myself in the foot, decided to dive into Javascript through NodeJs and write an asynchronous one. I think on basic functionality it's nearly complete but there might be some things that I've missed on implementation and ...
[]
[ { "body": "<h1>Overfall feedback</h1>\n<p>This review will mostly focus on the usage of JavaScript features used and not so much on the actual algorithm.</p>\n<p>The code has many repeated lines/blocks, which violates the <a href=\"http://deviq.com/don-t-repeat-yourself/\" rel=\"nofollow noreferrer\"><strong>D<...
{ "AcceptedAnswerId": "268678", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T17:32:08.523", "Id": "268445", "Score": "2", "Tags": [ "javascript", "node.js", "ecmascript-6", "asynchronous", "cache" ], "Title": "Learning asynchronous caching by i...
268445
<p>The TEXTJOIN function has a really nice interface:</p> <pre class="lang-swift prettyprint-override"><code>=TEXTJOIN(delimiter, ignore_empty, text1, [text2], …, [text252]) </code></pre> <p>... where <code>text2</code> onwards are optional args, and each text argument can be a string (hardcoded or function return) <e...
[]
[ { "body": "<p>Very nice! It can be simplified, since you don't need <code>_ReplaceRecursive</code>. I subbed in a <code>REDUCE</code> like this and this and it seems ok, assuming we don't have to escape the tokens.</p>\n<pre><code> REDUCE(\n mask,\n SEQUENCE(ROWS(tokensArray)),\n ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T18:34:14.863", "Id": "268446", "Score": "1", "Tags": [ "array", "vba", "excel", "reinventing-the-wheel", "lambda" ], "Title": "Fancy new LAMBDA functions with variable num...
268446
<p><strong>Problem.</strong></p> <p>I have a directory of <code>.root</code> files (the proprietary format of CERN's <code>ROOT</code> framework). These files contain so-called <code>TTree</code>'s, essentially tables who's cells may contain virtually any <code>c++</code> object or type. In my case, these files contain...
[]
[ { "body": "<h1>Let ROOT read the file for you</h1>\n<p><code>RdataFrame</code>'s constructor can take a filename or a <code>TFile*</code> as an argument, and will read the whole file in for you. This avoids first reading into the temporary vector <code>list</code> and then parsing that list again.</p>\n<h1>Choi...
{ "AcceptedAnswerId": "268453", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T19:54:20.807", "Id": "268449", "Score": "1", "Tags": [ "c++", "performance" ], "Title": "Data processing with the CERN ROOT framework" }
268449
<p>Given a dictionary including multiple X-Y pairs where X, Y are both three dimensional structure. <code>dictionaryBasedNonlocalMean</code> function return a <code>output</code> which is weighted sum of each Y in the dictionary. Each weight of Y are based on the Manhattan distance between the <code>input</code> of <co...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-27T23:58:18.713", "Id": "268454", "Score": "1", "Tags": [ "algorithm", "array", "error-handling", "matrix", "matlab" ], "Title": "Dictionary based non-local mean implementati...
268454
<p>I am working on an e-commerce website. I want to display products in the search result. Here is a subset of what I am doing to display the images.</p> <p>I am using <code>flex</code> to divide the screen into 3 columns and I am using <code>flex-grow-1</code> to make all the cards the same height, here is the code:</...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T00:32:37.630", "Id": "268455", "Score": "0", "Tags": [ "css", "bootstrap-4" ], "Title": "Display product summary for an e-commerce website" }
268455
<p>I just finished Problem 04 on Project Euler, and I was looking at ways to optimize my code, just started learning functions too, so I'm pretty sure it's very bad, hopefully you guys can help me.</p> <p><em><strong>Question</strong></em></p> <p><strong>A palindromic number reads the same both ways. The largest palind...
[]
[ { "body": "<h2>Arithmetic simplification</h2>\n<pre><code>if (a % 1000000 / 100000 == a % 10 &amp;&amp; a % 100000 / 10000 == a % 100 / 10 &amp;&amp;\n a % 10000 / 1000 == a % 1000 / 100) {\n</code></pre>\n<p>An expression like <code>a % 10...0 / 100</code> can be simplified to <code>a / 100 % 10</code>....
{ "AcceptedAnswerId": "268460", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T02:11:08.433", "Id": "268457", "Score": "1", "Tags": [ "java", "beginner", "palindrome" ], "Title": "Optimizing Code for Project Euler Problem 04" }
268457
<p>Almost a month ago I asked for some review of my first attempt at Chess in Python, with the main goal being to start learning inheritance in Python. It can be found here: <a href="https://codereview.stackexchange.com/questions/267644/first-attempt-at-chess-in-python">First attempt at chess in Python</a></p> <p>I fin...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T04:11:02.030", "Id": "268458", "Score": "1", "Tags": [ "python", "python-3.x", "chess" ], "Title": "First attempt at chess in Python #2" }
268458
<p>I'm an intermediate-level C++ programmer aiming to write reference-quality code. I hope to learn about any mistakes in this piece of code and blind spots in my understanding of concepts. Notes:</p> <ul> <li><p>The stylistic use of <code>public:</code>/<code>private:</code> on every member is subject of a <a href="//...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T08:00:33.327", "Id": "529429", "Score": "1", "body": "Given that you asked for advice on the `public:`/`private:` style, why have you _ignored all the answers_ (which unanimously advised against the unusual style you have used)?" ...
[ { "body": "<p>Why do you use <code>S</code> for size type? You can just use <code>std::size_t</code></p>\n<p>nondefault assignment operator with default copy constructor is unidiomatic, just let your assignment operator as <code>DisjointSet&amp; operator=(const DisjointSet&amp; other) = default;</code></p>\n<p>...
{ "AcceptedAnswerId": "268474", "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T06:42:59.333", "Id": "268461", "Score": "5", "Tags": [ "c++", "algorithm", "union-find" ], "Title": "Disjoint-set data structure (C++)" }
268461
<p>I have the below data and am obtaining the expected output column for it.</p> <pre class="lang-none prettyprint-override"><code>DATA EXPECTED_OUTPUT EXPLANATION ---------------------------------------------------------------------------------------------- 123 0000000123 7 leading ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T08:33:52.073", "Id": "529433", "Score": "1", "body": "You might want to look through the answers to [Padding a hexadecimal string with zeros](/q/67611/75307), as it's a very similar problem." }, { "ContentLicense": "CC BY-SA...
[ { "body": "<p>Are you sure you want the non-numeric case to result in <code>None</code>? Pandas more commonly uses <code>NaN</code>. Anyway.</p>\n<p>You're missing an important test case: what do you want to happen for values with a non-zero post-decimal half?</p>\n<p>Option 1 is broken because you're just subs...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T07:01:16.050", "Id": "268462", "Score": "0", "Tags": [ "python", "python-3.x", "comparative-review" ], "Title": "Convert string to 10 character string with leading zeros if necess...
268462
<p>I have written a fully functional simple command line multi-connection downloader, written in Python 3, using just <code>threading</code>, <code>requests</code> and <code>pathlib</code> for its core functionality, plus 19 other libraries for some extra features.</p> <p>I have added resume support and it automaticall...
[]
[ { "body": "<p>Too bad I can't run it because of the Windows parts, but otherwise from\nthe first look of it, it's pretty nice.</p>\n<blockquote>\n<p>How should I format my code?</p>\n</blockquote>\n<p>I'd consider using <a href=\"https://pypi.org/project/black/\" rel=\"nofollow noreferrer\"><code>black</code></...
{ "AcceptedAnswerId": "268566", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T08:18:46.087", "Id": "268465", "Score": "4", "Tags": [ "python", "python-3.x", "multithreading" ], "Title": "Python 3 Multi-connection downloader" }
268465
<p>I am required to code (as part of a 3-question assignment) a variable-size connect 4 board with a standard size of 6x7, with a minimum size of 2x2 and a maximum of 20x20. The professor said that he could do it in 20 lines, and the maximum one can write is 3 times that. My code sits uncomfortably close to it at 58 li...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T08:55:03.320", "Id": "529435", "Score": "1", "body": "Welcome to Code Review! I changed the title so that it describes what the code does per [site goals](/questions/how-to-ask): \"*State what your code does in your title, not your ...
[ { "body": "<p>I was able to do it in just <em>3 lines</em>!</p>\n<p>Here is the code:</p>\n<pre><code>if input('Standard game? (y/n): ') == 'y': r, c = 6, 7\nelse: r, c = int(input('r? (2 - 20): ')), int(input('c? (2 - 20): '))\nprint('\\n'.join([*[str(i).ljust(2) + ' .' + ' .' * (c - 1) for i in range(r)], *[...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T08:42:02.990", "Id": "268466", "Score": "2", "Tags": [ "python", "homework", "connect-four" ], "Title": "Print a Connect 4 board" }
268466
<p>This is my code for a simple used car sales platform, with flex used for the DIVs: <a href="https://jsfiddle.net/m56npe32/" rel="nofollow noreferrer">https://jsfiddle.net/m56npe32/</a></p> <p>I am looking for constructive criticism on how to improve the design, as the entire code works well at a basic level.</p> <p>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T15:55:55.257", "Id": "529459", "Score": "0", "body": "If you want more code than that snippet of HTML reviewed then please expand the code here. [Please embed the code to be reviewed directly in the question](https://codereview.meta...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T11:47:50.850", "Id": "268467", "Score": "0", "Tags": [ "html", "css", "html5" ], "Title": "Simple flex-based design for automotive sales platform in HTML5" }
268467
<p>So I've made a dashboard, and I have alot of colors / icons on this page. One of the things I wanted to get some others view on was the design I've choosen.</p> <p>I use bootstrap background colors: <code>primary, success, danger, warning, dark</code>, so all icons can appear with this background.</p> <p>To change t...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T12:14:53.940", "Id": "268468", "Score": "0", "Tags": [ "html", "css", "svg", "bootstrap-4" ], "Title": "Weather status on dashboard design" }
268468
<pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; int main() { vector&lt;int&gt; primes; int n = 100; // amount of numbers - 1 vector&lt;bool&gt; sieve; for (int i = 0; i &lt;= n; i++) { // creating vector with all true values sieve.push_back(true); } // let's set 0 a...
[]
[ { "body": "<ol>\n<li><p>You are missing <code>std::</code> on some of the elements; it should be:</p>\n<pre><code>std::vector&lt;int&gt; primes;\n</code></pre>\n</li>\n<li><p>Instead of using a <code>for</code> loop to push the values into the <code>vector</code> one at a time, you can use the 'fill' constructo...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T13:02:23.520", "Id": "268469", "Score": "2", "Tags": [ "c++", "sieve-of-eratosthenes" ], "Title": "Sieve of Eratosthenes for primes up to 100" }
268469
<p>I'm creating a few macros that open specific Outlook templates an allow you to replace specific tokens before sending the email. It seems to work, but I'm admittedly doing full loops when I probably don't <em>need to</em>. So I'm just wondering if anyone sees a better way to approach this.</p> <p>As you can see belo...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T14:49:26.373", "Id": "529449", "Score": "1", "body": "The fact that you have to have a comment to describe each variable you're declaring tells me that your variable names aren't very good. For example, `SubjectReplace` could be nam...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T14:30:23.820", "Id": "268471", "Score": "1", "Tags": [ "vba", "outlook" ], "Title": "Outlook VBA to Replace Tokens from an email template" }
268471
<p>I recently started studying C++ programming; while attending the course I'm writing a program on the side as a personal project to familiarize with what I'm learning. It is still very basic and I'm sure that as I begin learning OOP there will be a lot of room for improving it. But for now I would like your feedback ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T15:16:19.620", "Id": "529454", "Score": "0", "body": "Welcome to Code Review! To the best of your knowledge- does the code function as expected? And it would benefit reviewers to have a bit more information about the code in the des...
[ { "body": "<p><a href=\"https://stackoverflow.com/questions/1452721\">Don’t</a> write <code>using namespace std;</code>.</p>\n<p>You can, however, in a CPP file (not H file) or inside a function put individual <code>using std::string;</code> etc. (See <a href=\"https://github.com/isocpp/CppCoreGuidelines/blob/...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T15:02:40.030", "Id": "268472", "Score": "2", "Tags": [ "c++", "performance", "beginner", "c++14" ], "Title": "Fantasy Character Creation Tool (early prototype)" }
268472
<p>This was my <a href="https://codereview.stackexchange.com/questions/268345/tic-tac-toe-in-c-with-classes">previous post</a> on Tic Tac Toe in C++. I received very good feedback and tried to implement all of the improvements. I could not implement some due to the AI needed functions or complexity.</p> <p>I wanted to ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T20:31:41.457", "Id": "529476", "Score": "1", "body": "Generally you should avoid using `friend`. Make the necessary objects `public` or create getters / setters." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2...
[ { "body": "<blockquote>\n<p>Improve my Tic Tac Toe class.\nImprove my AI.\nImprove the UX.</p>\n</blockquote>\n<p>Maybe a redesign of the classes:</p>\n<p>Not sure you have the greatest class break down.</p>\n<p>The TikTakToa class seems to be a class that combines the state of the game the future state for the...
{ "AcceptedAnswerId": "268529", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-28T19:18:53.267", "Id": "268486", "Score": "2", "Tags": [ "c++", "algorithm", "tic-tac-toe", "ai" ], "Title": "C++ - Tic Tac Toe AI powered by minmax algorithm" }
268486
<p>I am working on a quite a big Spring Boot web service and I wanted a standardized and simplified way to handle responses and exceptions by following fluent API design.</p> <p>So this is what I did and it works as I expected.</p> <p>For handling responses, first i created an <code>interface</code> like this,</p> <pre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T20:46:02.160", "Id": "529550", "Score": "0", "body": "All the json responses are composed of two equal named fields and a third field (named error in the error response and data in the success response) ?" }, { "ContentLicen...
[ { "body": "<p>As you are using <code>Spring Boot</code>, the best way to handle you response is to add a <a href=\"https://www.bezkoder.com/spring-boot-restcontrolleradvice/\" rel=\"nofollow noreferrer\">RestControllerAdvice</a>.</p>\n<p>A few rules to follow :</p>\n<ol>\n<li><p>Create custom <code>POJO</code> ...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T05:15:02.260", "Id": "268493", "Score": "0", "Tags": [ "java", "error-handling", "http", "spring", "spring-mvc" ], "Title": "Spring boot: better way to handle response and...
268493
<p>I am currently migrating some code from class-based components to function components using hooks in <em>React</em>. Where I have come across a piece of code that works as expected but there are 3 <em>Axios</em> calls that are dependent on input from the first Axios call.</p> <p>First Axios call returns <em>order am...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T06:38:47.260", "Id": "529492", "Score": "2", "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 sta...
[ { "body": "<p>You can use the async/await syntax, its purpose is exactly cleaning up nested callbacks like this.</p>\n", "comments": [ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T07:55:21.780", "Id": "529499", "Score": "0", "body": "I have ad...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T05:19:10.370", "Id": "268494", "Score": "0", "Tags": [ "javascript", "react.js", "axios" ], "Title": "How to deal with nested callbacks in a clean way?" }
268494
<p>A project of mine required me to search for certain workbooks in open instances of Excel. I found this article <a href="http://exceldevelopmentplatform.blogspot.com/2019/01/vba-code-to-get-excel-word-powerpoint.html" rel="nofollow noreferrer">Code to get Excel, Word, PowerPoint from window handle</a> which returns ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T12:22:08.357", "Id": "529514", "Score": "2", "body": "_\"No where in the code is the full array used, only the first element\"_ actually since you pass the first element `ByRef riid As Any` what you're actually supplying is a pointe...
[ { "body": "<blockquote>\n<pre><code>Public Declare PtrSafe Function AccessibleObjectFromWindow Lib &quot;oleacc&quot; (ByVal hwnd As LongPtr, ByVal dwId As LongPtr, ByRef riid As Any, ByRef ppvObject As Object) As LongPtr\nPublic Declare PtrSafe Function FindWindowEx Lib &quot;USER32&quot; Alias &quot;FindWindo...
{ "AcceptedAnswerId": "268545", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T09:46:56.423", "Id": "268498", "Score": "3", "Tags": [ "vba", "excel", "winapi" ], "Title": "Collecting all instances of an Office application (Excel, PowerPoint, Word)" }
268498
<p>I'm just getting to know the possibilities of Kotlin and mongoDB.<br /> I am writing a method that returns the name of the street after the ID.<br /> Everything works, but I find it quite sloppy.<br /> Empty String initialization, returning more data from the collection than I would like. How do I straighten it? Cou...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-04T01:02:54.557", "Id": "529812", "Score": "0", "body": "I don't use mongo, but this doesn't look like it would even work. You modify `streetName` with an asynchronous callback, so you're returning the original empty String before the ...
[ { "body": "<p>This is how it would look in <strong>Java</strong>:</p>\n<pre class=\"lang-java prettyprint-override\"><code>public String getStreetNameByStreetId(String id) {\n Query streetNameByStreetId = Query.query(\n Criteria.where(&quot;_id&quot;).is(id));\n byStreetId.fields().include(&quo...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T12:08:23.397", "Id": "268499", "Score": "1", "Tags": [ "database", "kotlin", "spring", "mongodb" ], "Title": "Cleaning Kotlin method which returns the document name after the ...
268499
<p>I have a React hook &quot;useFetchSales&quot; that fetches all documents from the &quot;sales&quot; collection in Firestore:</p> <pre class="lang-js prettyprint-override"><code>import { useState, useEffect } from 'react'; import db from &quot;../firebase.config&quot;; import { collection, query, onSnapshot, orderBy ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T13:25:31.930", "Id": "268504", "Score": "0", "Tags": [ "javascript", "react.js", "asynchronous" ], "Title": "Overly complex code for a seemingly simple idea. Fulfilled promises re...
268504
<p>I'm using the <code>logging</code> module in python and I need a function or class method which logs only if some condition is false, similar to <code>assert</code> but logging a message instead of raising an exception.</p> <p>In order to still be able to use the condition in <code>if</code>, <code>while</code>, <co...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T13:56:52.007", "Id": "268505", "Score": "0", "Tags": [ "python-3.x", "logging" ], "Title": "Pass-through conditional logging" }
268505
<p>I was messing around with the csv package and I tried to implement a class that returns csv objects whenever I need to open a csv file directly from a url(and occasionally prints out something).I am still very green and I would like to know if there is something I can do to optimize this code.You are going to find t...
[]
[ { "body": "<p>This is doing too much. You're trying to support reading rows as both a list and a dict; both printing and not; and reading all lines or some lines.</p>\n<p>Change the class name to follow <a href=\"https://www.python.org/dev/peps/pep-0008/\" rel=\"nofollow noreferrer\">PEP 8</a>.</p>\n<p>Drop mos...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T14:14:30.187", "Id": "268506", "Score": "1", "Tags": [ "python", "object-oriented" ], "Title": "optimization csv from url analyzer" }
268506
<p>Below there is a full code for my app Staff Manager. The app does allow basic staff management, like adding, removing or changing details of employees. As it is one of my first GUI apps and I am self-taught (I have been learning for about 6 months now, a couple of hours every day after work) I would like to see what...
[]
[ { "body": "<h1>PEP 8</h1>\n<p>You deviate from the <a href=\"https://www.python.org/dev/peps/pep-0008/\" rel=\"nofollow noreferrer\">Style Guide for Python Code</a> in a couple of areas:</p>\n<ul>\n<li>Keyword arguments should not have spaces around the equals. For example\n<pre><code>add = ttk.Button(self, te...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T15:50:13.127", "Id": "268508", "Score": "3", "Tags": [ "python", "beginner", "python-3.x", "tkinter" ], "Title": "Staff Manager Windows APP -Python" }
268508
<p>So, I've written this small calculator for computing the volumetric weight of a parcel. I've been trying to kick some bad habits to the kerb lately so I was wondering if I could get a code review. Specifically, I'm hoping you lovely people could point out/correct my pitfalls in this example.</p> <p><strong>Here's th...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T16:42:55.437", "Id": "268509", "Score": "1", "Tags": [ "jquery", "html", "css" ], "Title": "Here's my attempt at a Volumetric Weight Calculator (in cm). How did I do?" }
268509
<p>This is my solution for <a href="https://leetcode.com/problems/zigzag-conversion" rel="nofollow noreferrer">ZigZag Conversion</a>, a coding challenge from LeetCode.</p> <p>The challenge:</p> <blockquote> <p>Write a program that takes two parameters, a string and a number of rows, that interprets the string as if it ...
[]
[ { "body": "<ul>\n<li><p>DRY. Every path through the loop ends up in</p>\n<pre><code> dict_copy = a_dict.copy()\n a_lst.append(dict_copy)\n a_dict.clear()\n</code></pre>\n<p>Lift it out out of the conditionals. You will also immediately see that the branches <co...
{ "AcceptedAnswerId": "268555", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T17:29:24.167", "Id": "268511", "Score": "3", "Tags": [ "python", "programming-challenge", "hash-map" ], "Title": "ZigZag Conversion Coding Challenge" }
268511
<p>I'm using <a href="https://the-odds-api.com/liveapi/guides/v4/#overview" rel="noreferrer">this API</a> to get information on sports-betting odds. I am then processing it in Python to discard the irrelevant information.</p> <p>Here's what the response looks like:</p> <pre class="lang-json prettyprint-override"><code>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T23:07:23.200", "Id": "529557", "Score": "0", "body": "I notice that the values for `spread` and `over_under_line` are not set in many of your code paths. That means you will get lots of garbage in your `odds`." } ]
[ { "body": "<p>I don't think you win something by avoiding loops in that case...</p>\n<p>Personally, I probably would just introduce a <code>namedtuple</code>, extract the processing of each <code>game</code> record to a function and use <a href=\"https://docs.python.org/3/library/stdtypes.html#dict.get\" rel=\"...
{ "AcceptedAnswerId": "268527", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T18:25:53.537", "Id": "268512", "Score": "8", "Tags": [ "python", "json", "api" ], "Title": "Efficiently parsing JSON response data in python" }
268512
<p>I built a class in C#, <code>DiscountManager</code>, which is responsible for calculating a customer discount based on years of loyalty. I want to refactor it and am seeking any suggestions for conciseness and efficiency.</p> <pre><code>public class DiscountManager { public decimal Calculate(decimal amount, int ty...
[]
[ { "body": "<p>Try to keep your calculations consistent.</p>\n\n<pre class=\"lang-cs prettyprint-override\"><code>price * 0.9m\n</code></pre>\n<p>Is the same as</p>\n\n<pre class=\"lang-cs prettyprint-override\"><code>(price - (0.1m * price))\n</code></pre>\n<p>Based on this you could have simplified it to the f...
{ "AcceptedAnswerId": "268526", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T18:32:29.997", "Id": "268513", "Score": "-1", "Tags": [ "c#", "formatting" ], "Title": "DiscountManager class in C#" }
268513
<p>I have a simple program that matches words with descriptions. The program should do the following.</p> <ol> <li>Allow a user to enter a set of inputs: keys and descriptions.</li> <li>When the user clicks generate html a textarea should be created with html to be rendered in the word matching exercise.</li> <li>When ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T19:46:35.703", "Id": "268518", "Score": "2", "Tags": [ "javascript", "html" ], "Title": "Word Matching Exercise Game" }
268518
<p>I inserted this code snippet in the functions.php of my child theme, to create the woocommerce single product page in the hook woocommerce_after_single_variation of the custom icons in line centered on the text, without using css, everything works, but I ask you much more experienced if that's okay, or could you do ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T20:38:44.087", "Id": "268520", "Score": "2", "Tags": [ "wordpress" ], "Title": "Added custom woocommerce product page hook" }
268520
<p>Saw <a href="https://codereview.stackexchange.com/q/268436/507">this question</a> and though I wanted to try.</p> <p>So my version of reading Mine Sweeper: For the <a href="https://onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;category=0&amp;problem=1130&amp;mosmsg=Submissio...
[]
[ { "body": "<p>It looks good to me, but there are a few things I would suggest changing.</p>\n<h2>Make <code>index</code> static</h2>\n<p>The <code>index</code> function only uses <code>maxSize</code> from the class and does not alter the class, so I would suggest making it <code>static</code>.</p>\n<h2>Prefer a...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T20:53:31.407", "Id": "268521", "Score": "5", "Tags": [ "c++", "c++17", "rags-to-riches", "minesweeper" ], "Title": "C++ Mine Sweeper Attempt" }
268521
<p>I have a working solution for the problem below. I have the feeling that it could be improved using memoization, but I cannot see how to do it.</p> <p>The problem:</p> <p>You are given an array arr of N integers. For each index i, you are required to determine the number of contiguous subarrays that fulfill the foll...
[]
[ { "body": "<p>Starting from your main question <em>My solution (Is it O(n^2) time complexity?)</em> the answer is <em>yes</em> because for every element of the array you are looking for elements at the left and at the right of it so the complexity of your algorithm is quadratic. You can erase from your code the...
{ "AcceptedAnswerId": "268571", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T22:03:55.850", "Id": "268522", "Score": "0", "Tags": [ "javascript", "array" ], "Title": "Is it possible to get a better performance using memoization? Array algorithm" }
268522
<h2>Motivation</h2> <p>While working on a completely unrelated task, I wanted to share a screenshot of my current Emacs frame, but <em>not</em> of the actual text contents. And while GIMP's pixelate filter did the job, I didn't want to fire up my image manipulation program just to share a picture of a custom theme or s...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T08:03:27.033", "Id": "529575", "Score": "0", "body": "Looks good to me - sorry I don't have any suggestions to improve it!" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T08:56:35.363", "Id": "529...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T22:12:44.757", "Id": "268523", "Score": "2", "Tags": [ "lisp", "elisp" ], "Title": "Hide your text with colorful blocks in secret(-mode)" }
268523
<p>I'm working on a personal project to build a website that quizzes users on chess opening theory moves. I know my code is not very object-oriented but I am working on refactoring it right now. I just wanted to get the basics of it working before I started to restructure everything.</p> <p>Here is the <a href="https:/...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T07:57:52.127", "Id": "529574", "Score": "1", "body": "Welcome to Code Review! I changed the title so that it describes what the code does per [site goals](/questions/how-to-ask): \"*State what your code does in your title, not your ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-29T23:24:11.003", "Id": "268524", "Score": "1", "Tags": [ "javascript", "jquery", "html", "chess" ], "Title": "Chess quiz web site" }
268524
<p>I do have my code running but again I'm wondering if there is a nicer solution since mine seems to be clumsy and I'm wondering if there is a better way like chaining (but I can't work out how to do that)</p> <p>What I want to do is: <strong>for each element in data.lines</strong> replace properties &quot;<strong>fro...
[]
[ { "body": "<p>You're using <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map\" rel=\"nofollow noreferrer\">map</a> and <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter\" rel=\"nofollow noreferrer\">filter</...
{ "AcceptedAnswerId": "268535", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T09:39:00.507", "Id": "268532", "Score": "0", "Tags": [ "javascript", "array", "iteration" ], "Title": "Add Properties from one array of Objects to another array of Objects bas...
268532
<p>I primarily work with C#, and when working with an array of arrays, I can sum the length of the sub arrays using Linq:</p> <pre><code>var myArray = new int[2][] { new int[3] { 1, 2, 3 }, new int[4] { 1, 2, 3, 4 } }; myArray.Sum(s =&gt; s.Length); </code></pre> <p>Printing the result of that sum to a console ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T04:33:56.660", "Id": "529622", "Score": "4", "body": "For the sake of completeness: the analogous javascript would be `myArray.map(a => a.length).reduce((a, b) => a + b, 0)`" }, { "ContentLicense": "CC BY-SA 4.0", "Creat...
[ { "body": "<p>the simple way is to flatten out the array then get the length as it flattens out all the array.</p>\n<pre><code>let myArray = [ [1, 2, 3], [1, 2, 3, 4] ];\nconsole.log(myArray.flat().length);\n</code></pre>\n<p>That will output 7.</p>\n", "comments": [], "meta_data": { "CommentCount...
{ "AcceptedAnswerId": "268540", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T15:22:31.643", "Id": "268536", "Score": "4", "Tags": [ "javascript", "array" ], "Title": "Is there a simpler way to sum the lengths of arrays within an array of arrays in JavaScri...
268536
<p>The task is to read in a data file containing a representation of a rectangular array with '*' signifying a mine and '.' signifying the absence of one. Each such array is preceded by a row and column count. The file is terminated with an entry that has zero for both the row and column counts. The expected output ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:30:28.440", "Id": "529601", "Score": "0", "body": "What is the processor, memory size and OS on your computer?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:46:54.420", "Id": "529605", ...
[ { "body": "<h1>Consider using an array of rows</h1>\n<p>The idea to use pointers into buffer is a good one, as swapping those pointers around is quite fast. However, instead of using three distinct variables to hold those pointers, consider storing them in an array:</p>\n<pre><code>std::array&lt;char *, 3&gt; r...
{ "AcceptedAnswerId": "268548", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T15:50:52.083", "Id": "268539", "Score": "9", "Tags": [ "c++", "programming-challenge", "c++17", "minesweeper" ], "Title": "Yet another minesweeper field calculator" }
268539
<p>I have a directory that includes a number of subdirectories. Each subdirectories contains subdirectories of its own. I'd like to construct a list of all sub-subdirectories in python. Here is my attempt:</p> <pre><code>import os list_of_lists = [[sub_dir + '/' + sub_subdir for sub_subdir in os.listdir(my_dir + '/' ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T23:08:20.753", "Id": "529620", "Score": "1", "body": "Your example has only two levels. Do you care about deeper hierarchy?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T10:05:14.500", "Id": "52...
[ { "body": "<p>The os module provides many functions to interact with operating system features, and one such method is <code>os.walk()</code>, which generates and fetch the files and folders in a directory tree. It can traverse the tree either top-down or bottom-up search, and by default, it sets as top-down se...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T16:23:50.120", "Id": "268541", "Score": "0", "Tags": [ "python", "file-system" ], "Title": "Efficient way to construct list of sub-subdirectories in python" }
268541
<p>I'm writing a task list tracker with VueJS. Each task has a <code>Frequency</code> label (How often it needs to be done), Last completed date label (When the task was completed last) and a <code>Due Date</code> label which tells the user when a particular task needs to be done.</p> <p>The code below is used to updat...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:05:43.557", "Id": "529597", "Score": "0", "body": "\"Today\", \"tomorrow\", etc., these depend on the timezone (for example, \"in 5 hours\" can be today if it's 13:00 in my timezone, but will be tomorrow if it's 23:00). Is it OK ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T16:37:54.527", "Id": "268542", "Score": "3", "Tags": [ "javascript", "datetime" ], "Title": "Calculate difference between dates and output desired result like (Today, Tomorrow, or 20 ...
268542
<p>Here is my take at a lightweight interface implementation, where I focus on discoverability of suitable classes from strings (for simplicity, class name is used as an id). Each interface has it's own &quot;registry&quot; of implementations.</p> <p>My choice of <code>abc</code> module is due to presence of registrati...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:31:45.223", "Id": "529602", "Score": "0", "body": "I like the simplicity of the `InterfaceMeta`, but why not build this on `typing.Protocol` instead? The interface-checking logic itself would be more or less the same, but with th...
[ { "body": "<h2>Initial impressions</h2>\n<ul>\n<li>Re-using the ABC registration system is a nice idea. Note that this will not raise any errors at class <em>definition</em> time, only at <em>instantiation</em> time.\n<ul>\n<li>I personally think is a mis-feature of ABCs and not really your fault, but maybe you...
{ "AcceptedAnswerId": "268551", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:16:12.663", "Id": "268544", "Score": "3", "Tags": [ "python-3.x", "interface", "meta-programming" ], "Title": "Lightweight interface implementation in Python 3 using abstra...
268544
<p>I have a function which takes one argument, a fraction, and returns two numbers - an <strong>integer</strong> and a <strong>power of two</strong>.</p> <ul> <li>So, when you divide the the <strong>integer</strong> by 2 raised to power <strong>power of two</strong>, you get the original number. For example, When I run...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T11:50:29.337", "Id": "529662", "Score": "0", "body": "You are hopefully aware that floating point numbers are merely an approximation. Floating point deviations will be enlarged and so on. A typed language might be better, should yo...
[ { "body": "<ul>\n<li><p><code>get_whole_number</code> looks like a misnomer. The function does not <em>get a whoe number</em>. Rather, it deconstructs the float into a mantissa and exponent, and returns both. <code>deconstruct_float</code> could be better. Even better is to reuse the names for the <a href=\"/qu...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:25:23.717", "Id": "268546", "Score": "0", "Tags": [ "javascript", "floating-point" ], "Title": "Convert a fraction into a whole number and a binary exponent (eg 3.125 => 25, 3)" }
268546
<p>I came upon <a href="https://www.youtube.com/watch?v=5xuvqBjRkok" rel="nofollow noreferrer">this</a> Youtube video and the problem they discussed piqued my interest, so I decided to take a stab at it. Below is the question:</p> <blockquote> <p>Given an array of unique characters <code>arr</code> and a string <code>s...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T04:45:41.687", "Id": "529623", "Score": "0", "body": "In your code, `arr = new char[] {'x','y','z'}; str = \"xxyyzz\";` results in `zyx`. I don't see how `zyx` (or `xyz` after fixing a trivial bug) can be a substring of `xxyyzz`." ...
[ { "body": "<h2>Algorithm issue 1</h2>\n<p>Your code is not correct. You're not getting the substrings. You're getting a list of the first occurrence of each character, and pasting those values together (in reverse order, for some reason) as if they were a substring.</p>\n<p>Try the following test case:</p>\n<pr...
{ "AcceptedAnswerId": "268701", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T17:32:55.440", "Id": "268547", "Score": "2", "Tags": [ "c#", "performance", "algorithm", "strings" ], "Title": "Algorithmic Efficiency: GetShortestUniqueSubstring implemen...
268547
<p>After finally having enough of the hacky batch-based workflow for a project, I tried &quot;porting&quot; it to Maven. This is my first time using a build tool for Java, so there's probably a lot of room for improvement.</p> <h3>General setup</h3> <pre><code>B:\WORKSPACE\COM.MSGPROGRAMS.AUDIRAS │ .classpath │ .pr...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T18:24:03.763", "Id": "268549", "Score": "1", "Tags": [ "java", "maven" ], "Title": "Building a native package using Maven" }
268549
<p>I am attempting to write a light script to deal with multiple package installation in Octave. The available packages can be checked in <a href="https://octave.sourceforge.io/packages.php" rel="nofollow noreferrer">Octave Forge</a> or <a href="https://en.wikipedia.org/wiki/GNU_Octave#Packages" rel="nofollow noreferre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-02T00:43:47.447", "Id": "529712", "Score": "1", "body": "You don’t need `eval`, you can just do `pkg('install', '-forge', Packages{1, i})`" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-04T23:46:01.533", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-09-30T23:48:53.533", "Id": "268554", "Score": "0", "Tags": [ "strings", "error-handling", "installer", "octave" ], "Title": "Batch installing packages script in Octave" }
268554
<p>The <code>sep</code> function separates <code>string</code> by the characters of <code>seps</code>, but it escapes the separates that are in quotes, like:</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; sep(&quot;a b c d 'e f' g h&quot;, ' ') ['a', 'b', 'c', &quot;'e f'&quot;, 'g', 'h'] </code></pr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T13:38:00.557", "Id": "529667", "Score": "3", "body": "Have you looked at profiling your function as starting point? https://docs.python.org/3/library/profile.html" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "...
[ { "body": "<p>There are a couple of different ways you might want to explore if you're looking for optimization opportunities here.</p>\n<p>To start off, consider that if you have <code>&quot;a b c d 'e f' g h&quot;</code> as an input string, you can save yourself a potentially hefty amount of effort simply ski...
{ "AcceptedAnswerId": "268576", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T05:04:06.063", "Id": "268557", "Score": "6", "Tags": [ "python", "performance", "strings" ], "Title": "A string separator that doesn't separate if in quotes" }
268557
<p>In my application, I'm using <code>std::wstring_convert</code> to convert <code>std::string</code> into <code>std::u32string</code>. As this is very frequently done, I want to use a custom allocator to improve performance (and to learn more about C++).</p> <p>Therefore, I wrote a custom allocator which allocates 2 b...
[]
[ { "body": "<p><code>assert(sizeof(U) == sizeof(T));</code><br />\nTry <code>static_assert</code> instead since these types are known at compile time!</p>\n<p><code>typedef std::wstring_convert&lt;std::codecvt_utf8&lt;char32_t&gt;, char32_t, StringConverterAllocator&lt;char32_t&gt;, StringConverterAllocator&lt;c...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T12:06:45.887", "Id": "268563", "Score": "2", "Tags": [ "c++", "performance", "c++17" ], "Title": "C++ allocator for std::wstring_convert" }
268563
<p>I was trying to emulate python's <code>timeit</code> in C++. My main aim for this is to measure the performance of small functions of C++ code that I write and print some basic stats like avg., min, max.</p> <h3>Code:</h3> <p><code>ctimeit.h</code>:</p> <pre><code>#ifndef CTIMEIT_H #define CTIMEIT_H #include &lt;ch...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T13:01:42.357", "Id": "529664", "Score": "1", "body": "The example output (with exact nanoseconds) suggests that you're trying to show more precision than your platform provides." }, { "ContentLicense": "CC BY-SA 4.0", "C...
[ { "body": "<p>I'm guessing <code>int64_t</code> is intended to be <code>std::int64_t</code>? Don't assume that all compilers declare these types in the global namespace as well as <code>std</code>. If <code>std::int64_t</code> is present, it's declared in <code>&lt;cstdint&gt;</code>, so be sure to include th...
{ "AcceptedAnswerId": "268570", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T12:13:39.403", "Id": "268564", "Score": "7", "Tags": [ "c++", "benchmarking" ], "Title": "Measuring execution time of a function" }
268564
<p>I am not a Ruby developer but cold-reading existing Jekyll plugins I implemented one to bundle files in a zip archive and <a href="https://github.com/PhilLab/jekyll-zip-bundler" rel="nofollow noreferrer">open sourced it on GitHub</a>.</p> <p>What do I need to fix to make it look more Ruby-native and/or Jekyll-native...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-11-01T16:16:57.760", "Id": "531957", "Score": "1", "body": "I have rolled back Rev 2 → 1. Please see [_What to do when someone answers_](https://codereview.stackexchange.com/help/someone-answers)." } ]
[ { "body": "<h1>Consistency</h1>\n<p>Sometimes you use <code>snake_case</code>, sometimes you use <code>camelCase</code> for methods and local variables. Sometime you use single-quoted strings and sometimes you use double-quoted strings.</p>\n<p>You should choose one style and stick with it. If you are editing s...
{ "AcceptedAnswerId": "268860", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T16:44:32.173", "Id": "268574", "Score": "4", "Tags": [ "ruby", "plugin", "jekyll" ], "Title": "Jekyll plugin which bundles files into a zip archive" }
268574
<p>I have this handler for my API endpoint <code>/api/universities</code>. My main concern is the overall quality of the code and the efficiency of my use of <code>append()</code>. I haven't been able to come up with a better way of storing the responses and returning them without using a slice &amp; <code>append()</co...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-10-01T21:09:35.237", "Id": "268580", "Score": "0", "Tags": [ "performance", "json", "go", "mongodb" ], "Title": "API handler to retrieve universities from MongoDB" }
268580