body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I've created an on-demand class that can be initiated to collected any new data written to file from <code>start_recording</code> call until <code>stop_recording</code> which close the connection and retrieve the collected data so far.</p> <p>It uses in test cases for obtaining relevant logs during the time where a ...
[]
[ { "body": "<p>Your <code>linesplit</code> repeats a little bit of code; you could phrase it as</p>\n<pre><code>while True:\n buffer_bytes = socket.recv(4096)\n if len(buffer_bytes) == 0:\n break\n buffer_string = buffer_bytes.decode('utf-8')\n *lines, buffer_string = buffer_string.split('\\n'...
{ "AcceptedAnswerId": "265553", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T10:59:18.943", "Id": "265545", "Score": "3", "Tags": [ "python", "python-3.x", "linux", "integration-testing" ], "Title": "remote file follow using python" }
265545
<p>As part of a larger project I'm writing to learn C++, I'm trying to read through some almost-XML files generated by another program. Unfortunately this program uses its own custom escaping logic, so some of these files aren't actually valid XML. As far as I can tell, its escape logic works like this:</p> <ul> <li>At...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T16:31:22.743", "Id": "524506", "Score": "0", "body": "This isn't really an XML question. It's about a proprietary data syntax that has some resemblances to XML, but you can't use any XML tooling, so this doesn't help you." }, { ...
[ { "body": "<h1>Use <code>enum class</code></h1>\n<p>Consider using <a href=\"https://en.cppreference.com/w/cpp/language/enum#Scoped_enumerations\" rel=\"nofollow noreferrer\"><code>enum class</code></a> instead of a plain <code>enum</code> for a little more type safety.</p>\n<p>I would also recommend you use al...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T13:13:41.297", "Id": "265550", "Score": "4", "Tags": [ "c++", "beginner", "parsing" ], "Title": "Preprocessing invalid xml before feeding it to a parser" }
265550
<p>I want to create a function that takes a numpy array, an axis and an index of that axis and returns the array with the index on the specified axis fixed. What I thought is to create a string that change dynamically and then is evaluated as an index slicing in the array (as showed in <a href="https://stackoverflow.c...
[]
[ { "body": "<ul>\n<li>Avoid <code>eval</code> at all costs</li>\n<li>Use the <code>slice</code> built-in for your <code>:</code> components, or the numeric index at the selected axis</li>\n<li>Do not abbreviate your variable names</li>\n<li>Type-hint your function signature</li>\n<li>Turn your example into somet...
{ "AcceptedAnswerId": "265604", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T14:35:05.840", "Id": "265551", "Score": "3", "Tags": [ "python", "numpy" ], "Title": "Dynamically indexing numpy array" }
265551
<p>This is an effect to augment juggling videos:</p> <p><a href="https://i.stack.imgur.com/KTcV4.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KTcV4.gif" alt="output" /></a></p> <p>The goal of this effect is to add a rainbow trail to a video using a tracked set of points.</p> <p><a href="https://dr...
[]
[ { "body": "<p>This is SO COOL. Some minor improvements:</p>\n<p><code>from scipy.signal import savgol_filter</code> should be moved to the top of the file</p>\n<p>You should be moving your global code into subroutines.</p>\n<p><code>distance</code> can be replaced with the built-in <code>np.linalg.norm</code>.<...
{ "AcceptedAnswerId": "265554", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T14:52:01.647", "Id": "265552", "Score": "5", "Tags": [ "python", "opencv", "scipy", "video" ], "Title": "Rainbow Trails Video Effect" }
265552
<p>I created this sample and wanted any advice on how to make this code; cleaner, more effective, just overall better! I am collecting the days data from the NegativeScheduleSentence model and ScheduleSentencePart model and removing the model from the concepts object. only to have to re-add them back in using the days...
[]
[ { "body": "<ul>\n<li>Type names should be written in PascalCase (<code>class Concepts</code>). Variables should be written in camelCase (<code>negativeScheduleSentence</code>).</li>\n<li>All the public fields should be properties (PascalCase).</li>\n<li><code>concepts.NegativeScheduleSentencePartModel</code> an...
{ "AcceptedAnswerId": "265564", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T16:44:07.047", "Id": "265559", "Score": "0", "Tags": [ "c#" ], "Title": "Collecting data from list and then removing" }
265559
<h1>Aim of the Code:</h1> <p>The aim of the function I'm working on is to take a particular column from a DataFrame that contains multiple <code>&lt;tag&gt;&lt;content&gt;</code> pairs in the form of a string and expand them into individual columns in an efficient way.</p> <p>An example file can be found <a href="https...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T14:55:19.433", "Id": "524972", "Score": "1", "body": "Incorporating advice from an answer into the question violates the question-and-answer nature of this site. You could post improved code as a new question, as an answer, or as a...
[ { "body": "<p>I've prepared a code snippet to solve your problem:</p>\n<pre><code>import pandas as pd\nfrom tqdm import tqdm\nimport datetime as dt\n\ndef convert_data(input_file_path):\n print(f&quot;converting file: {input_file_path}&quot;)\n output = []\n with open(input_file_path) as f:\n fo...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T16:49:41.877", "Id": "265561", "Score": "3", "Tags": [ "python", "performance", "pandas" ], "Title": "Pandas split column into multiple: performance improvement" }
265561
<p>I have a Item Service that is Called from an Asp.Net Core API Controller. The query gets all items in a particular category for display on an eCommerce web site (reactjs). The controller only returns json:</p> <pre><code> public async Task&lt;IEnumerable&lt;EcommerceItemDto&gt;&gt; GetAllItemsAsync(string custome...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T19:30:16.863", "Id": "524527", "Score": "0", "body": "Please follow our title guidance: https://codereview.stackexchange.com/help/how-to-ask" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T02:33:23.14...
[ { "body": "<p>I followed all the recommendations from RedGate's Sql Prompt (Modified my view to the one recommended change):</p>\n<pre class=\"lang-sql prettyprint-override\"><code>SET ANSI_NULLS ON\nGO\n\nSET QUOTED_IDENTIFIER ON\nGO\n\nALTER VIEW [cp].[GetEcommerceItemsView]\nAS\nSELECT\n RTRIM(LTRIM(IV.IT...
{ "AcceptedAnswerId": "265587", "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T16:56:39.597", "Id": "265562", "Score": "0", "Tags": [ "c#", "performance", "asp.net-core", "entity-framework-core" ], "Title": "Finding items involving a particular categ...
265562
<p>the introduction is this:</p> <blockquote> <p>You are a member of a biotechnology programming team that is responsible for creating a system for lab technicians, which will assist them with drug analysis.</p> <p>Your goal is to create the application that will let them input their findings into the system, provide a...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T19:14:05.133", "Id": "524526", "Score": "4", "body": "Welcome to Code Review (again)! The current question title, which states your concerns about the code, is too general to be useful here. Simply deleting your [old question](htt...
[ { "body": "<p>I don't know about how these scores are being figured, so I can't say what would improve your score. Your code looks like an OK &quot;face value&quot; implementation of the spec, with <s>two</s> three details &quot;wrong&quot;.</p>\n<ol>\n<li>The spec doesn't say that the addition operation should...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T17:55:51.483", "Id": "265563", "Score": "0", "Tags": [ "python", "python-3.x", "interview-questions" ], "Title": "Interview: Drug Analyzer class" }
265563
<p>So I built a house recently and didn't want to rely on &quot;privacy-questionnable&quot; systems like Google Home or Amazon whatever so I decided to build a doorbell system myself.</p> <h3>Hardware</h3> <p>I use a RPI4B+ as doorbell hardware and MQTT as communication platform between my home server, the doorbell har...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T19:06:02.870", "Id": "265566", "Score": "7", "Tags": [ "c++", "c++17", "qt", "qml" ], "Title": "A simple Qt + MQTT doorbell application" }
265566
<p>I am writing a web application (Servlets, JDBC, no Spring - for learning purposes) that accepts orders from customers, while registered couriers can choose which one of these orders they want to deliver. Several couriers may want to deliver the same order, in which case the system creates a contest and sets the dead...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T06:36:44.713", "Id": "524611", "Score": "0", "body": "Welcome to Stack Review, in the withdraw method the synchronized is really necessary ?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T13:35:39.69...
[ { "body": "<ul>\n<li>Naming: Uppercase names are usually reserved for constants.</li>\n<li>addOrCreate :\nWhy are you checking orderId twice? computeIfAbsent will check if the orderid is there, there is no performance or any other gain in doing it beforehand. Then you are getting it for the third time, however...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T21:01:42.800", "Id": "265567", "Score": "2", "Tags": [ "java", "concurrency", "servlets" ], "Title": "Correct synchronization of reads and writes to ConcurrentHashMap and Concurre...
265567
<p>I was working on <a href="https://leetcode.com/problems/kth-largest-element-in-an-array/" rel="nofollow noreferrer">kth largest element problem on leetcode</a></p> <h2>Question</h2> <p>Given an integer array nums and an integer k, return the kth largest element in the array.</p> <p>Note that it is the kth largest el...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T01:26:08.507", "Id": "524539", "Score": "2", "body": "Am I calculating the time complexity incorrectly? - Yes. You presume that `k` is fixed (or small compared to `n`). Only then the conclusion `kO(n) ~ O(n)` holds. In the worst cas...
[ { "body": "<p>You need to be observant of the bounds in the problem description, in particular they allow k=n which means your worst case time complexity is <em>not</em> constant k times O(n), it's actually O(kn), and when k is approximately n, then it turns into O(n^2).</p>\n<p>I solved a similar problem a whi...
{ "AcceptedAnswerId": "265573", "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-30T21:50:49.880", "Id": "265568", "Score": "1", "Tags": [ "java", "performance", "algorithm", "programming-challenge" ], "Title": "Leetcode kth largest element without using ...
265568
<p>Although there exists the most efficient &quot;Knuth-Morris-Pratt&quot; algorithm of string pattern matching. I tried to achieve the same result with a different approach. But I am not sure about it's efficiency. I am a novice in programming. Can anyone show me how to analyze this algorithm and find it's efficiency?...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T12:51:46.810", "Id": "524619", "Score": "1", "body": "In the future it would be better to add a follow up question with a link back to the original question rather than editing the question. Changing the question may cause answer in...
[ { "body": "<p>A couple of comments on your answer:</p>\n<h1>Code style</h1>\n<ul>\n<li><p>If you've already stored the <code>pattern.length()</code>, why keep calling the method? Just be consistent and use that variable. Same goes for <code>str.length()</code>. I'd just store it and use it.</p>\n</li>\n<li><p>I...
{ "AcceptedAnswerId": "265580", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T13:59:33.837", "Id": "265575", "Score": "4", "Tags": [ "java", "algorithm", "strings", "pattern-matching" ], "Title": "A different approach to string pattern matching algo...
265575
<p>Have been constructing an array that can be used to populate options to find. <code>${incl[@]}</code> made from function parameter arguments that takes filename suffixes.</p> <pre><code># get parameter arguments (&quot;--incl&quot;) incl+=(&quot;$2&quot;) ; shift 2 ;; # file type suffix </code></pre> <p>Example u...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T14:19:24.737", "Id": "524563", "Score": "0", "body": "Is this a good way for an if condition `[[ -z \"$fs\" && \"$ext\" == *\"$fs\"* ]]`. If I remember, one can also introduce parentheses. So it becomes `[[ (-z \"$fs\") && (\"$ext\...
[ { "body": "<p>The code the variable <code>s</code> that splits according to the value of <code>fs</code>.\nA more compact implementation is to use the variable <code>s</code>, then decide whether to split tho value of <code>s</code>, or not.</p>\n<p>Thus, the following code</p>\n<pre><code> isufx=( '(' )\n\n ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T14:15:58.853", "Id": "265576", "Score": "0", "Tags": [ "bash" ], "Title": "Handling field separator option" }
265576
<h2>What my program does</h2> <p>My program does simulation for fantasy football. Its inputs are teams and teams results in a particular match and its outputs are how many points each team earned in each match according to given scoring rules.</p> <p><em>Here is an example of a team:</em></p> <pre><code>team1 = [ c...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T17:05:27.307", "Id": "524837", "Score": "0", "body": "Have you run a profiler on the code to find where to optimize? It seems like there is more code that is not shown. Presumably there is code to get the player and game stats from ...
[ { "body": "<p>I don't think that your <code>Scoring</code> class is a great place to store constants. (Even if it was, a regular class with statics would be a better fit than a singleton dataclass.) If you wanted to do something like this, make a module instead of a class to get a cheap namespace. Given how the...
{ "AcceptedAnswerId": "265585", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-31T17:02:57.390", "Id": "265581", "Score": "3", "Tags": [ "python", "performance", "cython" ], "Title": "Fantasy Football (Soccer) Simulation" }
265581
<p>I recently learned about Finite State Machines (FSM) and thought I'd use that to implement a Reverse Polish Notation (RPN) calculator.</p> <p>I wanted it to also work nicely with the unix pipe. For example, if we have an input file with a set of RPN expressions, I can do something like:</p> <p><code>$ cat file.txt |...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T08:37:00.370", "Id": "524614", "Score": "1", "body": "Obviously you'd use `<` to take input from a file, rather than pulling out `cat` for that!" } ]
[ { "body": "<p>Here are some things that may help you improve your program.</p>\n<h2>Make sure you have all required <code>#include</code>s</h2>\n<p>The code uses <code>strcpy</code> but doesn't <code>#include &lt;string.h&gt;</code>.</p>\n<h2>Use a <code>switch</code> instead of long <code>if ...else</code> cha...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T02:21:36.440", "Id": "265591", "Score": "5", "Tags": [ "c", "calculator" ], "Title": "Reverse Polish Notation in C (using a Finite State Machine)" }
265591
<p>I am making a program about numbers. The user will enter a number and will get its properties.</p> <h3>Program objectives</h3> <ol> <li>Welcome users;</li> <li>Display the instructions;</li> <li>Ask for a request;</li> <li>If a user enters zero, terminate the program;</li> <li>If numbers are not natural, print the e...
[]
[ { "body": "<p>As far as I can understand, you're a beginner lacking some knowledge. But the job is done well. Some considerations:</p>\n<h3>Comments</h3>\n<p>A perfect code should use identifier names to avoid comments; your code have good names and one unneeded comment at the beginning. But, on the other hand,...
{ "AcceptedAnswerId": "265598", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T05:33:02.353", "Id": "265592", "Score": "3", "Tags": [ "java" ], "Title": "Determine number properties" }
265592
<p>I am trying to time <a href="https://en.wikipedia.org/wiki/Radix_sort" rel="nofollow noreferrer">radix sort</a> on 128 bit unsigned integers for different base sizes (that I call bitwidth). My code has at least the following problems:</p> <ul> <li>The radix sort itself may run slower than it would otherwise as the ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T09:24:03.260", "Id": "524615", "Score": "1", "body": "The problem is the 0xff. That needs fixing" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T13:52:30.573", "Id": "524628", "Score": "0", ...
[ { "body": "<p>There's an opaque magic number here, that reduces portability:</p>\n<blockquote>\n<pre><code> putchar(48+(int)(u%10));\n</code></pre>\n</blockquote>\n<p>I think that was intended to be <code>'0'</code>, and we unnecessarily created an ASCII-only program.</p>\n<p>This function might be better if i...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T07:26:18.400", "Id": "265593", "Score": "4", "Tags": [ "c", "benchmarking", "radix-sort" ], "Title": "Radix sort with benchmarks" }
265593
<h3>Background</h3> <p>I'm interested in implementing a small script to display multiple independent instances of a Canvas-based control on one page. The ultimate intention is to add many similar controls to the same page, so efficiency is helpful.</p> <h3>Inspiration Code</h3> <p>Here is the <a href="https://github.co...
[]
[ { "body": "<h2>Review</h2>\n<p>There are bugs and the code is accessibly noisy.</p>\n<h2>Style</h2>\n<p>Some source code style points</p>\n<ul>\n<li><p>Avoid unneeded code as it is just noise. Code noise makes code harder to read amd maintain.</p>\n<ul>\n<li><p>The script tag default type is <code>&quot;text/ja...
{ "AcceptedAnswerId": "265618", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T14:11:49.677", "Id": "265599", "Score": "2", "Tags": [ "javascript", "beginner", "canvas" ], "Title": "Generate Multiple Instances of Canvas-based UI Object" }
265599
<p>As a C++ newbie, I am practicing my C++ skill by implement games in <a href="https://www.atariarchives.org/basicgames/" rel="nofollow noreferrer">BASIC Computer Games</a> and here is my C++ version for <a href="https://www.atariarchives.org/basicgames/showpage.php?page=15" rel="nofollow noreferrer">Battle</a>.</p> <...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T14:25:34.903", "Id": "524629", "Score": "0", "body": "Are you really stuck with C++11? That's pretty archaic these days." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T14:30:04.883", "Id": "5246...
[ { "body": "<p>The code is not bad, but I see some things that may help you improve it.</p>\n<h2>Check your spelling</h2>\n<p>There are some typos and peculiar capitalization in the strings displayed for the user. For instance &quot;gut&quot; should probably be &quot;guys,&quot; &quot;InValid&quot; should be &q...
{ "AcceptedAnswerId": "265609", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T14:22:22.540", "Id": "265600", "Score": "3", "Tags": [ "c++", "battleship" ], "Title": "BASIC Computer Games: Battle in C++" }
265600
<p>In one of my personal python libraries I have a custom class used for computing the running average and variance of a stream of numbers:</p> <pre><code>import numpy as np class RunningStatsVariable: def __init__(self, ddof=0, parallel=None): self.mean = 0 self.var = 0 self.std = 0 ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T17:34:04.030", "Id": "265605", "Score": "1", "Tags": [ "python", "multithreading", "thread-safety", "multiprocessing" ], "Title": "Thread-safe running mean and variance" }
265605
<p>This code needs to extract data from in XML file. Specifically it needs to iterate over it, looking for a node called <code>CHARGE_CODES</code> that repeats over and over and has several elements. it needs to extract the values of one of them, called <code>CODE</code>. the XML contents are composed of repeating bloc...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T18:56:19.740", "Id": "524642", "Score": "1", "body": "That looks a lot like something that XPath is well suited to. You might find that the subset of XPath support in [`xml.etree.ElementTree`](https://docs.python.org/3/library/xml....
[]
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T18:22:52.450", "Id": "265607", "Score": "1", "Tags": [ "java", "xml", "dom" ], "Title": "Extract series of XML elements' values into an array" }
265607
<p>Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them from smallest to largest so that each statue will be bigger than the previous one exactly by 1. He may need some addit...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T20:01:35.793", "Id": "524644", "Score": "0", "body": "Welcome back to Code Review, please add the link to the programming challenge in your question." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T20...
[ { "body": "<h1>Indentation</h1>\n<p>You indentation is inconsistent. <code>int count =0;</code> is not indented the same amount as the following line, despite being logically at the same level.</p>\n<p>Your indentation amount is not consistent. You should use the same increment for each additional level. Ass...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T19:37:25.850", "Id": "265610", "Score": "3", "Tags": [ "java", "programming-challenge" ], "Title": "Make Array Consecutive" }
265610
<p>I'm starting to learn about networking and as a project I am building a really simple DNS client in Rust.</p> <p>Functionality to start was just to take a command line domain argument and sending a DNS A record request to the google DNS server (8.8.8.8:53).</p> <p>The application works right now (when compared to ou...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T21:37:34.063", "Id": "265615", "Score": "4", "Tags": [ "rust", "networking", "bitwise" ], "Title": "Barebones DNS Client in Rust" }
265615
<p>So I am once again beating a dead horse, by solving the <a href="https://projecteuler.net/problem=1" rel="nofollow noreferrer">first Project Euler problem</a>:</p> <blockquote> <p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.</p> <p>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T19:21:48.723", "Id": "524739", "Score": "1", "body": "No need for the helpers. This can be done as a single reduce: `[...Array(1000).keys()].reduce((m,x)=> m + ((x % 3 == 0 || x % 5 == 0) ? x : 0))`." } ]
[ { "body": "<p>You can definitely reduce the length of some of your variable names without losing any readability:</p>\n<pre><code>const pipe = (...functions) =&gt; value =&gt;\n functions.reduce((currValue, currFunc) =&gt; currFunc(currValue), value)\n</code></pre>\n<p>Could be:</p>\n<pre><code>const pipe = (....
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-01T22:55:33.170", "Id": "265616", "Score": "2", "Tags": [ "javascript", "programming-challenge", "functional-programming" ], "Title": "Project Euler 1 using functional programming in...
265616
<p>File: InfoFactory.h contains four classes.</p> <ol> <li><code>CaffienatedBeverage</code> is an Abstract class with one pure virtual function <code>Name</code>. It also contains some data members that are used to make a coffee based drink and name of the drink.</li> <li><code>Latte</code> is a class that inherits <co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T07:47:45.750", "Id": "524664", "Score": "0", "body": "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 main concerns about it.*...
[ { "body": "<h2>Memory management and cleanup with inheritance</h2>\n<p>Objects allocated with <code>new</code> must be cleaned up by calling <code>delete</code>. In this case the <code>beverage</code> object is never cleaned up. In modern (and not so modern) C++ we should use a <code>std::unique_ptr</code> inst...
{ "AcceptedAnswerId": "265624", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T06:51:47.740", "Id": "265621", "Score": "2", "Tags": [ "c++", "object-oriented", "c++11", "design-patterns", "factory-method" ], "Title": "Factory Method Design Patter...
265621
<p>The original purpose of this script was saving data to a local file, which is still the primary purpose.</p> <p>Since I may only obtain one copy of a data stream (not this particular Coinbase one; it's just a free example), I'd like to add a secondary purpose using websockets to mirror the data for a Python web-serv...
[]
[ { "body": "<p>I'm not familiar with how <code>websocket</code> works, but from your code I think I can infer it. So here a few comments:</p>\n<p>It seems your subscribers list depends on currently opened connections. That is bad practise. The first reason being, HTTP sessions have a timeout. Hence, after a whil...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T08:04:19.560", "Id": "265623", "Score": "1", "Tags": [ "python", "async-await", "websocket" ], "Title": "Adding websocket functionality to send live data from a Python script. Any...
265623
<p>I am trying to use Scrapy for one of the sites I've scraped before using Selenium over <a href="https://codereview.stackexchange.com/questions/263373/requests-vs-selenium-vs-scrapy">here</a>.</p> <p>Because the search field for this site is dynamically generated and requires the user to hover the cursor over a butto...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T16:08:45.943", "Id": "524728", "Score": "0", "body": "I think for this to be on topic, you're going to need to excise the part that doesn't work." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T06:16:...
[ { "body": "<blockquote>\n<p>the search field for this site is dynamically generated</p>\n</blockquote>\n<p>That doesn't matter, since - if you bypass the UI - the form field name itself is not dynamic. Even if you were to keep using Selenium, it should be possible to write an element selector that does not need...
{ "AcceptedAnswerId": "265668", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T09:33:20.043", "Id": "265627", "Score": "3", "Tags": [ "python", "web-scraping", "beautifulsoup", "selenium", "scrapy" ], "Title": "Scraping a dynamic website with Scr...
265627
<p>File - DatabaseOperations.h</p> <p>This file contain classes representing database operations for three different types of databases (relational, document based and graph based) like establishing connections, executing statements, and committing and closing the connections.</p> <p>There are four abstract classes wit...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T06:45:52.907", "Id": "524772", "Score": "0", "body": "I have rolled back your last edit. Please don't change or add to the code in your question after you have received answers. See [What should I do when someone answers my question...
[ { "body": "<blockquote>\n<p>Does the above code implements the Abstract Factory design pattern correctly?</p>\n</blockquote>\n<p>No.</p>\n<p>First, it is wildly overcomplicated. It seems ridiculous to need <em>four</em> different class hierarchies just to do a database transaction.</p>\n<p>Second, it is just pl...
{ "AcceptedAnswerId": "265640", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T10:11:07.503", "Id": "265629", "Score": "0", "Tags": [ "c++", "c++11", "design-patterns", "abstract-factory" ], "Title": "The Abstract Factory design pattern as a Database...
265629
<p>I have a model of Author which has books, awards and pricing as shown below (Not showing getters and setter just to avoid verbosity)</p> <p>Author: Has books and prices for the books</p> <pre><code>public class Author { private long id; private String name; private Set&lt;Book&gt; books; private Set&lt;Pric...
[]
[ { "body": "<p>Here are a few comments on your code:</p>\n<h1>Business objects</h1>\n<p>If the business objects' model is given, there is nothing to do here. Otherwise, just the way you have described it:</p>\n<blockquote>\n<p>Price - Price of book (Can have multiple prices for same book...</p>\n</blockquote>\n<...
{ "AcceptedAnswerId": "265638", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T11:39:54.763", "Id": "265631", "Score": "2", "Tags": [ "java" ], "Title": "Efficient usage of Java Stream API to convert one object to another" }
265631
<p>Could someone say if this kind of contextual binding for plugins has a point?</p> <pre class="lang-csharp prettyprint-override"><code> //it is a AbstractModule code public abstract class AbstractModule : Module { private ContainerBuilder _containerBuilder; protected AbstractBinderBehavior Binder...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T13:07:11.457", "Id": "524679", "Score": "1", "body": "Welcome to the Code Review Community. Are you the author of the code? We can only review code by the author of the code. The more code you post in the question the better the ans...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T12:33:01.510", "Id": "265632", "Score": "0", "Tags": [ "c#", "dependency-injection", "plugin", "autofac" ], "Title": "Contextual binding based on Autafac and caller assembly" ...
265632
<p>I'm working on a card game using Amethyst's Specs crate and am fairly new to Rust (therefore I'm learning through the fight with the compiler). My first <code>System</code> is to deal the cards to each player. I have:</p> <ul> <li>a <code>Card</code> type that has <code>Copy</code> semantics</li> <li>a <code>Cards</...
[]
[ { "body": "<p>I'm not familiar with ECS or some of the types you used in your code, and to be honest I don't think I quite understand your code as it seems incomplete, but this seems like something that could be fixed by using the <a href=\"https://doc.rust-lang.org/std/rc/struct.Rc.html\" rel=\"nofollow norefe...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T12:58:22.183", "Id": "265633", "Score": "0", "Tags": [ "game", "rust" ], "Title": "Avoiding cloning references in a Specs system" }
265633
<p>I want to make the code below prettier but I don't know what to change and how to change. I know that the controller should be easy, delegating actions related to models or to services or something else.</p> <p>The task the code below solves is to authenticate a client with 2 factory authentication. If a client has ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T14:57:36.407", "Id": "524692", "Score": "2", "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 actually think you are doing it ok. You made the choice to test a number of conditions in a logical order and <strong>return early</strong> in case of failure. Thus each test takes only a few lines of code and is clearly delimited. The control flow is easy to grasp.</p>\n<p>You could have done i...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T14:44:42.563", "Id": "265635", "Score": "1", "Tags": [ "php", "authentication", "laravel" ], "Title": "Login using two-factor authentication" }
265635
<p>I'm kinda new to C# and Unity, coming from PHP/Python background.<br /> So I'm curious, if this CubeController script <strong>can be considered a bad code</strong>.<br /> I mean the coding style, performance, &amp; overall Unity C# best practices.</p> <p>The code itself is a simple CubeController script.<br /> It ad...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T14:50:56.963", "Id": "265636", "Score": "0", "Tags": [ "c#", "performance", "game", "unity3d" ], "Title": "Unity C# CubeController script (jumping & moving the cube)" }
265636
<p>Im currently working with discord with Python 3.9.6 where I am trying to create a embed based on how much text I have.</p> <p>According to discord:</p> <pre><code>+-------------+------------------------+ | Field | Limit | +-------------+------------------------+ | title | 256 characters ...
[]
[ { "body": "<p>Overall your algorithm is pretty reasonable, but it needs to be pulled out into a function, and type hints will help. Your input type is a sequence since it needs to be indexed, and your output is an iterable.</p>\n<p>Rather than having an <code>if</code> statement that increments or assigns to yo...
{ "AcceptedAnswerId": "265666", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T17:17:29.340", "Id": "265637", "Score": "2", "Tags": [ "python-3.x", "discord" ], "Title": "Split message when too many character" }
265637
<p>A quick and dirty line-based approach for detecting duplicated text blocks.</p> <p>Did not find any references as to what (deterministic) algorithms are there for detecting duplicated text blocks, so went with the most straightforward way: take the biggest possible text block starting from fist line + 1 to the botto...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T20:33:58.233", "Id": "524698", "Score": "8", "body": "It would be helpful to add some test cases. So far it looks like an instance of a [longest repeated substring](https://en.wikipedia.org/wiki/Longest_repeated_substring_problem) p...
[ { "body": "<p>This approach will work, but be slow. You will be comparing something like N**2.5 lines in the worst case, which is quite bad. You should be running in something more like linear time.</p>\n<p>The biggest problem I see here is that your problem is not well-defined, so first clarify your problem to...
{ "AcceptedAnswerId": "266472", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-02T18:53:37.190", "Id": "265639", "Score": "1", "Tags": [ "python", "algorithm" ], "Title": "Remove duplicated multiline blocks in text" }
265639
<p>I am learning data structures and below is my implementation of a stack in JavaScript. I didn't want to use built in functions for an array because in JavaScript that would be too easy, so I made my own.</p> <pre><code>class Stack { constructor(data=null) { this.items = [data] this.length = 0 } push(...
[]
[ { "body": "<p>You have a bug in your constructor:</p>\n<pre><code>constructor(data=null) {\n this.items = [data]\n this.length = 0\n }\n</code></pre>\n<p>If you pass an item and then push to the stack, you lose the first item:</p>\n<pre><code>let myStack = new Stack(&quot;123&quot;);\nmyStack.push(&quot;...
{ "AcceptedAnswerId": "265649", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T02:08:49.593", "Id": "265646", "Score": "4", "Tags": [ "javascript", "reinventing-the-wheel", "stack" ], "Title": "Stack Implementation in JavaScript" }
265646
<p>I am a new F# programmer, and a student in a security class. As part of my notes, I wrote a small implementation of a monoalphabetic cipher as follows:</p> <pre class="lang-fs prettyprint-override"><code>open System let random = Random() let defaultCharMap() = ['a' .. 'z'] @ ['A' .. 'Z'] @ ['0' .. '9'] let ran...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T11:10:54.530", "Id": "524887", "Score": "0", "body": "Undoubtedly not for production use, but `Random` is not a cryptographically secure RNG." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T11:41:01.8...
[ { "body": "<p>Your code looks good in terms of being idiomatic functional-ish F#. </p>\n<p>I do still have some suggestions:</p>\n<ul>\n<li><p><code>defaultCharMap</code> is a function that always returns the same value. Therefore it might as well be a plain module-level value instead. This will mean it's evalu...
{ "AcceptedAnswerId": "265660", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T06:48:14.180", "Id": "265650", "Score": "2", "Tags": [ "functional-programming", "f#", "caesar-cipher" ], "Title": "F# simple monoalphabetic cipher code implementation" }
265650
<p>I've been experimenting with the <a href="https://tryfsharp.fsbolero.io/" rel="nofollow noreferrer">F# Bolero</a> environment to learn F# a bit and I was trying to get the hang of pattern matching by generating ordinal numbers (1st, 2nd, 3rd, ...) from cardinal numbers (1, 2, 3, ...).</p> <p>Here's the code I came u...
[]
[ { "body": "<p>You can combine both cases with an if .. then .. else ..</p>\n<pre><code>let ordinal n =\n match if n &gt; 20 then n % 10 else n % 20 with\n | 1 -&gt; string n + &quot;st&quot;\n | 2 -&gt; string n + &quot;nd&quot;\n | 3 -&gt; string n + &quot;rd&quot;\n | _ -&gt; string n + &quot;t...
{ "AcceptedAnswerId": "265664", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T10:23:41.553", "Id": "265656", "Score": "0", "Tags": [ "beginner", "functional-programming", "f#", "pattern-matching" ], "Title": "Cardinal to ordinal numbers in F# code r...
265656
<p>As this is a very basic word wrap program, it has at least the following 3 limitations :-</p> <ol> <li>The file should have a terminating newline.</li> <li>The column number at which the lines are to be wrapped must be greater than or equal to the length of the longest word.</li> <li>Tabs (<code>\t</code>) should no...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T16:34:40.233", "Id": "524834", "Score": "1", "body": "Yes that is a good fix as `while (getc(fp) != '\\n')` is a potential infinite loop should `get()` return a `EOF` due to a rare input error (even if file has a final `'\\n'`)." ...
[ { "body": "<p><strong>Readability</strong></p>\n<p>Your (ab)use of the comma operator is detrimental to program readability. It is <em>extremely</em> easy for a reader of your code to miss the fact that you have two expressions on one line. Reformat your code to have one statement (expression) on a line, and m...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T13:55:11.367", "Id": "265661", "Score": "7", "Tags": [ "c", "formatting", "io" ], "Title": "Word wrap with file input & ouput" }
265661
<p>I'm developing a screen recording as an application log. The recording should capture a full HD screen at 25fps and on request it should save last 60 seconds of record. It is for embedded app, but the app is built for 32 bit and during development the recording app threw OutOfMemory exception during video generating...
[]
[ { "body": "<p>I don't think this is the best way of capturing the screen, but I'll leave it to someone with more experience in the area to comment on that.\nWhat I will comment on are rather obvious performance issues assuming the overall code stays as it is:</p>\n<ul>\n<li><p>List&lt;Tuple&lt;byte[], DateTime&...
{ "AcceptedAnswerId": "265678", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T14:30:17.097", "Id": "265662", "Score": "2", "Tags": [ "c#", "performance", "image", "memory-optimization", "video" ], "Title": "C# screen recording" }
265662
<p>I'm using C#, .NET Core and the entity framework and am currently working on optimizing various functions for better performance.</p> <p>One of the main functions is getting a calculation based on two indexes; a product and machine. The records in this database table is currently at 500 rows but can go upwards to 10...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T10:03:58.313", "Id": "524792", "Score": "1", "body": "Specify the exact version of the Entity Framework. Remove the asp.net tag." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T10:06:44.450", "Id"...
[ { "body": "<p>When using EF, it would be better if you query the database then create a list of the results. in <code>GetCalculationByProduct</code> method, see this line :</p>\n<pre><code>IList&lt;Calculation&gt; calculations = _calculationRepository.Index().ToList();\n</code></pre>\n<p>at this line, it will p...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T14:50:50.043", "Id": "265663", "Score": "0", "Tags": [ "c#", "linq", "entity-framework" ], "Title": "Efficiency of finding one database record using two ID's" }
265663
<p>I'm trying to perform a 4-dimensional numerical integration in <code>R</code> using a function I wrote in <code>C++</code> code which is then sourced in <code>R</code> using the <code>Rcpp</code> package.</p> <p>Below there is my code:</p> <pre><code>// [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends(RcppNumerical)]...
[]
[ { "body": "<h1>Sources of slowness</h1>\n<p>The actual calculations you are doing are fine, I don't see anything you can optimize that the compiler won't already do for you itself. The main overhead will be caused by R repeatedly having to call <code>integral_CppFunctionCUBATURE()</code>. The first issue I see ...
{ "AcceptedAnswerId": "265674", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T16:43:34.860", "Id": "265667", "Score": "3", "Tags": [ "c++", "performance", "numerical-methods", "rcpp" ], "Title": "Implementation of Multidimensional numerical integrat...
265667
<p>So I made an inverted index following a tutorial online and was wondering if I can improve it by implementing one or more algorithms or reduce code or maybe make the processing files faster. I am using .txt files as data which there is not a lot of files but if the there is then this inverted index might not be that...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T20:27:00.443", "Id": "265676", "Score": "0", "Tags": [ "python", "python-3.x", "algorithm", "search" ], "Title": "Simple Inverted Index made in python" }
265676
<p>So I've started writing an OS to know how they work, and I came up with the following makefile to compile it.</p> <p>The reason I used a makefile is because I wanted to <em>see</em> everything it was doing and have full control over it, to be as explicit as possible. Hence, please don't tell me about CMake (I don't ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T21:56:22.160", "Id": "524748", "Score": "0", "body": "By the way, this was detected as spam... Any idea why? (I saw [here](https://meta.stackexchange.com/questions/311147/this-looks-like-spam-error-message-when-attempting-to-ask-a-n...
[ { "body": "<p>Here are some things that may help you improve your code.</p>\n<h2>Understand your tools</h2>\n<p>There are a huge number of redundant compiler warnings that serve little purpose except to clutter up the Makefile. I would recommend trimming that to the smallest possible non-redundant equivalent. ...
{ "AcceptedAnswerId": "265682", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T21:54:12.770", "Id": "265679", "Score": "2", "Tags": [ "makefile", "kernel" ], "Title": "Makefile to compile an OS which also uses functions/macros" }
265679
<p>This is poorly written Java code, intended to implement a thread-safe collection to store Member objects and failing at doing so.</p> <pre><code>import javax.annotation.concurrent.ThreadSafe; import java.io.Closeable; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.HashS...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T01:42:52.883", "Id": "524753", "Score": "0", "body": "I'm not sure where you think thread-safety is an issue." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T01:49:40.310", "Id": "524754", "Sc...
[ { "body": "<h2>Thread Unsafe</h2>\n<p>It's not thread-safe. <code>addMember(Member member)</code> directly calls <code>members.add(member);</code> with <code>members</code> being a <code>HashSet</code>. And its documentation says</p>\n<blockquote>\n<p>Note that this implementation is not synchronized. If multip...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-03T23:43:49.727", "Id": "265681", "Score": "-2", "Tags": [ "java", "multithreading", "thread-safety" ], "Title": "Thread-safe collection to store Member objects" }
265681
<p>This is the second time I am writing any practical JavaScript so it is pretty likely that I have messed something up.</p> <p>I am beginner, so just need a piece of advice before sharing the code: Do I need to be more focused on writing maintainable and flexible code or do I need to be more focused on writing as conc...
[]
[ { "body": "<blockquote>\n<p>I am practicing for maintainable and flexible code. Is it right thing to do?</p>\n</blockquote>\n<p>Yes!</p>\n<p>Delivering loads of javascript to the client can be slow, but the way to solve is this is not by writing worse code. You solve it by minifying/uglyfying, chunking, tree sh...
{ "AcceptedAnswerId": "265709", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T01:27:20.870", "Id": "265684", "Score": "3", "Tags": [ "javascript", "strings", "functional-programming" ], "Title": "garbage string remover with array or object input" }
265684
<p>I implemented a simple Java virtual machine in C.<br /> Here it is: <a href="https://github.com/phillbush/jvm" rel="nofollow noreferrer">https://github.com/phillbush/jvm</a><br /> It includes two programs: javap(1), a Java disassembler; and java(1), the JVM itself.<br /> It does not have a garbage collector nor exce...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T14:55:15.520", "Id": "524818", "Score": "2", "body": "Despite the char limit the rule is also that we only review code that is included directly into the question. If it is too much, consider splitting up your code into multiple rev...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T01:45:02.150", "Id": "265685", "Score": "0", "Tags": [ "c" ], "Title": "Class file reader for simple java virtual machine" }
265685
<p>I was trying to implement a generic PriorityQueue in C#. Below is my implementation which works fine as per few test cases. Operations supported-</p> <ul> <li>Add: Adds an element</li> <li>Poll: Removes the smallest element and returns it</li> <li>Remove: Removes a specific element (only first occurence) and returns...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T06:36:47.933", "Id": "524770", "Score": "1", "body": "Just a small remark: I think `Size` shouldn't have a public setter." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T07:14:32.327", "Id": "5247...
[ { "body": "<blockquote>\n<pre><code>public int Length { get; private set; }\n</code></pre>\n</blockquote>\n<p><code>_elements</code> carries the length already, and duplicate state that you keep in sync manually is a good way to create bugs. Consider implementing the getter as returning <code>_elements.Count</c...
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T02:16:14.177", "Id": "265686", "Score": "2", "Tags": [ "c#", "priority-queue" ], "Title": "Generic PriorityQueue (Min-Heap) implementation" }
265686
<p>I am trying to code up a basic combinatorial math library for C++. Started with the implementation of the factorial function. Here I include the code and the test code. Please review.</p> <ol> <li>Is the way of throwing argument exceptions the best way to do it?</li> <li>Am I using the Test code the correct way for ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T13:48:12.520", "Id": "524810", "Score": "1", "body": "Aside: \"a tabularized approach with gamma functions\" is not an optimization; it's a completely different approach." }, { "ContentLicense": "CC BY-SA 4.0", "Creation...
[ { "body": "<p>We're missing some required headers:</p>\n<pre><code>#include &lt;climits&gt;\n#include &lt;stdexcept&gt;\n#include &lt;string&gt;\n</code></pre>\n\n<pre><code>#include &lt;gtest/gtest.h&gt;\n</code></pre>\n<hr />\n<p>We can reduce the number of division operations here:</p>\n<blockquote>\n<pre><c...
{ "AcceptedAnswerId": "265690", "CommentCount": "10", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T04:35:37.143", "Id": "265688", "Score": "9", "Tags": [ "c++", "beginner" ], "Title": "Factorial function for a math library in C++" }
265688
<p>I have a project where I publish and subscribe some data packages. Mostly those data packages are just one package, but sometimes (1 in 100) there could be more packages at one time (a lot more, like 100.000 at the same time) I have a class <code>PacketTransport</code> which only has a <code>IDataPacket</code> prope...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T09:29:35.257", "Id": "524788", "Score": "3", "body": "It seems like you are worrying about micro optimization. Have you done any performance analyzis to spot the sweets spots / bottleneck of your system? Like via [CodeTrack](https:/...
[ { "body": "<p>The only area I would consider for maintainability of your code is to avoid repeating code i.e. &quot;DRY&quot;.</p>\n<pre><code>public class PacketTransport\n{\n public IEnumerable&lt;IDataPacket&gt; DataPackets { get; }\n\n // constructor chaining\n public PacketTransport(IDataPacket da...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T07:29:20.827", "Id": "265691", "Score": "0", "Tags": [ "c#", ".net", ".net-core" ], "Title": "Using a IEnumerable where we have mostly only one item" }
265691
<p>Component:</p> <pre class="lang-js prettyprint-override"><code>import React from 'react'; interface QuestionsProps {} export default function Questions({ children }: React.PropsWithChildren&lt;QuestionsProps&gt;) { return &lt;div&gt;{children &amp;&amp; React.Children.count(children) &gt; 1 ? children.join('\n')...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T07:48:47.160", "Id": "265693", "Score": "0", "Tags": [ "react.js", "typescript" ], "Title": "React children props array type predicate" }
265693
<p>I have this method that I feel has code repetition that can be improved but since I am new to Go, I am not quite sure how to improve it. I would appreciate if anyone can give me their opinion.</p> <pre><code>func (c *Configuration) loadFromEnvVars(key string, target interface{}, optional bool, defaultValue interface...
[]
[ { "body": "<p>You won't get rid of entirely, you could trade the <code>switch</code> cases for <code>if</code> statements of course:</p>\n<pre class=\"lang-golang prettyprint-override\"><code>func (c *Configuration) loadFromEnvVars(key string, target interface{}, optional bool, defaultValue interface{}) error {...
{ "AcceptedAnswerId": "265700", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T08:13:02.043", "Id": "265695", "Score": "2", "Tags": [ "go" ], "Title": "Loading configuration options from environment or default values" }
265695
<p>Taking forward the combinatorial library <a href="https://codereview.stackexchange.com/questions/265688/factorial-function-for-a-math-library-in-c">link</a>, I have tried to implement the nCr function. Please mention if this is prone to failing somewhere</p> <ol> <li>Any other test code that needs to be added.</li> ...
[]
[ { "body": "<p>I’ll ignore the factorial code, since that was already reviewed in your previous question.</p>\n<p>In <code>combinations()</code>, what would happen if <code>r&gt;n</code>? What if either input is negative? Neither case appears in your test set, and is not tested for in the function either. Unsign...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T15:25:45.430", "Id": "265703", "Score": "1", "Tags": [ "c++", "beginner" ], "Title": "Combination function for a math library in C++" }
265703
<p>I build the Shortest Path to Get All Keys algorithm in JavaScript. It's working properly, but with a really bad performance.</p> <p>The problem:</p> <p>You are given an m x n grid grid where:</p> <p>'.' is an empty cell. '#' is a wall. '@' is the starting point. Lowercase letters represent keys. Uppercase letters re...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T03:41:56.687", "Id": "524866", "Score": "1", "body": "Your code does not work, The code either, ends up in an endless loop (Im guessing as I just killed the page rather than waited) or returns a incorrect distance,. example `[\"@cba...
[ { "body": "<h2>Style</h2>\n<ul>\n<li><p>Always delimit code blocks. eg <code>if (foo) bar()</code> should be <code>if (foo) { bar() }</code></p>\n</li>\n<li><p>Avoid using <code>continue</code></p>\n</li>\n<li><p>Spaces between operators and after commas. Eg <code>pos[0]+d[0]</code> should be <code>pos[0] + d[0...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T16:20:47.840", "Id": "265705", "Score": "0", "Tags": [ "javascript", "algorithm" ], "Title": "Shortest Path to Get All Keys in JavaScript" }
265705
<p>I made a simple BlackJack game and I want to make it as good as possible before I move on to creating a few other games in my &quot;casino&quot; - let me know how I can improve it I added a few things here and there if you are interested my GitHub for this project is linked:</p> <p><a href="https://github.com/sharoi...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T19:36:27.770", "Id": "524846", "Score": "0", "body": "[don't import the standard library (std) in your header file](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice)" } ]
[ { "body": "<pre><code>#include &lt;stdlib.h&gt;\n</code></pre>\n<p>Why are you including the <a href=\"https://en.cppreference.com/w/cpp/header\" rel=\"nofollow noreferrer\">deprecated C header</a>? Why do you need the C header <code>&lt;stdio.h&gt;</code> as well as <code>&lt;iostream&gt;</code>? You would u...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T16:26:50.123", "Id": "265706", "Score": "3", "Tags": [ "c++", "game" ], "Title": "Simple Blackjack Game in c++" }
265706
<p>Currently I am creating an app in Tkinter that creates, displays, and saves sticky notes. I am new to python so I keep trying to rewrite my classes so I have my code more organized but every time I try to create a separate class that inherits from my root class, it quits working properly and won't let me get variabl...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T22:26:00.653", "Id": "524857", "Score": "1", "body": "Your indentation doesn't make much sense starting at `makecolor` and onward. However, by some miracle this all runs as-is, so uh. It's reviewable, but there are going to be some ...
[ { "body": "<p>Overall this is a great start, basically functional, and looks cool.</p>\n<p>Your doing this:</p>\n<p><code>import tkinter as tk</code></p>\n<p>is a good idea - so you should then avoid the next line:</p>\n<p><code>from tkinter import *</code></p>\n<p>as it pollutes your namespace. Using <code>tk....
{ "AcceptedAnswerId": "265714", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T16:39:54.800", "Id": "265707", "Score": "4", "Tags": [ "python", "beginner", "python-3.x", "tkinter", "gui" ], "Title": "Tkinter Sticky Notes" }
265707
<p><strong>Hi Everyone, this is my first bash script ever.</strong> I would really appreciate it if you could provide me with some comments and insights regarding correct function use, logic implementation, and a lead to how to implement the recursive functionality described in the script's body. Thanks a lot!</p> <pre...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T10:23:38.760", "Id": "524882", "Score": "0", "body": "Is that first line really indented like that, or is that due to how you copied the code into the question? I'm asking because the shebang (`#!`) only works if it's the first two...
[ { "body": "<p>Please wrap the comments to a reasonable length. Most terminals aren't that wide.</p>\n<p>In a few places, we have <code>$@</code> where we really needed <code>&quot;$@&quot;</code>, causing the script to fail badly when whitespace is present in the values. We should be using Shellcheck to catch...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T16:53:53.717", "Id": "265708", "Score": "0", "Tags": [ "bash", "linux" ], "Title": "Uncompress files, with autodetection of algorithm" }
265708
<p>I have just finished making a maze maker. I took inspiration from <a href="https://www.youtube.com/watch?v=Y37-gB83HKE" rel="nofollow noreferrer">this</a> video, but its my own implementation. I just wanted to know what you guys thought of it and if there are any improvements that can be made like</p> <ol> <li>Impro...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T06:25:27.183", "Id": "524871", "Score": "0", "body": "The map could be represented more memory efficiently using a smaller datatype such as short or even just a few flags packed into a part of a short/int. In the packed case you wou...
[ { "body": "<h1>Consider making <code>mazevi2d</code> a <code>struct</code>, and rename it</h1>\n<p><code>std::pair</code> is sometimes useful, but the problem is that you access the two elements using <code>.first</code> and <code>.second</code>, and those names are not really describing what you want to do. So...
{ "AcceptedAnswerId": "265723", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T20:23:45.740", "Id": "265710", "Score": "1", "Tags": [ "c++" ], "Title": "General coding style and efficiency of a maze maker" }
265710
<p>This is a still incomplete file manager for X11. It can only navigate through directories, select files (and do nothing with them), call a script to open files, and call a script to produce and cache thumbnails (it uses the imlib2 library to render images).</p> <p>Here is the git repository: <a href="https://github...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T14:54:27.817", "Id": "524907", "Score": "0", "body": "Why did you choose to write a program using Xlib, when X11 (while still perfectly usable IMO), is planned to be phased out in favor of Wayland? Why not use a widget toolkit that ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T23:24:54.327", "Id": "265712", "Score": "3", "Tags": [ "c", "x11" ], "Title": "X11 file manager in C, using Xlib and imlib2" }
265712
<p>This is a simple implementation of the calendar(1) utility included in some UNIX systems (all BSDs have it, GNU has not).</p> <p>Here's the manual:</p> <pre class="lang-none prettyprint-override"><code>CALENDAR(1) General Commands Manual CALENDAR(1) NAME calendar - print upco...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T02:42:18.870", "Id": "524865", "Score": "0", "body": "might be an issue on some platforms. Here's the error on OSX `awk: calling undefined function systime\n source line number 261`" }, { "ContentLicense": "CC BY-SA 4.0", ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-04T23:28:27.870", "Id": "265713", "Score": "0", "Tags": [ "awk" ], "Title": "UNIX calendar(1) in awk" }
265713
<p>Continuing the code for combinatorics library, adding the definition of ⁿPᵣ. This is an extract from a <a href="https://github.com/suryasis-hub/MathLibrary" rel="nofollow noreferrer">larger codebase</a>.</p> <ol> <li>Is there any way to limit the code of <code>gcd()</code> to this file? Should I convert the namespa...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T06:08:33.040", "Id": "524870", "Score": "1", "body": "As a general note unless you are sure that all your users understand what an overflow is you might want to replace that with an more actionable error message." }, { "Cont...
[ { "body": "<p>Unnecessary includes:</p>\n<blockquote>\n<pre><code>#include &quot;pch.h&quot; // in both files\n#include &quot;framework.h&quot;\n#include &lt;iostream&gt; // in both files\n#include &lt;limits&gt;\n</code></pre>\n</blockquote>\n<p>Missing includes:</p>\n<pre><code>// in implementation\n#includ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T03:54:32.360", "Id": "265717", "Score": "3", "Tags": [ "c++", "beginner", "mathematics", "library" ], "Title": "Permutation function for a math library in C++" }
265717
<p>I have applied a DFS solution for to check finding path if exist from beginning point to the end point.</p> <blockquote> <p>OA: Given 2d array, check if there is path from one beginning point to given endpoint in the matrix</p> </blockquote> <pre><code>public class StartToEnd { // OA: Given a 2d matrix with cha...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T06:52:01.270", "Id": "524873", "Score": "1", "body": "how is **beginning point** and **beginning point** defined? What does the assignment in your question have to do with the comments in your class? *OA: Given a 2d matrix with char...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T06:43:13.947", "Id": "265718", "Score": "0", "Tags": [ "java", "matrix", "depth-first-search" ], "Title": "If maze has path" }
265718
<p>These snippets are nothing special, but they remind us to sometimes loop without a <code>for</code> or a <code>while</code> loop. It is even possible to iterate over <code>struct</code> members in a similar manner.</p> <pre><code>template &lt;typename ...A&gt; constexpr auto all_loop(A&amp;&amp; ...a) noexcept { r...
[]
[ { "body": "<h1>No need to return a lambda</h1>\n<p>I don't see the need for returning a lambda which you then have to invoke. Why not pass the function as the first parameter, similar to <a href=\"https://en.cppreference.com/w/cpp/utility/apply\" rel=\"nofollow noreferrer\"><code>std::apply</code></a> and <a hr...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T11:07:38.473", "Id": "265724", "Score": "2", "Tags": [ "c++", "c++17" ], "Title": "looping over variables of heterogeneous type" }
265724
<p>I'm trying to learn how to multithread with c, and thought that the <a href="https://www.geeksforgeeks.org/longest-palindromic-subsequence-dp-12/" rel="nofollow noreferrer">longest palindromic subsequence problem</a> would be a good place to start.</p> <p>The idea is that we run two threads and compare their results...
[]
[ { "body": "<h1>Passing strings to threads</h1>\n<p>You are dynamically allocating <code>struct str</code>s and passing pointers to those structs to the threads. However, the structs could be allocated on the stack instead:</p>\n<pre><code>struct str s0 = {seq0, len};\n...\nif (pthread_create(&amp;t0, NULL, &amp...
{ "AcceptedAnswerId": "265736", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T12:49:22.763", "Id": "265728", "Score": "4", "Tags": [ "c", "multithreading", "palindrome" ], "Title": "Longest Palindromic Subsequence Multithread in C" }
265728
<p>I've done a script to sort fanfics by the bayesian average of views and rating. I've used views because it took much longer to scrape the dlp website for reviews.</p> <p>I leave all the code so that it works. But I'm most interested in the following functions:</p> <pre><code>get_percentile(conn, column, nth) get_top...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T13:02:27.113", "Id": "265729", "Score": "0", "Tags": [ "python", "sorting", "sqlite" ], "Title": "Bayesian ranking of fanfics with python and sqlite" }
265729
<p>I am trying to build on @Reinderien's answer to my previous question over <a href="https://codereview.stackexchange.com/q/265627/242934">here</a> to add page iteration functionality to the code:</p> <pre class="lang-py prettyprint-override"><code>from base64 import b64encode from datetime import date from typing imp...
[]
[ { "body": "<p>Scraping code is often ugly, and this is no exception. There's not much you can do, but it's important to work extra hard to make it readable.</p>\n<p>Error handling is missing (just throws an error), but that's okay if that's what you want. It makes things more readable.</p>\n<p><code>search</cod...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T13:05:57.857", "Id": "265730", "Score": "0", "Tags": [ "python", "web-scraping" ], "Title": "Adding page iteration capability to Requests scraper" }
265730
<p>I'm pretty new to programming and shell and I'm not having any issue with the script below; it's working perfectly but I want to know if I can do better.</p> <p>I'm inserting the content of some CSV files (<code>value1</code>, <code>value2</code>, <code>value3</code>) into an HTML table. I'm using a <code>while</cod...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T13:43:49.133", "Id": "265733", "Score": "0", "Tags": [ "html", "csv", "shell" ], "Title": "displaying contents from CSV files in an HTML table" }
265733
<p>I'm looking for advice on how to improve my code or find some potential bugs. I have a Java app which listen to multiple RabbitMQ queues and process the messages. In the my case I have 5 queues. I have the following consumer class</p> <pre><code>public class ConsumerWorker extends DefaultConsumer { private long s...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T13:56:25.040", "Id": "265734", "Score": "0", "Tags": [ "java", "rabbitmq" ], "Title": "RabbitMQ multiple queues and process the message" }
265734
<p>I'm a new developer just starting out learning HTML, css and JavaScript. Below is my attempt at building a portfolio website.</p> <p>I am finding it difficult positioning elements the way I want to and finding botched ways to do so when there's probably a more cleaner and efficient way of doing so.</p> <p>Any advice...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T15:39:35.043", "Id": "524911", "Score": "0", "body": "Welcome to Code Review! It would benefit reviewers to have a bit more information about the code in the description. From [the help center page _How to ask_](https://codereview.s...
[ { "body": "<p>Just a few words about the JavaScript:</p>\n<ul>\n<li><p>Don't assign event handlers using <code>on...</code> attributes/properties. Use <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener\" rel=\"nofollow noreferrer\"><code>addEventListener</code></a>.</p>\n</l...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T14:26:50.187", "Id": "265735", "Score": "2", "Tags": [ "javascript", "performance", "beginner", "html", "css" ], "Title": "developer portfolio website" }
265735
<h2>Background</h2> <p>Recently, I was making some updates to an &quot;older&quot; library that would handle PATCH-style modifications to an object that is persisted in a JSON format on our document-storage databases (e.g., CosmosDB).</p> <p>I took a fresh approach of this, and started on a blank slate and decided to m...
[]
[ { "body": "<h1>1. Optimize</h1>\n<h2>1.1 Get rid of clones</h2>\n<p>Let's take a look what JsonElement::Clone() does. See <a href=\"https://github.com/dotnet/runtime/blob/b2d5d63e5194265e18c448d7f014585bf0bad2d4/src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonElement.cs#L1440\" rel=\"nofollow n...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T15:24:06.610", "Id": "265739", "Score": "1", "Tags": [ "c#", "json", "dynamic-programming" ], "Title": "Patch a JSON object using dynamic / ExpandoObject with System.Text.Json" }
265739
<p>I have been working with postgresql where I am trying to get information from database, update, exists and much more. I have created a context manager for commit and to close whenever it is in finished.</p> <p>This project is about storing some variables (mostly regarding store and link)</p> <pre class="lang-py pret...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T16:59:07.673", "Id": "524920", "Score": "1", "body": "The title isn't very descriptive of what the code achieves and the description is quite brief. Please [edit] to the site standard, which is for the title to simply state the task...
[ { "body": "<p><code>ps_connection</code> existing as a global is ungood. <code>QuickConnection</code> on its own seems like a reasonable way to spin up a cursor, but would be better-modelled with a connection instance that it owns as a member, not referring to a global. This would also (reasonably) require that...
{ "AcceptedAnswerId": "265745", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T16:30:52.990", "Id": "265741", "Score": "2", "Tags": [ "python-3.x", "sql" ], "Title": "Queries for storing and get information from postgreSQL" }
265741
<p>I decided to make an extension for Spicetify (modified Spotify client). It generates a playlist of similar songs based on their average audio features.</p> <pre><code>//@ts-check // NAME: Feature Shuffle // AUTHOR: CharlieS1103 // DESCRIPTION: Create a playlist based on the average features of a playlist /// &lt;r...
[]
[ { "body": "<ul>\n<li><p>Repeated code: <code>Math.round(num * 100) / 100</code> is constantly repeated. Extract it to a function</p>\n</li>\n<li><p>Nested <code>if</code> statements: You have an awful lot of nested <code>if</code> statements that could be one simple <code>if</code>:</p>\n<pre class=\"lang-js pr...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T18:47:28.010", "Id": "265747", "Score": "2", "Tags": [ "javascript" ], "Title": "Spicetify extension to generate a playlist of songs with similar audio features" }
265747
<p>I've tried to write a version of this problem where it's easy to adapt if there's an additional pair (e. g. Say Bazz for 7). Looking for general advice.</p> <pre class="lang-ml prettyprint-override"><code>type word = Number of int | Vocable of string let string_of_word = function | Number n -&gt; Int.to_string n...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-05T20:14:21.137", "Id": "265749", "Score": "1", "Tags": [ "fizzbuzz", "ocaml" ], "Title": "FizzBuzz in OCaml" }
265749
<p>I have written basic insertion sort in java and I would request you to please spend some time on this code and give me your review of code. Is there anything I could have improved:</p> <pre><code>package elementarySorts; public class InsertionSort { InsertionSort(int [] input_array){ System.out.pri...
[]
[ { "body": "<blockquote>\n<pre><code> InsertionSort(int [] input_array){\n System.out.println(&quot;Unsorted arrey:&quot;);\n for(int elem:input_array) {\n System.out.print(elem +&quot; &quot;);\n }\n sort(input_array);\n }\n</code></pre>\n</blockquote>\n<p>This is a ...
{ "AcceptedAnswerId": "265756", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T00:49:54.663", "Id": "265752", "Score": "0", "Tags": [ "java", "object-oriented", "insertion-sort" ], "Title": "Insertion Sort code in Java" }
265752
<p>Taking forward the code written for the <a href="https://github.com/suryasis-hub/MathLibrary" rel="noreferrer">math library</a> I'm developing. I wrote templatized functions for mean and variance.</p> <ol> <li><p><code>std::accumulate()</code> (or summation in general) is likely to cause overflow. Should I go for an...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T07:26:20.957", "Id": "524949", "Score": "2", "body": "You might want to look at [my implementation of incremental mean and variance](/q/198124/75307), including the reviews I received." }, { "ContentLicense": "CC BY-SA 4.0",...
[ { "body": "<h2>Review</h2>\n<p>Welcome to Code Review. There are some suggestions as follows.</p>\n<h3>Answer your questions</h3>\n<blockquote>\n<p><code>std::accumulate()</code>(or summation in general) is likely to cause overflow. Should I go for an incremental approach?</p>\n</blockquote>\n<p>Why you think t...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T03:04:31.997", "Id": "265753", "Score": "6", "Tags": [ "c++", "beginner", "statistics" ], "Title": "Mean and Variance for Math Library" }
265753
<p>I have a piece of code that downloads acupuncture data from Wikipedia and consolidates it into an acupoint, meridian and extraordinary meridian dictionary stored as .pkl files in the working directory.</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd import wikipedia as wp import json from han...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T08:35:03.823", "Id": "524954", "Score": "0", "body": "Using non-ascii characters for strings and displayable text if ok, but using them for variable names is awful for two reasons: 1- If format is lost, your code may become unrunnab...
[ { "body": "<p>This took me a long time to go through.</p>\n<p>First, re. non-ASCII characters for strings - yes(ish), but it's less important to eliminate non-ASCII characters, and more important to make a consistent codebase whose variables are in English for international collaboration purposes. So it's not h...
{ "AcceptedAnswerId": "265843", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T03:35:35.053", "Id": "265755", "Score": "1", "Tags": [ "python", "database" ], "Title": "Data storage and processing in Python" }
265755
<p>I have been learning SystemVerilog before I go back to school and decided to try and implement a Carry Lookahead Adder. As far as I can tell, it works correctly though I haven't tested extensively, just the tests you see on the testbench. I would like some feedback on best practices, things to avoid, and any other c...
[]
[ { "body": "<p>The layout of your code is good, and you did a good job partitioning the design from the testbench.</p>\n<p>In your design, you could take advantage of the &quot;reduction&quot; operators to make your code more compact and less prone to errors. For example, you could change:</p>\n<pre><code>assig...
{ "AcceptedAnswerId": "265775", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T06:46:18.390", "Id": "265759", "Score": "3", "Tags": [ "verilog", "hdl", "fpga" ], "Title": "Carry Lookahead Adder - SystemVerilog" }
265759
<p>I tried to implement a weighted draw. The idea of which is, you can have disproportionate probabilities of drawing different items. In this particular case, I want to cumulatively bias the probability towards drawing undrawn items. That is, the longer an item hasn't been drawn, the higher its chances become.</p> <p>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T01:34:23.113", "Id": "525019", "Score": "1", "body": "Please give a specific formula for what weights you want. Your problem is a little vague, so it will help while reading the code." }, { "ContentLicense": "CC BY-SA 4.0", ...
[ { "body": "<p>I must admit I have stared at your function for almost an hour now, and I still struggle to comprehend how it works. I think I get the <em>gist</em> of it, but.. Yeah.</p>\n<h3>Readability</h3>\n<p>Global variables are bad in any programming language and hurts readability. See <a href=\"https://st...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T10:05:20.863", "Id": "265765", "Score": "2", "Tags": [ "python", "performance", "python-3.x" ], "Title": "Weighted draw/raffle (biased towards undrawn)" }
265765
<p>I am trying to learn Go concurrency patterns and best practices on my own.<br/> I have invented a simple task for myself.<br/> I want to process a slice of integers in a parallel manner by dividing it into sub-slices and process each with a goroutine.<br/> Below is the solution I have at the moment, I seek construct...
[]
[ { "body": "<p>Looks fine, as you wrote, you don't need <code>simulate_close_signal</code> to be in the wait group since the <code>wg.Wait</code> call will already synchronise the access to <code>slice</code> later for the other two goroutines that write to it.</p>\n<p>Other than that, you might as well make the...
{ "AcceptedAnswerId": "265872", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T10:46:35.853", "Id": "265766", "Score": "1", "Tags": [ "go" ], "Title": "Concurrent processing of a slice" }
265766
<p><a href="https://archive.ics.uci.edu/ml/datasets/iris" rel="nofollow noreferrer">Iris Data Set</a> consists of three classes in which versicolor and virginica are not linearly separable from each other.</p> <p>I constructed a subset for these two classes, here is the code</p> <pre><code>from sklearn.datasets import ...
[]
[ { "body": "<p>This is a very nice little project but there are some thing to upgrade here :)</p>\n<hr />\n<p><strong>Code beautification</strong></p>\n<ol>\n<li>Split everything to functions, there is no reason to put logic outside of a function, including the prediction part (this will remove the code duplicat...
{ "AcceptedAnswerId": "265773", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T11:00:03.783", "Id": "265767", "Score": "0", "Tags": [ "python", "machine-learning" ], "Title": "Logistic Regression for non linearly separable data" }
265767
<p>I work at an application that receives data from user and I try to write a validator function for it, but I'm not sure if this is the correct way to proceed.</p> <p>Example: The user will input a number (as string, don't ask why I don't use an int, let it be a string), let's say &quot;103&quot;, and I'will use this ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T12:33:43.997", "Id": "524963", "Score": "0", "body": "\"an application that receives data from user\" -- what kind of application? In many cases you would be far better off with a relevant NuGet package. Also, why did you tag this \...
[ { "body": "<p>First off, in here</p>\n<pre class=\"lang-csharp prettyprint-override\"><code>if (!String.IsNullOrEmpty(Payload) &amp;&amp; !String.IsNullOrWhiteSpace(Payload))\n</code></pre>\n<p>You only need to do</p>\n<pre class=\"lang-csharp prettyprint-override\"><code>if(!String.IsNullOrWhiteSpace(Payload))...
{ "AcceptedAnswerId": "265772", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T11:33:10.857", "Id": "265770", "Score": "3", "Tags": [ "c#", "validation" ], "Title": "Input Data Validator (good practice)" }
265770
<p>Compared to my another post <a href="https://codereview.stackexchange.com/q/265767/233283">Logistic Regression for non linearly separable data</a> which uses one-layer net, i.e. Logistic Regression to classify the iris data set, this post is to discuss the tensorflow method.</p> <pre><code>iris = load_iris() x_train...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T12:08:34.870", "Id": "525039", "Score": "0", "body": "As I understand from your post (and previous post) you are not looking for a code review, you are looking for a model review. I believe this is not the correct platform for you t...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T11:48:19.897", "Id": "265771", "Score": "1", "Tags": [ "python", "machine-learning", "tensorflow" ], "Title": "The best tensorflow neural net I got so far for iris dataset" }
265771
<p>I am a beginner in C and am learning linked lists. I have made a program to implement a linked list, allowing certain operations on the linked list.</p> <p>There are 3 functions:</p> <ul> <li><code>addnode()</code> adds node to end of list</li> <li><code>printlist()</code> prints the whole linked list</li> <li><cod...
[]
[ { "body": "<p>We're missing includes of the library headers which provide function prototypes:</p>\n<pre><code>#include &lt;stdio.h&gt;\n#include &lt;stdlib.h&gt;\n</code></pre>\n<hr />\n<p>A popular naming convention is to use a distinctive prefix (rather than a suffix) for the function names, so that they app...
{ "AcceptedAnswerId": "265780", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T12:50:20.367", "Id": "265776", "Score": "2", "Tags": [ "c", "linked-list", "pointers" ], "Title": "Linked list - append, insert, print" }
265776
<p>After yesterday suggestions, I was told... recommended to move over to ORM and I did. I choosed to use <strong>PeeWee</strong> together with PostgreSQL. <a href="https://codereview.stackexchange.com/questions/265741/queries-for-storing-and-get-information-from-postgresql?noredirect=1#comment524956_265741">Queries fo...
[]
[ { "body": "<p>I am not familiar with that ORM so at this time I will only provide superficial comments.</p>\n<p>Suggestions anyway:</p>\n<p>Keep all your imports and from ... import on top of the file and group them together.</p>\n<p>Keep your <strong>data model</strong> in a <strong>separate</strong> Python fi...
{ "AcceptedAnswerId": "265803", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T13:23:20.757", "Id": "265777", "Score": "1", "Tags": [ "python-3.x", "postgresql", "peewee" ], "Title": "Queries using ORM and PostgreSQL" }
265777
<p>I've written this <code>Email</code> component which obfuscates the email until the user hovers over it:</p> <pre><code>import React, { AnchorHTMLAttributes, DetailedHTMLProps, ReactNode, useState, } from &quot;react&quot;; import { percentEncodeParams } from &quot;./utils&quot;; function obfuscateEmail(ema...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T08:56:14.820", "Id": "526149", "Score": "1", "body": "Would you be so kind a provide a codesandbox.io working example?\nthats helps aaaaaaaaaalot" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-24T20:51:...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T14:59:31.293", "Id": "265782", "Score": "0", "Tags": [ "react.js", "typescript", "jsx" ], "Title": "Obfuscate email React component" }
265782
<p>I don't have a lot of experience creating/managing an active directory environment. This will be more of a lab environment where a solution could be tested. It will not have lots of regular users etc, just some test internal type users.</p> <p>Part of that, I need to set up a domain controller quickly on Windows 201...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T17:27:36.933", "Id": "524991", "Score": "2", "body": "you may want to look at some of the results from a net search for `powershell autolab`. there appear to be several AD setup routines available. [*grin*]" } ]
[ { "body": "<p>Looking good, thankfully there aren't really any &quot;traps&quot; when creating a new domain via Powershell.</p>\n<p>Couple things to note though:</p>\n<ul>\n<li><p>You may want to install management tools for <code>AD-Domain-Services</code> unless you plan to manage the server remotely only (as ...
{ "AcceptedAnswerId": "267621", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T15:21:23.257", "Id": "265783", "Score": "0", "Tags": [ "windows", "powershell", "active-directory" ], "Title": "powershell script for creating a Domain Controller" }
265783
<p>I have a for which loops for X files, if the current file is the file Y i have to skip it if the condition <code>dcc.payload.v[0].dn === dcc.payload.v[0].sd &amp;&amp; dcc.payload.v[0].dn &gt; 1</code> is true, else i have to make my checks and return the result.</p> <p>The issue is that after adding that new condit...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T15:26:05.993", "Id": "524978", "Score": "5", "body": "Please, update the title so that it shows what your code does, and not what you intend to change about it. That title is too loose for a site like this" } ]
[ { "body": "<p>To reduce duplicated code, just change the condition:</p>\n<pre class=\"lang-js prettyprint-override\"><code>for (const ruleFile of ruleFiles) {\n if (ruleFile !== 'VR-DE-0003.json') \n || dcc.payload.v[0].dn !== dcc.payload.v[0].sd\n || dcc.payload.v[0].dn &lt;= 1) {\nconst rule = Rule.fro...
{ "AcceptedAnswerId": "265786", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T15:21:58.150", "Id": "265784", "Score": "-2", "Tags": [ "javascript" ], "Title": "How to prevent repetitive returns for almost same contitions in IF and ELSE?" }
265784
<p>My generic 3 median quicksort:</p> <pre><code> public class Util { final static int CUTOFF = 27; public static &lt;T extends Comparable&lt;? super T&gt;&gt; void quicksort(T[] a) { quicksort(a, 0, a.length - 1); } private static &lt;T extends Comparable&lt;? super T&gt;&gt; void quicksort(...
[]
[ { "body": "<p>The error was in this line:</p>\n<pre><code> if (low + CUTOFF &gt; high) {\n insertionSort(a);\n</code></pre>\n<p>It should had been</p>\n<pre><code>if (low + CUTOFF &gt; high) {\n insertionSort(a,low,high);\n</code></pre>\n<p>And the corresponding change to insertionSort</p>...
{ "AcceptedAnswerId": "265790", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T16:22:55.337", "Id": "265788", "Score": "1", "Tags": [ "java", "array", "quick-sort" ], "Title": "Java generic 3-median quicksort" }
265788
<p>I made an infinite map in Ursina. The game freezes for a second every time I press 'l' to generate a new area.</p> <p>My <code>Face</code> code:</p> <pre><code>class Face(Button): def __init__(self, position = (0,0,0),block = generate_block((0,0,0))): super().__init__( parent = scene, pos...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T16:44:37.337", "Id": "265789", "Score": "0", "Tags": [ "python", "performance" ], "Title": "Infinite map in Ursina" }
265789
<pre><code>#!/bin/sh #Path where to store saved urls. URL_FILE=&quot;$QUTE_CONFIG_DIR/saved_urls&quot; #Arguments are appended to the url (ie for comments) printf &quot;$QUTE_URL $*\n&quot; &gt;&gt; &quot;$URL_FILE&quot; printf &quot;tab-close&quot; &gt;&gt; &quot;$QUTE_FIFO&quot; </code></pre> <p>I often have lot of...
[]
[ { "body": "<blockquote>\n<pre><code>printf &quot;$QUTE_URL $*\\n&quot;\n</code></pre>\n</blockquote>\n<p>This will want to consume (nonexistent) arguments if the expansion contains a <code>%</code> format specifier, such as <code>%c</code>, <code>%d</code> or <code>%f</code>.</p>\n<p>Instead use <code>printf '%...
{ "AcceptedAnswerId": "265795", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T17:22:41.573", "Id": "265791", "Score": "2", "Tags": [ "sh" ], "Title": "Short (user)script to store current URL and close tab in qutebrowser" }
265791
<p><sub><a href="https://github.com/Greedquest/CodeReviewFiles/blob/master/MVVM_Comparer.xlsm?raw=true" rel="nofollow noreferrer">download</a></sub></p> <hr /> <p>Bit of an esoteric title, but let me explain. I wanted to create an IComparer that can be supplied to a sorting algorithm, which rather than using the <code>...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T18:08:32.473", "Id": "265793", "Score": "0", "Tags": [ "design-patterns", "vba", "sorting", "mvvm", "rubberduck" ], "Title": "GUIComparer with MVVM dialog to allow user in...
265793
<p>I was solving a question on a coding website and this website has a limit for execution time of code. My code takes 1.01 sec but the limit is 1 sec. I am unable to find any changes in my code that can decrease the execution time. Here is the link for the question :- <a href="https://www.codechef.com/AUG21C/problem...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T18:19:58.370", "Id": "524996", "Score": "2", "body": "Codechef likely stopped executing your code after the 1 second mark, meaning your code didn't actually take 1.01 seconds. You'll need to try a different algorithm." }, { ...
[ { "body": "<p>This algorithm is <span class=\"math-container\">\\$\\mathcal{O}(nk)\\$</span> but could be <span class=\"math-container\">\\$\\mathcal{O}(n)\\$</span>.</p>\n<p>It is <span class=\"math-container\">\\$\\mathcal{O}(nk)\\$</span> because you reset <code>j</code> <code>k</code> times with <code>j</co...
{ "AcceptedAnswerId": "265846", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T18:18:06.557", "Id": "265794", "Score": "2", "Tags": [ "c", "programming-challenge", "time-limit-exceeded" ], "Title": "How to do modulo thing fast (less execution time)" }
265794
<p>I'm trying to learn the golfing language <a href="https://github.com/Vyxal/Vyxal" rel="noreferrer">Vyxal</a> because I occasionally contribute to it, and I'm slightly ashamed I can't even use it. To do this, I started with implementing the Sieve of Eratosthenes in Vyxal. I'd like to know how to make this code more r...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T19:55:05.580", "Id": "525060", "Score": "1", "body": "Please also have a look at https://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf" } ]
[ { "body": "<p>It is probably more efficient to work with a boolean array (which is the idea behind the sieve anyway - a boolean mask that you build up to filter out all of the non-primes in the range). Instead of a <code>sieve</code> and a <code>primes</code> variable, we just have a single <code>isprime</code>...
{ "AcceptedAnswerId": "265800", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T20:41:25.273", "Id": "265797", "Score": "13", "Tags": [ "primes", "sieve-of-eratosthenes", "vyxal" ], "Title": "Sieve of Eratosthenes in Vyxal" }
265797
<p>I was trying to fetch some data (daily new cases and daily new deaths) from <a href="https://www.worldometers.info/coronavirus/" rel="nofollow noreferrer">Worldometers</a> and I came up with this:</p> <pre><code>import requests from bs4 import BeautifulSoup as bs import numpy as np import matplotlib.pyplot as plt ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T01:41:57.700", "Id": "525020", "Score": "0", "body": "You should make your link match the URLs in your code." } ]
[ { "body": "<p>Sure. One way would be to use another source. Another might be to separate out the &quot;script&quot; tag (for example, using a bs selector) and at least only use that as the string. Unless you want to run javascript, there's not a much better way to read the data from inside the script.</p>\n<p>I...
{ "AcceptedAnswerId": "265861", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T21:25:27.200", "Id": "265798", "Score": "2", "Tags": [ "python", "python-3.x", "html", "covid-19" ], "Title": "A better way to extract COVID data from Worldometers" }
265798
<p>Get a list of popular Arch Linux packages with a popularity greater or equal than the given one.</p> <p>It asks for the popularity if it isn't given. Then gets the total number of packages and iterates until it gets the whole list of packages - one thousand at a time, because if I try to grab them all the API gives ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T17:05:57.133", "Id": "525051", "Score": "0", "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>First, as someone who writes a lot of bash, I would recommend rewriting this in something other than bash. You're using bash as a programming language (and trying quite hard to make it readable), but it's simply not the best programming language.</p>\n<ul>\n<li>The basic idea of gluing together a ...
{ "AcceptedAnswerId": "265818", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T21:33:43.690", "Id": "265799", "Score": "4", "Tags": [ "bash" ], "Title": "Get popular Arch packages" }
265799
<p>I've made some code that generates cursed error messages like this, for my new language <a href="https://github.com/chunkybanana/javastack" rel="noreferrer">Javastack</a>:</p> <pre class="lang-none prettyprint-override"><code>BadError on line 58: S(Y5YN6c/$sIcI\&quot;h&gt;mH424`Ihkt&amp;!3aolsjBHZ%\\J| ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T17:15:30.350", "Id": "525054", "Score": "0", "body": "Note that strings encased in backticks can go on for multiple lines, so you don't need the `+'\\n\\n'+` stuff. However, it may be better to declare variables like `const errorNam...
[ { "body": "<h2>Efficiency</h2>\n<p>Since there is no real algorithm here to speak of, all optimizations are micro-optimizations and boil down to avoiding unnecessary object allocations.</p>\n<p>Every call to <code>genCursedError</code> allocates and deallocates a function <code>rand</code>. This function is gen...
{ "AcceptedAnswerId": "265841", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T21:52:25.447", "Id": "265801", "Score": "7", "Tags": [ "javascript" ], "Title": "Cursed error generator in Javascript" }
265801
<p>This is my WIP attempt at an open-source web demo for exploring <a href="https://en.wikipedia.org/wiki/Word_embedding" rel="nofollow noreferrer">word vectors</a> as part of my research. The functionality will be explained separately from the site. It is also my first time using HTML, JavaScript, and CSS in a non-tri...
[]
[ { "body": "<p>This a pretty big submission, so I'm going to focus on what I think is most important.</p>\n<p>The feeling I got from skimming the code:</p>\n<ul>\n<li>Good formatting and good use of modern javascript overall.</li>\n<li>Seems to be fairly easy to read overall, though a bit hard to follow the glob...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T22:31:35.523", "Id": "265802", "Score": "3", "Tags": [ "javascript", "html", "css", "data-visualization" ], "Title": "Javascript Word Vectors Demo" }
265802
<p>So this code is yet another attempt at solving the <a href="https://projecteuler.net/index.php?section=problems&amp;id=2" rel="nofollow noreferrer">second Project Euler problem</a> to improve my handling of Python. The purpose of the code is to solve the problem below</p> <blockquote> <p>Each new term in the Fibonac...
[]
[ { "body": "<p>Disclaimer 1: This is not a review, but an extended comment.</p>\n<p>Disclaimer 2: ProjectEuler is not about programming. It is about math. As long as you understand what the problem is about, an actual computation is supposed to be very simple.</p>\n<blockquote>\n<p>I wanted to do it as fast as p...
{ "AcceptedAnswerId": "265879", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-06T23:27:02.830", "Id": "265804", "Score": "4", "Tags": [ "python", "performance", "python-3.x", "programming-challenge" ], "Title": "Bisection, linear recurrences and even F...
265804
<p>CodeSignal put out a challenge by Uber that involves writing a &quot;fare estimator&quot; that involves a function dependent on cost per minute, cost per mile, ride time and ride distance.</p> <p>The formula is along the lines of...</p> <p>Given that: cₐ stands for cost per minute, rₐ stands for ride time, cₑ stands...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T19:23:36.757", "Id": "525058", "Score": "1", "body": "I'm not sure who \"they\" are, but recommending type hints makes sense for Python, being a duck-typed language. What you have done here (explicit typing) seems perfectly appropr...
[ { "body": "<p>There isn't much code to review here.</p>\n<ol>\n<li><p>Use correct spelling. <code>estimation_forumla</code> should be <code>estimation_formula</code>.</p>\n</li>\n<li><p>Use consistent naming conventions. <code>estimation_forumla</code> is snake case, while <code>fareEstimator</code> is camel ca...
{ "AcceptedAnswerId": "265829", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T03:10:48.677", "Id": "265810", "Score": "2", "Tags": [ "c++", "algorithm", "programming-challenge", "reinventing-the-wheel", "vectors" ], "Title": "An implementation o...
265810
<p>This is a mythical beast we discussed in <a href="/q/265724/75307">a previous question</a>:</p> <pre><code>template &lt;typename F, class Tuple&gt; constexpr void operator|(Tuple&amp;&amp; t, F f) noexcept(noexcept(f(std::get&lt;0&gt;(t)))) { [&amp;]&lt;auto ...I&gt;(std::index_sequence&lt;I...&gt;) noexcept(noexc...
[]
[ { "body": "<p>I don't see a great need for this in normal (clear, obvious) code;\nI believe that most C++ users would expect an ordinary function (in the pattern of <code>std::for_each()</code>, perhaps), rather than overloading the <code>|</code> operator. In the future, <code>|</code> become recognised as a ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T07:22:00.917", "Id": "265811", "Score": "2", "Tags": [ "c++", "functional-programming", "c++20" ], "Title": "piping a std::tuple into a function" }
265811