body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>I'm recording which keys are being pressed. After pressing two keys, the first link that matches the two characters will be highlighted. After pressing one more key, the link that corresponds to those three characters will be clicked.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" d...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T07:54:16.480", "Id": "525023", "Score": "0", "body": "@TobySpeight Is the title fine now?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T07:59:21.400", "Id": "525025", "Score": "2", "body...
[ { "body": "<h2>Warning <code>keypress</code></h2>\n<p>The <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event\" rel=\"nofollow noreferrer\" title=\"MDN Web API's Document keypress event\">keypress</a> event has been depreciated. Using it means that your code can just stop working ...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T07:28:32.647", "Id": "265812", "Score": "2", "Tags": [ "javascript" ], "Title": "Recording keypress and clicking the link that corresponds to the pressed characters" }
265812
<p>This is a simple Python multi-connection downloader primarily using requests, mmap and threads, it downloads a single file using 32 concurrent connections, slices the download using range parameter, and write the slices to a <code>mmap</code> object.</p> <p>The code:</p> <pre class="lang-py prettyprint-override"><co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T13:12:17.757", "Id": "525106", "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>Here are a few comments on your question and your code, in no particular order:</p>\n<ul>\n<li><p>There is no need to reinvent the wheel when formatting a time (<code>timestring</code> function). Have a look at <a href=\"https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior\" ...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T07:44:34.200", "Id": "265814", "Score": "4", "Tags": [ "python", "performance", "python-3.x", "multithreading" ], "Title": "Python multi-connection downloader" }
265814
<p>In a recent coding interview I was asked to write a program which takes as input two text lines:</p> <ul> <li>The first one represents a graph, formatted as a sequence of undirected edges like <code>[A,B,10] [B,C,4]</code></li> <li>The second one represents two nodes, between which the shortes path is to be found, a...
[]
[ { "body": "<p>Do you <em>really</em> use all these?:</p>\n<blockquote>\n<pre><code>#include &lt;map&gt;\n#include &lt;set&gt;\n#include &lt;list&gt;\n#include &lt;cmath&gt;\n#include &lt;ctime&gt;\n#include &lt;deque&gt;\n#include &lt;queue&gt;\n#include &lt;stack&gt;\n#include &lt;string&gt;\n#include &lt;bits...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T09:15:43.590", "Id": "265816", "Score": "4", "Tags": [ "c++", "interview-questions", "graph", "c++14", "pathfinding" ], "Title": "Compute shortest path in undirected graph...
265816
<p>I've been looking at the way the native queries are written in my project and it just seems overengineered in my perspective. Writing a native query should be simple. Can someone suggest the right/simple way to write native queries? Here is how it is written as of now:</p> <p><strong>Repository</strong></p> <pre><co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T20:01:34.080", "Id": "525476", "Score": "0", "body": "I would have done at Repository level. It's closer to @Query , easily visible . If entity grows and so does querying methods , over the period of time it became cumbersome to ea...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T10:07:41.627", "Id": "265817", "Score": "0", "Tags": [ "java", "hibernate", "jpa" ], "Title": "What is the right way to write a native query in Spring JPA?" }
265817
<p>Some background: JavaScript is not my primary language, so I'm looking to get some constructive criticism here.</p> <p>I built a tiny single page HTML app that pretty prints JSON text. It's very useful when I am looking a process logs that dump JSON without pretty printing.</p> <p>In my tool, I added a checkbox to ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T16:48:57.823", "Id": "525049", "Score": "1", "body": "`Array.sort()` can sort `null` if done so explicitly in a `compareFunction` passed into `sort()`. [See MDN documentation.](https://developer.mozilla.org/en-US/docs/web/javascript...
[ { "body": "<p>This code was well-commented and easy enough to figure out. Well done on that front.</p>\n<p>Stylistic notes:</p>\n<ul>\n<li>In JS it's idiomatic to use <code>camelCase</code>, not <code>snake_case</code>.</li>\n<li>This code is formatted like C# code. In JS, open brace on same line is more comm...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T10:55:30.317", "Id": "265820", "Score": "2", "Tags": [ "javascript", "sorting", "json" ], "Title": "Using JavaScript, given a JSON value, recursively find all JSON objects, then s...
265820
<h1>What is Vyxal</h1> <p><a href="https://esolangs.org/wiki/Vyxal" rel="nofollow noreferrer">Vyxal</a> is a golfing language with a unique design philosophy: make things as short as possible but retain elegance while doing so. In very simple terms, this means keeping aspects of traditional programming languages that m...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T11:36:42.160", "Id": "265822", "Score": "0", "Tags": null, "Title": null }
265822
Vyxal is a golfing language made by CGSE user lyxal. But unlike other golfing languages you might have seen, Vyxal has a special focus on readability and elegancy - it has features such as arbitrary variable names and defined functions that other golflangs don't have. Questions using the vyxal tag are not for advice on...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T11:36:42.160", "Id": "265823", "Score": "0", "Tags": null, "Title": null }
265823
<p>I've created this code in the golfing language <a href="https://github.com/vyxal/vyxal" rel="nofollow noreferrer">Vyxal</a> to do FizzBuzz:</p> <pre class="lang-js prettyprint-override"><code>100 ( n 1 + →currentvalue ←currentvalue 15 % 0 = [ `FizzBuzz`, | ←currentvalue 5 % 0 = [ `Buzz`, | ←currentvalue ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T22:09:15.837", "Id": "525071", "Score": "0", "body": "This is a comment because I don't have much to say, but I'd recommend closing your loops and other structures. It's like having a Java class where you write `class Foo { public v...
[ { "body": "<p>Firstly, it doesn't really make sense to push <code>100</code>, run a <code>(</code> block, and then do <code>n 1 +</code> when you could instead just use <code>ɾ</code> to get the range <code>1, 2, ..., 100</code>: <code>100 ɾ (</code>. Now, you are looping from 1 to 100, which makes a lot more s...
{ "AcceptedAnswerId": "265840", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-07T22:02:10.990", "Id": "265838", "Score": "4", "Tags": [ "fizzbuzz", "vyxal" ], "Title": "FizzBuzz in Vyxal" }
265838
<p>I need to go from this dataframe:</p> <pre><code>&gt; dat Code Project Status 1 A01 Pr1 In progress 2 A02 Pr1 Complete 3 A03 Pr2 Complete 4 A04 Pr1 Complete 5 A05 Pr1 In progress 6 A06 Pr3 Complete 7 A07 Pr3 In progress 8 A08 Pr3 Complete 9 A09...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T07:19:19.593", "Id": "265844", "Score": "2", "Tags": [ "json", "r" ], "Title": "Transform dataframe to a certain JSON format" }
265844
<p>The code works, at least against the unit tests. But I would like input on how to refactor it. Or also maybe a way to do this without using temporary lists? I also have some special checks, like if the string is empty or if the brackets are unbalanced; is there a way to incorporate these special checks into the main...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T13:02:08.983", "Id": "525104", "Score": "1", "body": "For a simple balanced pair check without temporary lists, you can (1) move up from last known Left index until you find an opening bracket, (2) determine the required closing bra...
[ { "body": "<p>Nice code. But you can use one stack instead two lists. Try to refactor your code.\nPush the opening bracket to the stack.\nPop the last bracket. In case there is wrong bracket return false.</p>\n<p>At the end you should get empty stack in case the brackets are paired</p>\n<pre><code>public static...
{ "AcceptedAnswerId": "265853", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T09:30:59.897", "Id": "265845", "Score": "5", "Tags": [ "c#", "balanced-delimiters" ], "Title": "C# code to check balanced brackets in a string" }
265845
<p>I'm building a full stack exercise app and some of my objects include routines, exercises, exercise sets etc. Instead of writing out specific get, post, put and delete requests for each resource, I was wondering if there's a more dynamic way to make requests using a custom React hook. I've seen many examples of a us...
[]
[ { "body": "<p>The biggest part is that the code works and it looks okay.</p>\n<p>I only have a few concerns about unnecessary rerenders and inconsistent UI because of inaccurate status state.</p>\n<p>Below are a few minor things I'd recommend and consider.</p>\n<h3>Naming</h3>\n<p>Code naming should be consiste...
{ "AcceptedAnswerId": "265865", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T10:47:59.763", "Id": "265849", "Score": "3", "Tags": [ "react.js", "typescript", "mongoose", "axios" ], "Title": "A React - Typescript custom hook for any request (GET, PO...
265849
<p><strong>Edit</strong>: cross-posted this question on <a href="https://stackoverflow.com/questions/68774523/best-way-of-cleaning-up-resources-with-completablefuture">Stackoverflow</a>.</p> <p>Suppose I have a function that takes a <code>FileInputStream</code>, performs some operation using the file data in the backgr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T06:40:26.300", "Id": "525214", "Score": "0", "body": "Hello at CodeReview@SE - SE's site *for open-ended feedback on **working** source code from your project, including **application** of best practices* (along [What topics can I a...
[ { "body": "<p>I can think of a different approach in which it would be the asynchronous' call responsibility to create the resource and close it:</p>\n<p>If you want to let the responsibility of knowing how to create the resource to the caller, you could use a <a href=\"https://docs.oracle.com/en/java/javase/16...
{ "AcceptedAnswerId": "265876", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T11:04:47.370", "Id": "265850", "Score": "2", "Tags": [ "java", "asynchronous" ], "Title": "Best way of cleaning up resources with CompletableFuture" }
265850
<p>I'm implementing <code>apply_each</code> for tuple-like object as a general function which may be a combined version of <code>for_each</code> and <code>tuple_transform</code> in some implementations for tuple iteration.</p> <p>As the name suggests, the first argument which is invocable will <strong>apply each</stron...
[]
[ { "body": "<p>I see two main issues with the design.</p>\n<ol>\n<li>That you need to use <code>std::ref</code> to operate on the tuples themselves and not their copies. This isn't good. It is used this way in <code>thread</code> and similar cases but there it creates an object and knowledge whether a copy is ne...
{ "AcceptedAnswerId": "267874", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T14:20:04.170", "Id": "265854", "Score": "5", "Tags": [ "c++", "template-meta-programming", "c++20" ], "Title": "Implementing apply_each for tuple c++" }
265854
<p>First of all: Hi, my name is Henrik and I am a mechanical engineer, who loves to code in his free time. To get better in programming I wrote a genetic algorithm compined with a list planning algorithm (giffler thompsoon algorithm) to solve the fjssp (i have encountered this problem in my master thesis 2 years ago).<...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T13:49:08.910", "Id": "525673", "Score": "1", "body": "First thing I notice is that your variable names are not always self-descriptive. Things like `nOp` or `susRank` make it hard to follow along." }, { "ContentLicense": "CC...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T15:50:22.360", "Id": "265855", "Score": "2", "Tags": [ "java", "beginner", "genetic-algorithm" ], "Title": "Giffler Thompson Algorithm for decoding individuals of a Genetic Algori...
265855
<p>I'm a new developer just starting out learning HTML5, CSS3 and JavaScript. Below is my attempt at building a portfolio website.</p> <p>I am finding it difficult getting my site to respond better when adjusting the screen size. Text and images are just going all over the place when resizing the browsers window or vie...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T13:27:55.087", "Id": "525301", "Score": "1", "body": "You might be interested in learning about [**flexbox**](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) for greatly simplifying not only the CSS, but also the HTML by re...
[ { "body": "<p>Sick portfolio Jack. So instead of giving img a fixed size, you should give it a relative value (i.e percentage). For example:</p>\n<pre><code>.socials img{\n width: 125px; =&gt; 75%\n height: auto; \n margin: 40px;\n}\n</code></pre>\n<p>To make your site responsive, the next time you may...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T16:50:52.173", "Id": "265856", "Score": "0", "Tags": [ "javascript", "beginner", "html", "css", "mobile" ], "Title": "Portfolio Website Responsive Design" }
265856
<p>I'm learning C# and have written the below class to encapsulate the game state of Conway's Game of Life and its update methods. I'm also learning about implementing light automated unit tests for this project from the beginning. My overall goal is to build an Android app implementation of the game (using Xamarin) ...
[]
[ { "body": "<p>You've implemented the &quot;game of life&quot; as an actual game where you have to enter coordinates. That's really weird to me; it's a zero-player game - the living cells play the game.</p>\n<p>I've got no clue when I started to read into the code why there are two coordinate systems and two nam...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T16:50:55.430", "Id": "265857", "Score": "2", "Tags": [ "c#", "unit-testing", "game-of-life" ], "Title": "Conway's Game of Life in a C# class. Is this sensibly factored and well te...
265857
<p>I want to know if I can use shared memory to optimize my code and get better performance. I will explain how my code works:</p> <p>The inputs to my kernel are a matrix <code>d_e</code> of size [75x19], array <code>d_l</code> and <code>d_f</code> both of size [75x1]. In my kernel I don't always use the the whole matr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T14:36:51.067", "Id": "525168", "Score": "1", "body": "Welcome to the Code Review Community. What we do here is review working code that you have written and make suggestions on how to improve that code. Do you have this code working...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T19:01:16.177", "Id": "265859", "Score": "0", "Tags": [ "c++", "cuda" ], "Title": "Using shared memory in cuda kernel to populate arrays of different dimensions" }
265859
<p>I have implemented the following question and looking forward for the reviews.</p> <p>Question Explanation : We have a two-dimensional board game involving snakes. The board has two types of squares on it: +'s represent impassable squares where snakes cannot go, and 0's represent squares through which snakes can mo...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T07:29:16.490", "Id": "525138", "Score": "1", "body": "This is the third question involving depth first search you have posted in a short time. You may have fallen into the good old \"hammer trap.\" I.e. thinking that all problems lo...
[ { "body": "<p>The one big thing worth saying has already been said: This isn't a problem where DFS is needed. This could and should be checked using nested <code>for</code>-loops, iteratively checking all rows and columns. Recursion is probably slower, certainly heavier on memory and doesn't make much sense her...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T19:15:17.580", "Id": "265860", "Score": "-1", "Tags": [ "java", "matrix", "depth-first-search" ], "Title": "Find Passable Lanes in Rows and Columns" }
265860
<p>I would like the array elements to minimize by preserving their orders. For example:</p> <ul> <li><code>3,7,9,7</code> is given <code>1,2,3,2</code> is yielded</li> <li><code>1,99,90,95,99</code> is given <code>1,4,2,3,4</code> is yielded.</li> </ul> <p>Think array can be ranged btw 0 to 100, exclusively. My try’s t...
[]
[ { "body": "<h3>Indents</h3>\n<p>I've spent a minute struggling to understand that <code>copy[i] = num;</code> happens inside the second <code>for</code> loop. Please, indent the code to make it readable - you will gain from it in the first place.</p>\n<h3>Your algorithm is <span class=\"math-container\">\\$O(n^...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-08T22:19:07.100", "Id": "265862", "Score": "4", "Tags": [ "c#", "algorithm", "array" ], "Title": "Better way to minimize array elements" }
265862
<p>I know this is a weird program but I am trying to learn how to write Python programs. This program will accept user input, starting by having the user specify a file path then continuously looping through a set of option which the user will choose.</p> <p>The options are basic Pandas methods, get mean, variance, and...
[]
[ { "body": "<h2>Starting from your questions:</h2>\n<ul>\n<li><strong>...<code>GroupCols</code> method, is that the best way to allow for method overloading?</strong> I guess if what you mean is whether the way the function is defined does a function overload depending on the number of parameters you provide, th...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T03:18:22.387", "Id": "265871", "Score": "1", "Tags": [ "python", "python-3.x", "pandas" ], "Title": "Python program to accept user input for Pandas methods" }
265871
<p>I need people who have experience with React to review my code.</p> <p>I want to make a debounce using Lodash.</p> <pre><code>import debounce from 'lodash/debounce' </code></pre> <pre><code>const [name, setName] = React.useState&lt;string | undefined&gt;(undefined) const [displayedName, setDisplayedName] = React.use...
[]
[ { "body": "<ol>\n<li>Code you provided can't work properly in some cases. Thing is that <code>debounce</code> returns a completely new function with a separate queue on each new render.\n<ul>\n<li>So, in case if rerender happens, <code>changeName</code> will be completely new &amp; will apply changes immediatel...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T04:39:15.793", "Id": "265873", "Score": "0", "Tags": [ "javascript", "react.js", "lodash.js" ], "Title": "React debounce using Lodash" }
265873
<p>I'm a beginner and self taught and just want to see if there are neater ways of doing what I am doing, or whether there are bits of code that are poorly written. I think Lines 100-204 are the most crudely written. Below I've also determined who is bowling first and therefore assigning a dictionary to that team for t...
[]
[ { "body": "<p>Disclaimer: I know nothing whatsoever about the rules of cricket.</p>\n<p><strong>Useless check</strong></p>\n<p>Because either <code>info['toss_decision']</code> equals <code>'field'</code> or it does not, you do not need to check things twice in:</p>\n<pre><code>if info['toss_decision'] == 'fiel...
{ "AcceptedAnswerId": "265880", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T11:11:57.787", "Id": "265877", "Score": "3", "Tags": [ "python", "beginner", "csv", "database" ], "Title": "Reducing the amount of duplicated code (python) - cricket match...
265877
<p>I wanted to create a simple method that creates two random teams for football/soccer match from a list of players with a requirement that the goalkeepers should be in different teams (so that one team should have at least one goalkeeper). It's a simple task and I wanted this method to be as clean as possible, let me...
[]
[ { "body": "<p><code>{ player -&gt; player.isGoalkeeper }</code> can be replaced with <code>(Player::isGoalkeeper)</code> in all the places you're using it. This is recommended syntax from Jetbrains because it's self-documenting...no extra variable name introduced so it's simpler to read and know what the types ...
{ "AcceptedAnswerId": "265885", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T12:31:42.750", "Id": "265881", "Score": "3", "Tags": [ "kotlin" ], "Title": "Create two teams from a list of players with minimum of one goalkeeper per team" }
265881
<p>I don't know how to use classes and i think its meant to be used here to avoid repetition of functions but i can be completely wrong, i am a student who keeps learning bit by bit. Please can you take a look into my code? i truly appreciate it :)</p> <pre><code>import nmap import re from sys import argv, version #Ope...
[]
[ { "body": "<p>This is by no means a thorough review but I see things you can improve in no particular order:</p>\n<ul>\n<li>add <strong>line spacing</strong>, especially between functions - that will make the code easier to read. Everything is glued together here, it's not obvious in the blink of an eye where a...
{ "AcceptedAnswerId": "265888", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T18:47:51.237", "Id": "265887", "Score": "0", "Tags": [ "python" ], "Title": "A port scanner made in python" }
265887
<p>Hello everyone I was told to post this here instead of StackOverFlow.</p> <p>I am using PyAutoGUI currently as this was the best tools I could manage to find to use a piece of software that has no native Python function. I am using the mouse and keyboard control to design maps for Dungeons and Dragons using the soft...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T21:08:26.723", "Id": "525195", "Score": "0", "body": "We are missing some information here. Can you include a screenshot of the program you're scripting, and explain why you're scripting it (instead of doing it once by hand?)" }, ...
[ { "body": "<blockquote>\n<p>My reason for creating this script is so that I can eventually randomize it to create a random generated map for my D&amp;D campaign that is somewhat original compared to just taking a map off the internet.</p>\n</blockquote>\n<p>Given that you want to eventually make a random map, y...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T20:51:02.693", "Id": "265889", "Score": "2", "Tags": [ "python" ], "Title": "Maze generator for Dungeons and Dragons" }
265889
<p>This is my first Stack Exchange question, so please bare with me. I'm following this tutorial on youtube by <a href="https://www.youtube.com/watch?v=GFYT7Lqt1h8&amp;list=PLlrATfBNZ98eOOCk2fOFg7Qg5yoQfFAdf&amp;index=2" rel="nofollow noreferrer">The Cherno</a>, Im only up to episode 16 and I have done this on another ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T06:38:11.753", "Id": "525213", "Score": "3", "body": "There's not much to review here as you are under the wrong assumption, that you can make a game engine using normal user interface code like swing/awt. To achive performance, you...
[]
{ "AcceptedAnswerId": null, "CommentCount": "10", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T23:09:01.293", "Id": "265892", "Score": "1", "Tags": [ "java", "performance", "game", "eclipse" ], "Title": "I'm making a 2D game engine with JAVA Eclipse 2021-06 but it is u...
265892
<p>Is the code properly documented/commented? does the code handle errors properly? any suggestions to improve the code Help outline the object-oriented principles shown in the code.</p> <pre><code>using System; public class testScore { public static void Main() { string str1; double ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T00:31:52.420", "Id": "525203", "Score": "0", "body": "`Double.Parse(Console.ReadLine())` will throw an exception on invalid input. Use [Double.TryParse](https://docs.microsoft.com/en-us/dotnet/api/system.double.tryparse?view=net-5.0...
[ { "body": "<p><strong>Variables</strong></p>\n<p>You've defined <code>str1</code> and <code>dbl1</code> as variable names, but the names themselves aren't descriptive of their use. Better names for them would be:</p>\n<pre><code>string name;\ndouble score;\n</code></pre>\n<p>Along with this, there's no reason w...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-09T23:45:31.417", "Id": "265893", "Score": "1", "Tags": [ "c#" ], "Title": "Is the code properly documented/commented and does the code handle errors properly?" }
265893
<p>I've recently reached a milestone for my Othello clone. This is my first python project and the farthest I've come to a full program beyond small scripts and little automations.</p> <p>I'd love for those smarter than I to critique and help me to write better code.</p> <p>Link: <a href="https://github.com/Mcclujdd/ot...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T00:38:59.960", "Id": "265895", "Score": "3", "Tags": [ "beginner", "python-3.x", "object-oriented", "design-patterns" ], "Title": "Othello game in Tk" }
265895
<h1><strong>Overview</strong></h1> <p>This is a program that encrypts and decrypts messages and texts using two simple algorithms. Please note, the algorithms used in this project are not suitable for production use. I used them to help deepen my understanding [beginner] of the general ideas behind Java, encryption, wo...
[]
[ { "body": "<p>Here's what I found in no particular order, I hope it helps:</p>\n<h2>Command line parsing</h2>\n<p>The parser will throw an <code>OutOfBoundsException</code> or will use garbage if the user doesn't provide a value after an argument flag. If you pass only an input file but no output file, the pars...
{ "AcceptedAnswerId": "265981", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T01:02:17.993", "Id": "265896", "Score": "2", "Tags": [ "java", "beginner" ], "Title": "Program that encrypts and decrypts messages and texts" }
265896
<p>Well, there are many game of life's already, but after posting an answer on it in C#, I thought I might as well check if I did any better and if there is anything new to learn - there always is.</p> <p>Design:</p> <ul> <li>main object is a <code>Board</code> which represents a board including the living cells;</li> ...
[]
[ { "body": "<p>Not bad at all, therefore here's only a few things that rub me the wrong way:</p>\n<ul>\n<li>Encoding the state in a long. Why? We are talking about saving a few hundred bytes at most, and we are in an age where this will not even make a difference on a mobile phone. This had been a good idea in 1...
{ "AcceptedAnswerId": "265901", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T02:29:12.927", "Id": "265897", "Score": "6", "Tags": [ "java", "game", "design-patterns", "game-of-life", "coordinate-system" ], "Title": "Conway's game of life as Jav...
265897
<p>I'm solving the classic problem of finding two numbers from an array that sum to a given value.</p> <p>Can anybody please check whether my analysis of time and space complexity is correct on this one?</p> <pre><code># O(n) time | O(1) space def twoNumberSum(array, targetSum): for x in array: y = targetS...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T06:26:59.593", "Id": "525211", "Score": "2", "body": "It is nearly impossible to solve this problem with O(n) time and O(1) space." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T14:51:58.053", "I...
[ { "body": "<p>This code fails given <code>[0, 1, 1]</code> and <code>2</code> as inputs: it should return <code>[1,1]</code> but fails because the two numbers are identical. So it fails review, without any further analysis.</p>\n<p>Scaling is poorer than you believe, if <code>array</code> is a list, since <cod...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T04:49:39.817", "Id": "265898", "Score": "2", "Tags": [ "python" ], "Title": "Python - Two Number Sum (time and space complexity)" }
265898
<p>Taking forward the code written for the math library previously mentioned here. <a href="https://github.com/suryasis-hub/MathLibrary" rel="nofollow noreferrer">link</a>. Wrote templatized functions for mode and standard deviations. (Some of the changes to the previous reviews were not made yet. Please review the sam...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T07:18:47.183", "Id": "525215", "Score": "2", "body": "The test code seems to be a repeat of the functions. I guess it's a copy-paste error?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T07:36:06.420...
[ { "body": "<blockquote>\n<pre><code> throw std::invalid_argument(&quot;Statistics::average - The distribution provided is empty&quot;);\n</code></pre>\n</blockquote>\n<p>Oops - we didn't include <code>&lt;stdexcept&gt;</code>.</p>\n<blockquote>\n<pre><code> return pow(variance(distributionVector), 0.5...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T06:14:23.327", "Id": "265900", "Score": "4", "Tags": [ "c++", "beginner" ], "Title": "Mode and standard deviation for Math Library" }
265900
<p>From the PEP8 &quot;Function names should be lowercase, with words separated by underscores as necessary to improve readability.&quot;</p> <p>Then we have popular libraries like matplotlib with arguments i.e. <code>linewidth</code> and <code>markersize</code>, which is apparently doesn't follow the convention. The q...
[]
[ { "body": "<p>I'd say it depends on who your code is for. If your library is designed for coders who are familiar with matplotlib and the arguments its functions take (they know what <code>linewidth</code> and <code>markersize</code> are in the context of matplotlib), use the matplotlib naming. Otherwise use th...
{ "AcceptedAnswerId": "265906", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T08:31:44.057", "Id": "265904", "Score": "-1", "Tags": [ "python" ], "Title": "Should you follow the style convention in python with old libraries?" }
265904
<p>I wrote a 2-layer neural net with just Python &amp; NumPy to implement the XOR Gate, here is the code</p> <pre><code>import time start_time = time.time() import numpy as np def sigmoid(z): return 1 / (1 + np.exp(-z)) class MLPClassifier: def __init__(self, eta=.05, n_epoch=10, n_0=2, n_1=2, n_2=1, ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T10:03:21.737", "Id": "265908", "Score": "0", "Tags": [ "python", "machine-learning" ], "Title": "Implement the XOR Gate using a 2-layer neural net with just Python & NumPy" }
265908
<p>Python Beginner building an automation irrigation system in Raspberry Pi.</p> <p>The Python has two functions:</p> <ol> <li>Single wire temperature sensor (DS18B20) that prints/monitors temperature</li> <li>Turn on LED (will be relay switch)</li> </ol> <p>The idea is when the temperature gets too hot, it will turn o...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T15:08:18.167", "Id": "525249", "Score": "2", "body": "Your `data.split(\"\\n\")[1].split(\" \")[9]` operation extracts the 10th space-separated word from the second line of `data`. We can't tell how robust that extraction process i...
[ { "body": "<p>I'm going to assume that your device has a <code>sysfs</code> interface identical to that described in <a href=\"https://albertherd.com/2019/01/20/using-c-to-monitor-temperatures-through-your-ds18b20-thermal-sensor-raspberry-pi-temperature-monitoring-part-3/\" rel=\"noreferrer\">this guide</a>, wh...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T14:00:33.267", "Id": "265914", "Score": "5", "Tags": [ "python-3.x" ], "Title": "Temperature Sensor that loop and turns on cooling" }
265914
<p>I'm working on a project that will have both a server and a client, using Boost's ASIO library for networking. I'm not really comfortable working with Makefiles, but, with some help from Chase Lambert's <a href="https://makefiletutorial.com/#makefile-cookbook" rel="nofollow noreferrer">https://makefiletutorial.com/#...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T03:01:32.277", "Id": "525279", "Score": "0", "body": "Is SUDOKU_OBJS a copy paste error?" } ]
[ { "body": "<p>Why are <code>INC_DIRS</code> and <code>SRC_DIRS</code> pluralized if they only contain one value each, and are treated that way throughout the rest of the makefile? These should be singular.</p>\n<p>It looks like <code>$(OBJS)</code> is common to both executables, and is re-linked in each case. I...
{ "AcceptedAnswerId": "265933", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T14:24:07.817", "Id": "265916", "Score": "2", "Tags": [ "c++", "boost", "makefile", "make" ], "Title": "Makefile that compiles to two separate executables" }
265916
<p>I'm trying to write a function to replace the standard <code>std::stod(...)</code>. I want to parse the following valid inputs:</p> <p><code>/[+-]?\d+(?:\.\d+)?(?:e[-+]?\d+)?/g</code></p> <p>Here's the <a href="https://regexr.com/63fv4" rel="nofollow noreferrer">RegExr link</a>.</p> <p>And also the words <code>infin...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T15:45:21.290", "Id": "525251", "Score": "2", "body": "Why are you putting an extra `\\0` in your strings? Note that in the comparisons that doesn't do anything since the compare stops at the _first_ `\\0`." }, { "ContentLic...
[ { "body": "<h3>Identifiers</h3>\n<p>Identifiers should be meaningful. What's <code>s</code>? What's <code>d</code>? What's <code>e</code>? Maybe you should name them <code>str</code>, <code>digits_count</code> (or at least <code>n_digits</code>) and <code>exponent</code> or something like that?</p>\n<p>The only...
{ "AcceptedAnswerId": "265930", "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T14:48:20.887", "Id": "265917", "Score": "2", "Tags": [ "c++", "strings", "floating-point" ], "Title": "string to double" }
265917
<p>The Microsoft.Extensions method for Polly, to use policies via dependency injection, <code>serviceCollection.AddPolicyRegistry()</code> only allows to add already created policies, while still defining the <em>ServiceCollection</em> content, so other DI service instances, such as loggers, are not available.</p> <p>T...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T07:57:36.570", "Id": "525292", "Score": "0", "body": "How are you planning to use the registered policies? Do you want to use them to decorate typed HttpClients?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2...
[ { "body": "<p>We have gone through the same problem (more or less) whenever we started to use Polly. But after a couple of months we have realized that this flexibility is really <strong>error-prone</strong> and it is <strong>not needed</strong>.</p>\n<p>Let me give an example why is it error-prone. Let's suppo...
{ "AcceptedAnswerId": "265983", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T18:52:54.423", "Id": "265921", "Score": "1", "Tags": [ "c#", "dependency-injection", "singleton", "polly" ], "Title": "Polly AddPolicyRegistry() with factory and registere...
265921
<p>I'm new to Rust. I wanted to create a script to read the contents on a directory, and then generate a js file exporting this assets. I wrote this code, it works but I'm not totally happy with it. I want to know the best way to do this.</p> <p>you can check full code here: <a href="https://gist.github.com/JoseLuna12/...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T00:56:12.297", "Id": "525276", "Score": "1", "body": "Since your full code is not long, consider including the full code to provide more context." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T15:14:...
[ { "body": "<p>To build strings in rust, use <code>format!()</code> or <code>write!()</code></p>\n<pre><code>let content = vec![\n &quot;import&quot;.to_owned(),\n [&quot;'&quot;.to_owned(), v_name[0].to_owned(), &quot;'&quot;.to_owned()].join(&quot;&quot;),\n &quot;from&quot;.to_owned(),\n ...
{ "AcceptedAnswerId": "266076", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T18:59:25.667", "Id": "265922", "Score": "3", "Tags": [ "rust" ], "Title": "Rust script to generate JavaScript asset list file based on directory contents" }
265922
<p>For the company I work for we spec lengths of tube of varying lengths.<br /> For a given project let's say there is a list like this</p> <p>100', 115', 105', 205', 195', 240', 240', 130', 180', 140', 225', 85'</p> <p>Edit 4: Entries in the list can not go over 285', and are always rounded to the nearest 5'.</p> <p>T...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T05:48:48.483", "Id": "525286", "Score": "0", "body": "Welcome to CodeReview@SE. I've touched up your post, please refer to [How do I ask a Good Question?](https://codereview.stackexchange.com/help/how-to-ask) and find ideas why." ...
[ { "body": "<p>I know I asked about the comments in a comment on the question, so I'll just point out that this type of commenting makes code so hard to read.</p>\n<pre><code>bool success = false;//exit condition for while loop\nwhile (!success)\n</code></pre>\n<p>You don't need a comment for what success is use...
{ "AcceptedAnswerId": null, "CommentCount": "9", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-10T22:37:19.133", "Id": "265926", "Score": "4", "Tags": [ "c#", "sorting", "recursion" ], "Title": "recursive bin packing" }
265926
<p>This is a simple implementation of the calendar(1) utility included in some UNIX systems (all BSDs have it, GNU has not). I do not have much experience with <code>&lt;sys/time.h&gt;</code> and <code>&lt;time.h&gt;</code></p> <p>Manual:</p> <pre class="lang-none prettyprint-override"><code>CALENDAR(1) ...
[]
[ { "body": "<p><strong>Missing error checks</strong></p>\n<pre><code>t = time(NULL);\nif (t == -1) handle_error_gracefully();\ntmorig = localtime(&amp;t);\nif (tmorig == NULL) handle_error_gracefully();\n</code></pre>\n<p><strong>Simplify</strong></p>\n<p>Value check not needed.</p>\n<pre><code>// if ((errno == ...
{ "AcceptedAnswerId": "265975", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T01:12:43.493", "Id": "265928", "Score": "3", "Tags": [ "c", "datetime", "reinventing-the-wheel", "posix", "to-do-list" ], "Title": "UNIX calendar(1) in C" }
265928
<p>It's my first time using stack exchange and getting my code reviewed, so if you find any issues with this post, please tell me. Anyway, I have done a very simple program in JS to find the average length of a decimal number created by a Math.random() function. The program works well, but since I'm new to coding, any ...
[]
[ { "body": "<ol>\n<li>(Styling) First thing that you should consider is to apply formatting:\n<ol>\n<li>Your tabs are not consistent.</li>\n<li>In most code styles, you should have a single space between // and text.</li>\n</ol>\n</li>\n<li>You should declare variables only when they are started to be used. Do n...
{ "AcceptedAnswerId": "265943", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T02:07:23.700", "Id": "265931", "Score": "6", "Tags": [ "javascript" ], "Title": "Basic AVG length of a decimal number program" }
265931
<p>Cancel the old timeout for the trip. Find the trip by Id validate it. Find the new driver not in old driver. If driver not found Try again</p> <p>Sent request to the new driver. Update the trip driver. Sent the socket request to the driver.</p> <pre><code> console.log(&quot;sendNewDriverRequest&quot;, tripId, typeo...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T03:09:23.640", "Id": "265932", "Score": "0", "Tags": [ "node.js", "socket" ], "Title": "Does using the multiple setTimeout decrease the performance of the nodejs app" }
265932
<p>A very simple function that can be used such that it returns a pointer to the first character on which <code>func</code> returned <code>0</code>. However, it also handles escaped lines. Needless to say this could be very useful in my cases, for example skipping spaces when converting a csv to an array.</p> <pre><cod...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T04:35:11.757", "Id": "525281", "Score": "0", "body": "What should happen if func returns true on '\\\\', like `ispunct`?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T04:46:51.540", "Id": "52528...
[ { "body": "<h3>Code Review</h3>\n<p><strong>Problem #1</strong></p>\n<p>In the function header <code>char *skip (const char *src, int(*func)(int))</code>, in particular, making the argument <code>char *src</code> a <code>const</code> does not make much sense, as it is not regarded as so throughout the function....
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T04:09:59.820", "Id": "265934", "Score": "1", "Tags": [ "c", "strings", "parsing" ], "Title": "Function to skip characters" }
265934
<p>A unix convention is to use <code>-</code> as a placeholder for stdin/stdout in command lines, e.g. <code>gcc -x c -</code> to compile stdin as C. I often find myself writing logic to get this behavior in my Python scripts, so I abstracted it out into a context manager:</p> <pre class="lang-py prettyprint-override">...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T16:40:47.557", "Id": "525343", "Score": "0", "body": "Is there a reason you don't use [`type=argparse.FileType(\"r\")`](https://docs.python.org/3.9/library/argparse.html#argparse.FileType) to get automatic handling of '-' as a comma...
[ { "body": "<p>The code can be simplified using the <code>contextlib.contextmanager</code> decorator:</p>\n<pre><code>from contextlib import contextmanager\n\n@contextmanager\ndef argfile(default: IO, filename: str, mode: str = 'r'):\n file_like = open(filename, mode) if filename != '-' else default\n yiel...
{ "AcceptedAnswerId": "265978", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T04:48:31.650", "Id": "265935", "Score": "0", "Tags": [ "python", "python-3.x" ], "Title": "argfile: read/write stdio or specified file depending on command line argument" }
265935
<p>I am solving the 2D Wave Equation using Fourier Transform. The Discrete Fourier Transform (and the inverse also) is done inside the <code>kx</code>-loop and <code>ky</code>-loop. But this code runs slow, is there anyway to make it much more efficient? I guess the <code>kx</code>-loop, <code>ky</code>-loop inside the...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T07:11:26.583", "Id": "525380", "Score": "0", "body": "You should never ever compute the discrete Fourier transform from the definition. Instead, use FFT (fast Fourier transform). There are packages like P3DFFT, FFTW3, FFTPACK and so...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T04:56:07.650", "Id": "265936", "Score": "0", "Tags": [ "performance", "mathematics", "numerical-methods", "signal-processing", "fortran" ], "Title": "2D Discrete Fourier T...
265936
<p>My daughter and I are trying to teach ourselves Python and OOP. We wrote a hangman game, and we'd really appreciate some feedback. Are we heading in the right direction? How could we improve it? Anything that makes a Python programmer go &quot;ouch&quot;? Anything that makes an OOP expert cringe? All sorts of questi...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T07:32:38.387", "Id": "525289", "Score": "3", "body": "It's not an answer neither the code review but I recommend writing unit tests for your code which helps to decompose your code better while giving insights on the dependency mana...
[ { "body": "<p>From the first looks, quite nice. I have mostly just a few smaller\nconcerns:</p>\n<ul>\n<li>Consistency matters for readers, so should be either <code>x = y</code>, <code>x= y</code>\nor <code>x =y</code> (or any variant really). Using\n<a href=\"https://black.readthedocs.io/en/stable/\" rel=\"...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T07:19:59.427", "Id": "265940", "Score": "15", "Tags": [ "python", "beginner", "object-oriented", "hangman" ], "Title": "OOP Hangman Game" }
265940
<p>The aim of the implementation is divide an array to two sub array which the total of the every sub array should be equal. If Array is dividable then method return <code>true</code> else return <code>false</code>.</p> <p>For example:</p> <p>This array can be dividable to two sub parts and each sub array sum is equal ...
[]
[ { "body": "<blockquote>\n<p>The aim of the implementation is <strong>divide an array to two sub array</strong> which the total of the every sub array should be equal. If Array is dividable then method return true else return false.</p>\n</blockquote>\n<p>The aim is clearly not met by your code; you never actual...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T10:17:21.980", "Id": "265945", "Score": "1", "Tags": [ "java", "array" ], "Title": "Is Array Separable To Two List" }
265945
<p>I recently started making a game in JavaScript, but I've only really built the renderer. This is the first 'real' game I started working on and I don't know if I'm doing any major things wrong and if there's things to improve.</p> <p><strong>renderer.js</strong></p> <pre><code>function Renderer(atlas){ this.canv...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T14:24:39.143", "Id": "525315", "Score": "0", "body": "Just an idea: you could scale using the height of the atlas if you have an atlas consisting of subsequent images. Generally, if you still have literals such as 16 in your code, y...
[ { "body": "<pre><code>this.loaded = 0;\n</code></pre>\n<p>I don't see the point of this variable; not much longer it will be set to 1, but it is never exposed anywhere.</p>\n<hr />\n<pre><code>this.width = this.canvas.width = screen.width;\nthis.height = this.canvas.height = screen.height;\n</code></pre>\n<p>I ...
{ "AcceptedAnswerId": "265958", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T10:38:12.387", "Id": "265946", "Score": "2", "Tags": [ "javascript", "beginner" ], "Title": "A renderer; JavaScript game beginnings" }
265946
<p>I am working on a test infrastructure that can help developers in a web api project. Below I wrapped up assertion classes. However when we increase the number of verification classes then it will look weird like it does right now :)</p> <p>Do you have any clear idea to refactor this code piece?</p> <pre><code>public...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T04:55:03.937", "Id": "525378", "Score": "1", "body": "could you explain the purpose of these classes, and how and when it's going to be used. As it seems you're trying to create a unit test, while there are multiple testing tools al...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T10:49:24.607", "Id": "265947", "Score": "0", "Tags": [ "c#", "integration-testing" ], "Title": "Repeated generic type instances with generic method" }
265947
<p>Below is a simple calculator program in which I'm using break statements to control the logic. I was wondering if this is overkill on the break statements or is it OK.</p> <pre><code>while True: try: print(&quot;Choose operation(+ | - | * | / | Enter 'e' to exit)&quot;) op=input() if op!=...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T15:13:25.180", "Id": "525325", "Score": "0", "body": "Welcome to Code Review! Your post looks fine, hope you get some good answers!" } ]
[ { "body": "<h1>Choosing an Operation</h1>\n<p>You can use a dictionary, rather than <code>if/elif/else</code> statements to choose operations more cleanly:</p>\n<pre class=\"lang-py prettyprint-override\"><code>from operator import add, sub, mul, truediv\n\nOPERATIONS = {\n '+': add,\n '-': sub,\n '*':...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T12:40:37.967", "Id": "265953", "Score": "3", "Tags": [ "python", "calculator" ], "Title": "Basic calculator using break statements to control the logic" }
265953
<p>I read about, that I only should have up to two parameters and a function should have about 10 lines. Now I am in trouble to achieve this. It is a Javascript/JSON thing in C#.</p> <p>I have too many parameters and too many lines in a function and I would like to reduce it. I reduced it already, but what can I do bet...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T19:47:34.310", "Id": "525353", "Score": "1", "body": "what is the difference between strcture id and folder id ? could you provide a data sample data for both ?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2...
[ { "body": "<p>The whole <code>try block( //implement publish true when it is parent - false when it is child)</code> can be reduced to one line.</p>\n<pre><code>try\n{\n structureId = parent == # ? AddNewParentFolderId(...) : AddNewChildFolderId(...);\n}\ncatch\n{\n}\n</code></pre>\n<p>No need of the <code>pub...
{ "AcceptedAnswerId": "266143", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T14:06:54.467", "Id": "265957", "Score": "1", "Tags": [ "c#", "json" ], "Title": "Add a folder via JSON" }
265957
<p>I have for some time been frustrated by the limitations around enumerations in VBA. Googling didn't find anything really simple and comprehensive. So after a bit of head scratching I came up with the following code which provides a neat intellisense based solution for managing enums to allow easy access to</p> <ul...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T17:42:55.417", "Id": "525346", "Score": "0", "body": "`AsProperty` is not defined anywhere - is it supposed to be a public member of each enum, for example a member of `Enum Testing`? `AsCount` is not defined or implemented in the s...
[ { "body": "<p>Some thought in no particular order:</p>\n<hr />\n<p>Could the <code>Enums</code> predeclared Class be a standard module? That would avoid the need to have this check:</p>\n<blockquote>\n<pre><code>Private Sub Class_Initialize()\n \n If Not Me Is Enums Then\n \n VBA.Err.Raise _...
{ "AcceptedAnswerId": null, "CommentCount": "9", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T16:13:38.320", "Id": "265962", "Score": "4", "Tags": [ "vba", "enum", "properties" ], "Title": "A method for managing enumerations in VBA" }
265962
<p>I'm working through these Koans: <a href="https://github.com/paytonrules/typescript.koans#readme" rel="nofollow noreferrer">https://github.com/paytonrules/typescript.koans#readme</a></p> <p>I'm on file 3, collections, the very first function <code>foreach</code>:</p> <pre><code>export interface Dictionary&lt;T&gt; {...
[]
[ { "body": "<h2>Compilation errors</h2>\n<p>Here is the reason is why you got compilation errors. Compiler doesn't understands that if <code>collection</code> is <code>Array&lt;T&gt;</code>, then <code>iteratee</code> is <code>ArrayForEachIteratee&lt;T&gt;</code>.</p>\n<p>We should help compiler to realize that....
{ "AcceptedAnswerId": "265987", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T16:55:29.893", "Id": "265963", "Score": "0", "Tags": [ "typescript" ], "Title": "Having trouble with this Koan - solved it, but I don't think what I wrote is correct in regards to Typ...
265963
<p>Im trying to implement a plugin system. A plugin is a compressed gzip tarball with files and folders. The tar file gets extractet and stored in memory. (The files are never written to the filesystem)</p> <p>Now with all the content of the files in memory, i load/compile the content of the entry file. For that i foun...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-07-17T20:05:42.083", "Id": "265965", "Score": "0", "Tags": [ "node.js" ], "Title": "manipulate \"require\" to load files from a \"virtual file system\"/in-memory" }
265965
<p>I'm writing a breadth first search algorithm in Haskell that supports pruning. It is guaranteed that the search will never encounter nodes that have been visited before, so I implemented the search as a <code>filter</code> along a stream of candidates.</p> <p>I'm concerned about the efficiency of the code. Is there ...
[]
[ { "body": "<p>Your</p>\n<pre><code>bfs feasible interesting branches tree = \n filter feasible . \n concat . takeWhile(&gt;[]) .\n iterate(concatMap branches . filter interesting)[tree] \n</code></pre>\n<p>is about as efficient as you can get if you also prune some of your finds. Otherwise you can save some...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T19:51:19.777", "Id": "265967", "Score": "4", "Tags": [ "performance", "haskell", "breadth-first-search" ], "Title": "Breadth first search on trees in Haskell" }
265967
<p>Could someone please help me out, I'm trying to remove the need to iterate through the dataframe and know it is likely very easy for someone with the knowledge.</p> <p>Dataframe:</p> <pre><code> id racecourse going distance runners draw draw_bias 0 253375 178 Standard 7.0 13 2 0.50 1 253375 178 Standa...
[]
[ { "body": "<p>Sorry, this is not a complete solution, just an idea.</p>\n<p>In Pandas you can split a data frame in subgroups based on one or multiple grouping variables using the <code>groupby</code> method. You can then apply an operation (in this case <code>nunique</code>) to each of the subgroups:</p>\n<pre...
{ "AcceptedAnswerId": "266030", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T20:23:57.220", "Id": "265968", "Score": "0", "Tags": [ "python", "pandas" ], "Title": "add column with count by constraint" }
265968
<p>I am just beginning to learn Python, and thought I would give myself a challenge using the lessons I have learned so far. I am following the Udemy course, Automate the Boring Stuff with Python. The point that I've reached so far has covered the basics of functions, handling errors, lists and dictionaries.</p> <p>I w...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T14:17:13.690", "Id": "525396", "Score": "1", "body": "Just a quick comment addressing question (4): your use of `del` and `copy.deepcopy` is probably one of the bad habits that you don't want to develop. Usually you don't want or ne...
[ { "body": "<p>As an...InTeRmEdIaTe...I think I <em>can</em> give some recomendations/advice about this.</p>\n<ol>\n<li>When building something don't think about what data structures or syntax features are you going to use. You can search for example &quot;python dictionary/loops exercises&quot; for practicing t...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T21:31:01.307", "Id": "265972", "Score": "3", "Tags": [ "python", "beginner", "tic-tac-toe" ], "Title": "Beginner learner: Python 3.9.6 tic-tac-toe code and questions about optimiz...
265972
<p>I'm trying to capture all input fields in a form (i.e. sign_up.html) &amp; validating them - if one of them is null or empty then it should show a validation message. I've done it but I'm looking for an elegant way to do it.</p> <h2>sign_up.html</h2> <pre><code>{% extends &quot;layout.html&quot; %} {% block main %...
[]
[ { "body": "<h2>Readability</h2>\n<p>Before addressing the main concern, readability should be addressed.</p>\n<p>Many python developers adhere to <a href=\"https://www.python.org/dev/peps/pep-0008/\" rel=\"nofollow noreferrer\">PEP8</a> for consistent code style.</p>\n<p>This code does not adhere to a few aspec...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-11T21:49:15.250", "Id": "265974", "Score": "3", "Tags": [ "python", "python-3.x", "validation", "flask" ], "Title": "Displaying validation messages for an input form" }
265974
<p>From <a href="https://github.com/App-vNext/Polly" rel="nofollow noreferrer">GitHub</a>:</p> <blockquote> <p><a href="http://www.thepollyproject.org" rel="nofollow noreferrer">Polly</a> is a .NET resilience and transient-fault-handling library that allows developers to express policies such as <a href="https://github...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T09:40:12.123", "Id": "265984", "Score": "0", "Tags": null, "Title": null }
265984
"Polly is a [...] resilience and transient-fault-handling library" for ".NET Standard 1.1 and .NET Standard 2.0."
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T09:40:12.123", "Id": "265985", "Score": "0", "Tags": null, "Title": null }
265985
<h1>Overview</h1> <p>I am working on an android To-Do app. I have a piece of code that I use to work with tasks.I am new to android development and want to grow, so I would really like someone to rate my code and tell me how i can make it better.</p> <h1>Code</h1> <p>TaskManager.kt</p> <pre><code>class TaskManager { ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T13:19:02.660", "Id": "525455", "Score": "1", "body": "Since Code Review doesn't get a ton of daily traffic, you might not want to be so quick to accept an answer, because it discourages further answers that might provide additional ...
[ { "body": "<p>The word &quot;manager&quot; is a class name trap. It's vague and if you don't have a clear idea of exactly what the class is responsible for, you're in danger of violating the single responsibility principle. You might be tempted to add too much functionality into this one class.</p>\n<p>But in y...
{ "AcceptedAnswerId": "266005", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T11:56:41.460", "Id": "265988", "Score": "1", "Tags": [ "android", "kotlin", "to-do-list" ], "Title": "Code for working with a tasks in To-Do Android application" }
265988
<p>I want to learn Java, so I ported a C# Enigma implementation of mine. It got UnitTests and is running.</p> <p>I'm looking for a review, telling me, where I don't know best practices, where I break naming conventions, where I look like a C# programmer writing Java:-)</p> <p>Thanks &amp; have fun Harry</p> <p><a href=...
[]
[ { "body": "<p>Basically, I don't see too many C# - Java issues other than the method naming and the enum, where you seemed to have gone from <code>namespace</code> to <code>class</code> while the class is unnecessary in Java.</p>\n<p>Unfortunately I see a lot of problems that would be equally bad in C# as well ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T11:58:10.893", "Id": "265989", "Score": "4", "Tags": [ "java", "beginner", "cryptography" ], "Title": "Enigma Implementation by JAVA newbie" }
265989
<p>I want to learn Python, so I ported a C# Enigma implementation of mine. It got UnitTests and is running.</p> <p>I'm looking for a review, telling me, where I don't know best practices, where I break naming conventions, where I look like a C# programmer writing Python:-)</p> <p>Thanks &amp; have fun Harry</p> <p><a h...
[]
[ { "body": "<p>First, a warm welcome to the python language! None of this is in any particular order.</p>\n<h1><code>argparse</code></h1>\n<p>There is a really nice argument parsing library available out of the box which makes parsing command line args much less clunky. I'd set up your parser like this:</p>\n<pr...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T12:45:28.667", "Id": "265990", "Score": "4", "Tags": [ "python", "beginner", "cryptography" ], "Title": "Enigma Implementation by Python newbie" }
265990
<p>The following bash code is meant to check every second the amount of NEW (relative to the last second) network socket files. at the end of the run it summarizes every 60 entries (should be 60 seconds) and output a file called verdict.csv that tells me how many new network sockets were opened in that minute (I run un...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T21:05:25.547", "Id": "525431", "Score": "1", "body": "It's possible that another tool could yield better performance than lsof but make sure you are aware of all the available command line arguments to fine tune your request. I woul...
[ { "body": "<h1>Temporary files</h1>\n<p>Don't assume that <code>/tmp/</code> is the right location for temporary files - if <code>$TMPDIR</code> is set, we should prefer that directory instead (e.g. which <code>pam_tmpdir</code> is used for per-user temp directories).</p>\n<p>It's a good idea to create a single...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T13:04:29.030", "Id": "265991", "Score": "2", "Tags": [ "performance", "bash" ], "Title": "bash script to collect new network sockets in a given period of time" }
265991
<p>In my web app, I am trying to secure a payment transaction, that is:</p> <ol> <li>prevent users spending more than they have, especially in the case of concurrent execution</li> <li>and prevent partial execution.</li> </ol> <p>Additional details:</p> <ul> <li>Orders can be partially paid, we store the amount already...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T16:18:33.560", "Id": "525410", "Score": "0", "body": "Just curious why you don't use `transaction` :/" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T16:22:09.977", "Id": "525412", "Score": "0...
[]
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T14:22:03.413", "Id": "265993", "Score": "0", "Tags": [ "javascript", "mysql", "typescript", "locking", "transactions" ], "Title": "Trying to secure a payment transaction w...
265993
<p>Hello I have this function that looks for nested value 3 levels deep currently</p> <pre><code> // This handle nested data to be applied to filter option which comes from filterProps.prop values // This is currently chained 3 level deep I.E clock.props.children to add more just keep chaineding const handleNestFi...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T16:12:17.810", "Id": "525409", "Score": "1", "body": "(Tagging with a programming language is quite enough, [including the language name in the title without special reason is frowned upon](https://codereview.meta.stackexchange.com/...
[ { "body": "<p>For me, using nested conditional expression makes the code very hard to understand, I think you should use <code>if</code> and <code>switch</code> statements for readability. It's difficult to understand what your code returns in each case so I only write the structure of the code.</p>\n<pre class...
{ "AcceptedAnswerId": "265998", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T15:03:51.357", "Id": "265994", "Score": "0", "Tags": [ "javascript", "performance", "algorithm", "array", "lodash.js" ], "Title": "Javascript: Reducing redundancy of n...
265994
<p>First post. I posted this on stack as well but somebody suggested I post it here too/instead.</p> <p>I wrote a shortest-path script for a Unity game project, and while it works, it gets so slow when applied at scale that it crashes Unity when executed. This is to say, it works slowly for a single test character, but...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T09:09:51.203", "Id": "525445", "Score": "3", "body": "Pathfinding is a _notoriously_ difficult problem, especially when balancing performance and scalability. It may be considerably more fruitful to look at existing pathfinding algo...
[ { "body": "<p><code>void ExploreBranch(List&lt;Point&gt; stem, List&lt;List&lt;Point&gt;&gt; masterList, Point target)</code></p>\n<p>Based on this signature, I can't understand what this function takes in (what is a &quot;masterList&quot;? what is a &quot;stem&quot;?). Since it returns <code>void</code>, I can...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T15:45:18.067", "Id": "265995", "Score": "2", "Tags": [ "c#", "time-limit-exceeded", "pathfinding", "unity3d" ], "Title": "Shortest route algo terribly slow" }
265995
<p>I was told that the following code of mine was poorly written. How bad is it? Do you have any recommendations?</p> <pre><code> #include &lt;iostream&gt; #include &lt;fstream&gt; void ioMenu(std::ifstream&amp;, std::ofstream&amp;, std::string&amp;, std::string&amp;); int ioMenuChoice(); void fileOpener(std::ifstream...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T17:22:37.187", "Id": "525418", "Score": "0", "body": "Welcome to Code Review! I [changed the title](https://codereview.stackexchange.com/posts/265999/revisions#rev-body-09f198ac-3467-4bb0-a637-981b1e57e594) so that it describes what...
[ { "body": "<p>Well, the first thing that jumps out is that there is no <code>const</code> in any of the parameters.</p>\n<p><code>void fileOpener(std::ifstream&amp;, std::ofstream&amp;, std::string&amp;, int&amp;);</code></p>\n<p>for example, the 3rd and 4th parameters are &quot;out&quot; parameters? This indi...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T16:27:57.063", "Id": "265999", "Score": "1", "Tags": [ "c++", "io" ], "Title": "File reader and writer" }
265999
<p>This is the first project I have ever undertaken and now that I've gotten it to a point I feel comfortable with, I would love to get some review and tips for any improvement on it! I am especially interested in getting tips on the design, readability and unit testing part of my code and any and all tips for improvem...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T18:47:10.573", "Id": "525704", "Score": "1", "body": "Welcome to Code Review! I have rolled back Rev 4 → 3. Please see [_What to do when someone answers_](https://codereview.stackexchange.com/help/someone-answers)." } ]
[ { "body": "<p>Welcome to code review! There is a lot of code and a lot to say, but I will concentrate on <code>Storage</code> as it is a fairly central component that affects the quality of all other classes.</p>\n<p>You should study the <a href=\"https://en.wikipedia.org/wiki/SOLID\" rel=\"nofollow noreferrer\...
{ "AcceptedAnswerId": "266024", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T17:41:14.057", "Id": "266001", "Score": "2", "Tags": [ "java", "beginner", "object-oriented", "to-do-list" ], "Title": "A to-do list application written with Java" }
266001
<p>I have a function called <code>USB()</code>, that will observe a <a href="https://en.wikipedia.org/wiki/USB_flash_drive" rel="nofollow noreferrer">USB stick's</a> insertion and delete files inside of it, if there are some:</p> <pre><code>import os import shutil # 1. Check and clean USB def USB(): usb_inserted ...
[]
[ { "body": "<h1>Boolean Checks</h1>\n<p>Instead of doing:</p>\n<pre class=\"lang-py prettyprint-override\"><code>if usb_inserted == False:\n # do something\n</code></pre>\n<p>use</p>\n<pre class=\"lang-py prettyprint-override\"><code>if not usb_inserted:\n # do something\n</code></pre>\n<h1><code>while not...
{ "AcceptedAnswerId": "266081", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T20:37:55.113", "Id": "266009", "Score": "6", "Tags": [ "python", "python-3.x" ], "Title": "USB stick condition check and file deleting function" }
266009
<p>I've started my journey of learning assembly on my Mac. As a start, I've decided to write a program to print the numbers one through ten to the console, then a final string signifying the end of the program. I want to kick bad habits to the curb quick, and know if there's any optimizations I can make to this code. A...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-25T20:23:51.853", "Id": "526280", "Score": "1", "body": "You can add to *i* with a single instruction `addl $1, -20(%rbp)`" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-25T20:26:30.407", "Id": "526281...
[ { "body": "<blockquote>\n<p>I want to kick bad habits to the curb quick, and know if there's any optimizations I can make to this code</p>\n</blockquote>\n<p>Sure thing. I'll look past the option to print all text at once without a loop though, that would be an optimization but it wouldn't be as instructive or ...
{ "AcceptedAnswerId": "266014", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-12T21:38:09.330", "Id": "266011", "Score": "1", "Tags": [ "beginner", "assembly", "x86" ], "Title": "Printing one to ten in (GAS/AT&T x86/x64) assembly" }
266011
<p>Currently I am working on a project for which I want to have the different links (div elements) placed randomly on my webpage. To accomplish this, I first generate a set of coordinates and later check whether they overlap (<a href="https://stackoverflow.com/questions/68734459/how-to-make-sure-randomly-generated-divs...
[]
[ { "body": "<h2>Style</h2>\n<p>Some styling points</p>\n<ul>\n<li><p>Names. You have some poor naming</p>\n<ul>\n<li>The JavaScript naming convention is <code>camelCase</code> avoid using <code>snake_case</code></li>\n<li>Use the context of the function to imply additional meaning. Eg you have <code>maxWidth</co...
{ "AcceptedAnswerId": "266061", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T01:23:34.723", "Id": "266019", "Score": "2", "Tags": [ "javascript", "html", "css", "random", "layout" ], "Title": "Randomly place Divs on webpage and make sure they d...
266019
<p>I have two <code>ArrayList</code>s of objects and the after comparison I am taking out the value which has a difference based on the attribute.</p> <p>So in my condition when the <code>deptCode</code> is the same in both lists but <code>deptName</code> is different then the output will be the updated <code>deptName<...
[]
[ { "body": "<p>Welcome to the site!<br />\nI doubt that there are much better ways to do what you want to do here. You'll always have to compare each element of <code>list</code> to each of <code>depList</code>. Databases have to do similar things like this; you could try resarching in that direction (index, ......
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T05:07:00.883", "Id": "266021", "Score": "1", "Tags": [ "java", "performance", "array" ], "Title": "How to take out attribute from two ArrayList of object which have different matc...
266021
<p>I'm very new with Go (started to learn it two weeks ago) and I would like to get your comments on the code below. The code is implementation of identifier used by DHT (Kademlia) The code works as expected in tests.</p> <pre><code>package identifier import ( &quot;fmt&quot; &quot;math/bits&quot; ) type idBu...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-27T21:25:41.020", "Id": "526414", "Score": "0", "body": "do you mind to get ride of the unsafe thing ?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-28T09:22:12.970", "Id": "526440", "Score": "2",...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T12:00:38.847", "Id": "266032", "Score": "1", "Tags": [ "go" ], "Title": "Kademlia identifier package written in go" }
266032
<p>In a larger project, I need a (rather simple) expression parser able to accept numerical values, operators and string identifiers. Fine, a lexical parser fed with some input which gives <em>tokens</em> one at the time to the syntactic parser. As a token can contain one single value type at a time, I decide to use an...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T15:57:42.830", "Id": "525467", "Score": "1", "body": "You’ve basically just reimplemented [`std::variant`](https://en.cppreference.com/w/cpp/utility/variant)." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021...
[ { "body": "<p>In order to do what you want, you can either have (non-union'ed) members of different types and only one is populated, which is your approach;<br />\nor, you can use a byte array buffer large enough to hold any of the different types, and in-place construct and destruct the actual object there. T...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T14:54:32.173", "Id": "266035", "Score": "1", "Tags": [ "c++", "lexical-analysis" ], "Title": "A Token class for a lexical parser" }
266035
<p>I have recently gotten back into writing python and i decided to take up a project of writing a backtracking algorithm in python to solve Sudoku puzzles</p> <p><strong>How it Works</strong></p> <p>A matrix is declared to represent the Sudoku grid the blank spaces on the Sudoku grid are represented by zero A function...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T18:29:28.540", "Id": "525475", "Score": "1", "body": "Does this work as expected? I suspect that your `Answer_Valid` has a `return True` at the wrong level of indentation, which would in turn manifest as a bug where only the first c...
[ { "body": "<p>Here are a few comments in no particular order:</p>\n<ul>\n<li><p>To find the time taken to solve the sudoku, you are now taking into account the time taken to declare the functions used and the time taken to print to std. Probably that is not intended.</p>\n</li>\n<li><p>As per PEP-8, function na...
{ "AcceptedAnswerId": "266054", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T14:58:13.907", "Id": "266036", "Score": "6", "Tags": [ "python", "algorithm", "recursion", "sudoku", "backtracking" ], "Title": "Python backtracking algorithm to solve...
266036
<p>I have a list of dictionaries <code>x</code> and a list of random numbers <code>x_randoms</code>. I want to update each of the dictionaries with the values from the list of random numbers. I've done the following and it works, but it feels a bit strange:</p> <pre><code>import random x = [{'key1': '123', 'key2': {'k...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T18:27:22.783", "Id": "525474", "Score": "2", "body": "This is too hypothetical to be on-topic, unfortunately." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T18:00:05.593", "Id": "525505", "Sc...
[ { "body": "<p>Instead of iterating over <code>range(len(x))</code> and ignoring the value, you can simply iterate over <code>x</code> and ignore the value:</p>\n<pre><code>x_randoms = [random.random() for _ in x]\n</code></pre>\n<p>Instead of enumerating <code>x</code> only to access <code>x_randoms</code>, you...
{ "AcceptedAnswerId": "266041", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T16:58:51.493", "Id": "266039", "Score": "1", "Tags": [ "python" ], "Title": "Updating python dictionary in a loop" }
266039
<p>I am trying write a method that will calculate kendalls tau in O(n log n) time. I have a managed to it in O(n^2) quite easily however I cannot find any GOOD explanation online that will describe with ease how to code it in faster time complexity?</p> <p>Here are some links as to mentioning how a modified merge sort ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-13T21:00:00.310", "Id": "266043", "Score": "0", "Tags": [ "c#", "algorithm", "statistics" ], "Title": "How to do kendalls tau in O(n log n)? O(n^2) is shown" }
266043
<p>I am using Next.js and want to properly implement session management into this serverless architecture. I checked out nextauth but I am not really a fan and it doesn't implement some things I think I might need, so just trying to keep things simple and do it myself. I also read through express-session where most of ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T01:30:22.657", "Id": "266046", "Score": "1", "Tags": [ "javascript", "node.js", "session", "https" ], "Title": "How to implement robust and secure session management (in gener...
266046
<p>I wrote a binary search to find the closest element to x in an array. How can show the correctness of the algorithm for any cases? Because it handles with floating points and variable length arrays, there are many cases.</p> <pre class="lang-java prettyprint-override"><code>import java.util.Arrays; import java.util....
[]
[ { "body": "<h3>Variable names</h3>\n<p>It's hard to read the code with one-letter variables. Sometimes it could be justified (like <code>i</code> and <code>j</code> as loop variables or names that were mentioned in a task); but usually you should name them <code>array</code> instead of <code>a</code>, <code>bin...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T05:38:46.640", "Id": "266047", "Score": "0", "Tags": [ "java", "algorithm", "binary-search" ], "Title": "Binary search to find the closest element" }
266047
<p>This code was originally posted <a href="https://codereview.stackexchange.com/questions/265940/oop-hangman-game?noredirect=1#comment525419_265940">here</a>. An exercise into learning OOP and Python. A huge thanks for the time and effort that @ferada @Alex Waygood @m-alorda and others put into commenting on it.</p> <...
[]
[ { "body": "<p>This is a great improvement on the original code -- well done! A few points:</p>\n<p><strong>1. Still not <a href=\"https://pep8.org/\" rel=\"nofollow noreferrer\">PEP8</a>-compliant :(</strong></p>\n<p>There's still lots of places in your code where you don't have spaces around operators (sorry, ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T09:33:57.527", "Id": "266049", "Score": "3", "Tags": [ "python", "object-oriented" ], "Title": "OOP Hangman Game - amended code" }
266049
<h3>Introduction</h3> <p>I have implemented a generalization to the <a href="https://en.wikipedia.org/wiki/Inclusion%E2%80%93exclusion_principle" rel="nofollow noreferrer">inclusion-exclusion principle</a>, which extends the principle from sets to more general objects. In short the principle calculates the left by doin...
[]
[ { "body": "<ul>\n<li><p><code>reduce_w_cache</code></p>\n<ul>\n<li><p>Prone to hitting recursion limits.\nYou should use an iterative approach not a functional one.</p>\n<pre class=\"lang-py prettyprint-override\"><code>&gt;&gt;&gt; reduce_w_cache(int.__add__, (1,) * 1000)\nTraceback (most recent call last):\n ...
{ "AcceptedAnswerId": "266065", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T09:55:20.027", "Id": "266051", "Score": "2", "Tags": [ "python", "python-3.x", "object-oriented", "classes" ], "Title": "Extending the inclusion-exclusion principle to gen...
266051
<p>I'm currently trying to improve my ChaCha algorithm implementation. Here's the my code (written in C):</p> <pre><code>#include &lt;string.h&gt; // memcpy #include &lt;stddef.h&gt; // size_t #include &lt;stdint.h&gt; // uint32_t typedef uint32_t ChaChaSigma [4]; typedef uint32_t ChaChaKey [8]; typedef uint32_t ChaCh...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T17:30:07.350", "Id": "525501", "Score": "0", "body": "I don't think that 1. it is possible, as you cannot magic the possible carry out of nothing and 2. that it would make any difference." }, { "ContentLicense": "CC BY-SA 4....
[ { "body": "<p>A small review</p>\n<blockquote>\n<p>trying to improve my ChaCha algorithm implementation</p>\n</blockquote>\n<p><strong><code>static</code> function</strong></p>\n<p><code>rotl32()</code> is not a well defined function for rotating when the count is 0 (or 32). That does not matter here as <code>...
{ "AcceptedAnswerId": "266066", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T12:26:18.623", "Id": "266052", "Score": "3", "Tags": [ "performance", "algorithm", "c" ], "Title": "Efficient (a XOR (b+1)) known (a XOR b) in C for the ChaCha algorithm" }
266052
<p>I recently got this question in an exam, this is how I implemented, it is working fine. However, I would like to know if the code can be improved, as I think it for sure needs to be improved. The question was:</p> <blockquote> <p>In the past, Twitter had a 140 characters limitation per tweet. If you wanted to enter ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T14:45:33.713", "Id": "525497", "Score": "1", "body": "Do you have a constraint that the number of tweets will be fewer than 10? If not, the problem becomes a bit more challenging to use up every available character." }, { "C...
[ { "body": "<p>Overall, your code does the job correctly, and does it in a way that is not unnecessarily complicated. Good job. The rest of my comments are just how you can make the code a little easier to read, because the simpler it is to read, the easier it will be to tackle the bonus problem.</p>\n<p>To star...
{ "AcceptedAnswerId": "266072", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T12:50:23.930", "Id": "266053", "Score": "7", "Tags": [ "java", "algorithm", "strings", "array" ], "Title": "Create tweet threads from String in Java" }
266053
<p>I've Never really made a game or such in python but was bored, so I tried to make a hangman game. I don't like how many if else statements I used but I can’t think of a better way to do it. Any feedback is appreciated!</p> <pre class="lang-py prettyprint-override"><code># global varibles SECRET_WORD = &quot;Python&q...
[]
[ { "body": "<p>I have split up my suggestions into various sections. Overall the code was pretty well formatted, there were some small syntax changes I would recommend as well as a bit of potential restructuring of your code.</p>\n<h2>Function Docstrings &amp; declarations</h2>\n<p>For your <code>blank_letters()...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T18:33:46.917", "Id": "266059", "Score": "5", "Tags": [ "python", "hangman" ], "Title": "First Time Making A hangman game" }
266059
<p>taking into account the <strong>scale2x</strong> algorithm for scaling an image to 2x. Im using <strong>winapi</strong> in an Emulator. When tha scale2x algorithm is used <strong>i don't see too much difference in the image scaled2x</strong> as it states in <a href="https://www.scale2x.it/algorithm" rel="nofollow no...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T22:02:29.267", "Id": "525506", "Score": "0", "body": "What are you expecting more? The top image is smoother." } ]
[ { "body": "<p>There are a couple of challenges to reviewing this:</p>\n<ol>\n<li>You don’t mention what version(s) of C++ you are targeting. I will assume C++20, because that’s the current standard.</li>\n<li>You don’t provide any example of how this code is going to be used. I have no way of knowing if this in...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T18:38:16.757", "Id": "266060", "Score": "1", "Tags": [ "c++", "winapi" ], "Title": "C++ winapi scale2x algorithm. Is it well implemented?" }
266060
<p>I am new to web development and would like to get feedback on a JavaScript library that automatically finds and replaces text on a webpage using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver" rel="nofollow noreferrer">MutationObserver</a> interface.</p> <p>EDIT: Seeing that this has ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T19:11:01.767", "Id": "266062", "Score": "4", "Tags": [ "javascript", "beginner", "html", "dom" ], "Title": "Find and replace text in a webpage with JavaScript" }
266062
<p>The problem is that we have an unsolved sudoku board, and we want to validate it, we need to check each column, row and sub-square.</p> <p>Here we represent a empty cell with -1.</p> <p>My idea was to create a multi-threaded solution to this problem, where we deal with each case.</p> <p>I didn't know how to pool thr...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T01:59:04.597", "Id": "525510", "Score": "0", "body": "I'm not really clear what validating an empty sudoku would entail. I can understand validating a proposed solution, but not an empty board. `arrayIn` is a 4x4 matrix with negativ...
[ { "body": "<p>I usually like to rewrite symbols like</p>\n<pre><code>#define threadNum 4\n#define squareUnit 2\n#define square 4\n</code></pre>\n<p>as <code>static const int</code>s, since that makes the type easier to see.</p>\n<p>Since this is a single-translation-unit program, all of your functions other tha...
{ "AcceptedAnswerId": "266107", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-14T21:27:53.293", "Id": "266063", "Score": "1", "Tags": [ "c", "multithreading", "sudoku" ], "Title": "Validate Empty Sudoku: Multi-Threaded Solution" }
266063
<h2>Function:</h2> <p>Outputs daily and weekly dose totals with means for time between doses and dose amount.</p> <h3>Code:</h3> <pre class="lang-py prettyprint-override"><code> from decimal import Decimal from dataclasses import dataclass from typing import List, Dict, Iterable, Collection UNIT = 'u' SUBSTANCE = 'sub...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T14:04:20.627", "Id": "525526", "Score": "0", "body": "What is the \"real\" way that data are going to be entered? Surely they won't be hard-coded. Will you have datetimes, rather than strictly days-of-the-week?" } ]
[ { "body": "<blockquote>\n<p>Am I correctly using classes?</p>\n</blockquote>\n<p>Very vaguely yes, though there's always room for improvement.</p>\n<blockquote>\n<p>Is this OOP?</p>\n</blockquote>\n<p>Yes!</p>\n<blockquote>\n<p>Please suggest improvements</p>\n</blockquote>\n<p><code>time_dose</code> has as its...
{ "AcceptedAnswerId": "266071", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T01:41:51.063", "Id": "266069", "Score": "3", "Tags": [ "python-3.x", "object-oriented", "classes" ], "Title": "Weekly Dose tracker with time and dose mean" }
266069
<p>I am brand new to programming in C. I am following along with the book &quot;The C Programming Language, Second Edition.&quot; I am making my own modifications to the example code presented in the book as I go along. Anyway I am posting my code here for review because I want to make sure I am off to a good start. Th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T07:55:58.700", "Id": "525513", "Score": "1", "body": "I don't have a copy of K&R ready, but how much of the code provided is theirs and how much of it is yours?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "20...
[ { "body": "<blockquote>\n<p>I want to make sure I am off to a good start.</p>\n</blockquote>\n<p><strong><code>float</code> vs <code>double</code></strong></p>\n<p>Save <code>float</code> for cases when serious reduced memory needed or when performance has compelled the use of narrow floating point, else use <c...
{ "AcceptedAnswerId": "266102", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T03:39:46.467", "Id": "266070", "Score": "2", "Tags": [ "c" ], "Title": "Fahrenheit to Celsius table temperature converter in C" }
266070
<p><code>element.parentNode.parentNode.children[3].innerHTML</code> is fine but not <code>element.parentNode.parentNode.querySelectorAll(&quot;:nth-child(3)&quot;).innerHTML</code> (outputs <code>undefined</code>)</p> <p>I also tried different numbers in <code>:nth-child()</code> but without any progress.</p> <p>Any id...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T04:35:12.303", "Id": "525546", "Score": "0", "body": "How `element.parentNode.parentNode.children[3].innerHTML` isn't a working code for me? What?" } ]
[ { "body": "<blockquote>\n<p>The Document method querySelectorAll() returns a static (not live)\nNodeList representing a list of the document's elements that match the\nspecified group of selectors.</p>\n</blockquote>\n<p>For this reason it returns you a list of nodes from the DOM, basically you can think of an ...
{ "AcceptedAnswerId": "266079", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T13:58:02.153", "Id": "266077", "Score": "-2", "Tags": [ "javascript", "css", "dom" ], "Title": "undefined instead of innerHTML" }
266077
<p>This is a follow-up question for <a href="https://codereview.stackexchange.com/q/263729/231235">Tests for the operators of image template class in C++</a>. As <a href="https://codereview.stackexchange.com/a/264348/231235">G. Sliepen's answer</a> mentioned, I am attempting to use <a href="https://www.boost.org/doc/li...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T23:54:05.010", "Id": "525542", "Score": "0", "body": "What will this cost be used for? Is it just practice for using boost.test?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T23:49:40.570", "Id"...
[ { "body": "<h1>Ensure you cover the basics</h1>\n<p>You have a lot of tests that check the operations on already created <code>TinyDIP::Image</code>s, but you lack tests to check that the creation and initialization of images works as expected. I would add something like this at least:</p>\n<pre><code>BOOST_AUT...
{ "AcceptedAnswerId": "267709", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T14:53:22.640", "Id": "266080", "Score": "0", "Tags": [ "c++", "unit-testing", "template", "boost", "overloading" ], "Title": "Unit Tests for the operators of image tem...
266080
<p>I created a quick &quot;demonstration of proposal behavior&quot; tool for my post on MSO: <a href="https://meta.stackoverflow.com/q/410790/2943403">A proposal to put ALL answerers on a path to curating better content</a>.</p> <p>Because I have never asked for a review before and I am not a JavaScript or CSS SME, I'd...
[]
[ { "body": "<h2>Declarations</h2>\n<p>Always declare variables that do not change as <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const\" rel=\"nofollow noreferrer\" title=\"MDN JavaScript statement reference. const\">const</a> rather than <a href=\"https://developer.mo...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-15T23:46:43.507", "Id": "266084", "Score": "0", "Tags": [ "javascript", "jquery", "html", "css", "user-interface" ], "Title": "HTML table with repeatable rows and live-calcul...
266084
<p>Firstly, the code relies on importing images, so I'll link to the repository as well as including the code here. If it's an issue that images need to be downloaded OR there is another solution please let me know and this post can be deleted and a more appropriate one can be made or I can annoy people on reddit with ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T09:27:09.427", "Id": "525557", "Score": "4", "body": "Don't be so hard on yourself, this is significantly better than most the crud you see on SO, nice docstrings and clear variable names are a good start:) Hope you get some useful ...
[ { "body": "<p>In no particular order:</p>\n<ul>\n<li>I found FEN notation very interesting! Thanks for sharing that.</li>\n<li><code>FEN</code> being a global that's read during <code>__init__</code> does not make sense. Instead, pass a <code>fen</code> parameter (as optional) that, if <code>None</code>, sets o...
{ "AcceptedAnswerId": "266101", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T02:18:36.383", "Id": "266085", "Score": "5", "Tags": [ "python", "object-oriented", "chess" ], "Title": "I'm writing a python chess UI+backend and I would like feedback on whe...
266085
<p>I'm currently writing a game of chess, and, more specifically, I'm creating the code for the game board. The board is simply a static class that contains a multi-dimensional array representing the board, and methods to interact with it. The method in question for the purposes of <em>this</em> question, is called <co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T09:41:33.043", "Id": "525563", "Score": "3", "body": "Any an all critiques of the code should be posted in answers. Posting critiques of the code in comments are subject to removal for being a violation of the [commenting privilege]...
[ { "body": "<p>Yes the code is readable.</p>\n<p>I'm curious why you feel you need multiple return statements. The return statement can return a boolean expression.</p>\n<pre><code>public static class GameBoard\n{\n private static GameEntity[,] _board = new GameEntity[8, 8];\n public static bool TryGetEnti...
{ "AcceptedAnswerId": "266100", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T02:40:24.120", "Id": "266086", "Score": "6", "Tags": [ "c#" ], "Title": "Is this try pattern to fetch entities from a chess board, easy to follow?" }
266086
<p>Well, it's not actually a <em>schema validator</em> but anyway...</p> <h1>Motivation</h1> <p>I'm writing a library which is a UI to work with some electronics - modules. Each real module is represented by a corresponding class in the library. I've decided to add the ability to program a module at once using the <em>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T20:34:41.050", "Id": "525616", "Score": "1", "body": "Seems like you're sort of trying to re-invent [`JSON Schema`](https://json-schema.org/). If you're interested primarily in the end result, maybe it would be easier to use this in...
[ { "body": "<pre><code> if ( ⋯ ) {\n if ( ⋯ ) {\n verdict = false;\n break;\n }\n }\n else\n {\n verdict = false;\n break;\n }\n }\n return verdic...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T06:35:37.037", "Id": "266090", "Score": "3", "Tags": [ "c++", "json" ], "Title": "Simple \"schema validator\" of JSON using JSON Patch (nlohmann:json)" }
266090
<p>I have a headless application that does either of two things.</p> <ol> <li>If table does not exist within database create it and copy all the data over</li> </ol> <p>OR</p> <ol start="2"> <li>If table exists update it</li> </ol> <p>Now I usually use access layers but this application is a bit older so I can't. This ...
[]
[ { "body": "<p>You have a lot of redundant code. Also, the <code>Start</code> method is very long and difficult to read. Basically, it executes three times the same procedure applied to different tables. The idea is to create a parametrized method that can be called three times for the three tables. This increas...
{ "AcceptedAnswerId": "266106", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T17:27:19.443", "Id": "266103", "Score": "0", "Tags": [ "c#", "sql" ], "Title": "Efficient way to build table within database or update it using C#" }
266103
<p>I write a function which takes as input 2 arrays of zeros and ones ~8000 elements per array. Input array size is variable, can have much higher number of elements. The density of ones is expected to be higher than zeros for most cases, but outliers may exist. My function <code>eps</code> calculates a statistic on th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-17T07:05:52.447", "Id": "525635", "Score": "1", "body": "Welcome to CodeReview@SE. See [How do I ask a Good Question?](https://codereview.stackexchange.com/help/how-to-ask) on how to title your question. Please include clarifications i...
[ { "body": "<p><code>for x,y in product(event_index1,event_index2)</code> looks like an efficiency killer. If the lengths of <code>event_index1, event_index2</code> are <code>L1, L2</code> respectively, this loop has <code>O(L1 * L2)</code> time complexity. You may get away with <code>O(L1 * log L2)</code> (or <...
{ "AcceptedAnswerId": "266113", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T20:05:08.367", "Id": "266108", "Score": "13", "Tags": [ "python", "algorithm", "numpy" ], "Title": "Iterate through two arrays calculating a statistic from indexes of zeros" }
266108
<p>I have a workbook that loads in the results of an SQL query into two worksheets called Old and New. The New worksheet is then edited by an end user. Rows can be inserted, deleted and values changed. There is a unique key in column M. With the following code, I am able to detect changes between Old and New, additions...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T23:25:35.433", "Id": "525620", "Score": "0", "body": "Have you already tried using the [comapare feature built-in to Excel](https://support.microsoft.com/en-us/office/basic-tasks-in-spreadsheet-compare-f2b20af8-a6d3-4780-8011-f15b32...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-08-16T22:00:55.050", "Id": "266110", "Score": "0", "Tags": [ "vba", "excel" ], "Title": "Fastest Way To Compare 2 Excel Worksheets And Output Differences To 3rd Worksheet" }
266110