body
stringlengths
25
86.7k
comments
list
answers
list
meta_data
dict
question_id
stringlengths
1
6
<p>Im not that good at C, so go easy on me, but I wanted to be able to have individual bit access in C without using a ton of functions to do bit manipulation on a <code>uint8_t</code>. Tell me where I could improve upon it</p> <pre><code>#include &lt;stdio.h&gt; #pragma pack(1) union bit_array { struct { ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-18T23:22:46.777", "Id": "512296", "Score": "5", "body": "Your current code does not show how you intend to use the bitwise access. The `main` function should demonstrate exactly that, but in the code you posted, it doesn't. Without thi...
[ { "body": "<p>This code is not portable. The order of bit-fields within a word is completely compiler-dependent, so the test that appears to work on one platform may give completely different results on another.</p>\n<p>You have avoided a common trap of using signed 1-bit fields (which can hold values <code>0<...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-18T22:29:48.320", "Id": "259707", "Score": "0", "Tags": [ "c", "bitset" ], "Title": "Individual bit access in C" }
259707
<p>Main function will ask what the user wants to do. LoginSystem class will handle the sign up and login process as well with the checking if password is right. passwordHashing will use bcrpyt to salt and hash the password.</p> <pre><code>import bcrypt from loginDbMySQL import insert, logging_in def main(): ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T01:44:56.483", "Id": "512303", "Score": "1", "body": "I'm stuck on my phone so I can't write a new answer, but your mechanisms of using strings as queries for this is not injection-safe. You should create programmable functions in ...
[ { "body": "<p>Let's start with the SQL and your <code>loginDbMySQL</code> stuff first.</p>\n<h3>You should probably reconsider the naming of your SQL table columns.</h3>\n<p>Bare minimum reproducible example with a table that has automatic incrementation, a UID as the primary key, and the username field 'userna...
{ "AcceptedAnswerId": "259776", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-18T23:41:00.363", "Id": "259710", "Score": "3", "Tags": [ "python", "mysql", "hash" ], "Title": "Login system using bcrypt and MySQL, to be used for any future projects" }
259710
<p>I'm new to C#, and want to conform as much as possible to good design patterns. This code is the beginning of a Microservice, running as Asp.Net. It is based on a Microsoft tutorial doing similar work.</p> <p>It has three functional components currently:</p> <ol> <li>Converts a CSV file to JSON, for return via REST<...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T12:13:19.080", "Id": "512322", "Score": "0", "body": "Welcome to CodeReview! From what aspect(s) are you looking for a review?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T12:20:41.900", "Id": ...
[ { "body": "<p>In this post let me focus on the project structure.</p>\n<h3>Project vs Projects</h3>\n<p>Most of the time when we implement a n-tier application we separate each tier into its own project. We also separate implementation and abstraction. Some like this:</p>\n<ul>\n<li><code>{Project}.Presentation...
{ "AcceptedAnswerId": "259751", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T08:55:25.890", "Id": "259715", "Score": "2", "Tags": [ "c#", "design-patterns", "asp.net", "dependency-injection" ], "Title": "Asp.Net overall design pattern integrating R...
259715
<p>I recently needed to create a function to approximate a complex trigonometric function on an embedded system without a floating point unit and without a fast trigonometric library. So I pulled out my ancient copy of &quot;Numerical Recipes in C, Second Edition&quot; by Press, Teukolsky, Vetterling and Flannery, and...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T15:14:12.090", "Id": "512336", "Score": "0", "body": "What were the memory restrictions like?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T15:24:06.657", "Id": "512337", "Score": "5", "...
[ { "body": "<h1>Naming things</h1>\n<p>You have a bounds checking evaluation function, <code>operator()</code>, and one that doesn't do bounds checking named <code>chebeval()</code>. If the idea is to have this mimic an STL containers <code>operator[]</code> vs. <code>at()</code>, then perhaps make it more like ...
{ "AcceptedAnswerId": "259735", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T14:33:36.613", "Id": "259725", "Score": "14", "Tags": [ "c++", "mathematics", "numerical-methods", "c++20" ], "Title": "C++ class to create and evaluate Chebyshev approxim...
259725
<p>I have a simple web api where each request &quot;item&quot; is stored in a list and thus a list is built without creating a new list per request. I have achieved this via dependency injection , but I want to know if there is a better way to do it?</p> <pre><code>[ApiController] [Route(&quot;[controller]&quot;)] publ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T09:23:03.517", "Id": "512427", "Score": "0", "body": "What is the expected lifetime of your data?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T14:09:48.230", "Id": "512451", "Score": "0", ...
[ { "body": "<p>It really depends, how far you want to go with this.</p>\n<p>Maybe the most common suggestion that I can give is that what you are doing is called Memory Caching. It's good to call things with a name that is widely understood.</p>\n<p>Read this article about <a href=\"https://docs.microsoft.com/en...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T15:32:16.917", "Id": "259728", "Score": "-1", "Tags": [ "c#", ".net", "api", "dependency-injection" ], "Title": "Better way to keep a list of items from a Http Request?" }
259728
<p>I made a snake game in c, it runs pretty well, everything is working, I think, I'm just wondering if there are any bugs I'm not aware of or if there is anything I can do better.</p> <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;conio.h&gt; #include &lt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T20:46:52.977", "Id": "512376", "Score": "1", "body": "dareesome, what is the reason for the `fruitX == x||fruitY == y` test?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T20:55:57.923", "Id": "5...
[ { "body": "<p>You should keep your game loop as simple as possible with only an <code>update</code> and <code>draw</code> method and specifically in that order.</p>\n<hr />\n<p>To ensure your game loop is iterating at the same speed everytime, you should calculate the duration of your <code>update</code> and <c...
{ "AcceptedAnswerId": null, "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T16:05:00.473", "Id": "259730", "Score": "20", "Tags": [ "c", "snake-game" ], "Title": "A Snake Game in C" }
259730
<p>I am trying to create a doc file which contains the list of folders in a given folder path. The <code>Main</code> function is the entry point.</p> <pre><code>// This function performs the operation of creating the file of the list of folders in the specific folder. // Usage: Set the ListDocName, the ListDocFullPath,...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T16:10:00.053", "Id": "259731", "Score": "0", "Tags": [ "javascript", "file-system", "web-services", "google-apps-script", "google-drive" ], "Title": "List sub-folders and ...
259731
<p>PHP 7 is the next version of <a href="/questions/tagged/php" class="post-tag" title="show questions tagged &#39;php&#39;" rel="tag">php</a>. It succeeds PHP-5.6, which is the last release of the PHP 5.X version. PHP 7.0.0 was <a href="https://php.net/archive/2015.php#id2015-12-03-1" rel="nofollow noreferrer">release...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T16:39:48.180", "Id": "259732", "Score": "0", "Tags": null, "Title": null }
259732
PHP 7 is the successor to PHP 5.6, it was released on December 3, 2015. Use this tag for issues relating to development using PHP 7
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T16:39:48.180", "Id": "259733", "Score": "0", "Tags": null, "Title": null }
259733
<p>I’m learning a lot of from Combine thanks to an amazing book in raywenderlich. Currently i’m writing an app and following the clean MVVM architecture.</p> <p>Then I have the following layers:</p> <ul> <li>Domain(UseCases and RepositoryProtocols)</li> <li>Data(RepositoryImplementations)</li> <li>Presentation(ViewCont...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T19:15:04.313", "Id": "259736", "Score": "0", "Tags": [ "swift", "ios", "mvvm" ], "Title": "iOS: Combine and Clean Architecture" }
259736
<p>I'm making a terrain-deformation system in Unity that utilizes the common marching-cubes algorithm. So far I've gotten the system working, employed Unity's job system and burst compiler, and managed to cut down frame calculation time from ~100ms per job to ~25ms. That's great, and I'm getting around 20 FPS during th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T03:48:07.367", "Id": "512391", "Score": "0", "body": "Welcome to the Code Review Community. The question would be better if the title just stated what the code does, and you addressed your concerns about the code within the body of ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T22:47:29.540", "Id": "259740", "Score": "3", "Tags": [ "c#", "performance", "game", "multithreading", "unity3d" ], "Title": "C# Procedural Mesh Generation Optimization" }
259740
<p>I've been playing around with <a href="https://dotty.epfl.ch/docs/reference/contextual/derivation.html#how-to-write-a-type-class-derived-method-using-low-level-mechanisms" rel="nofollow noreferrer">this example</a> from the Scala 3 documentation, and I noticed that certain things duplicate functionality already pres...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T14:53:09.700", "Id": "512862", "Score": "0", "body": "I think `p.asInstanceOf[Product]` is safe, since there wouldn't be a given `Mirror.ProductOf[T]` otherwise. Also, it looks like casting is unavoidable for `eqSum`, although you m...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-19T23:26:05.597", "Id": "259742", "Score": "2", "Tags": [ "scala" ], "Title": "Scala 3 Typeclass derivation using low-level mechanisms: The `Eq`-example" }
259742
<h3>Exercise 1</h3> <p>Please implement code and data structures that read the files:</p> <ul> <li><code>src/test/java/resources/people.csv</code></li> <li><code>src/test/java/resources/relationships.csv</code></li> </ul> <p>and use them to build an in-memory data structure that represents the people in the file and th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T08:01:20.880", "Id": "512413", "Score": "1", "body": "Welcome to Code Review, please divide the code in separated classes to improve readibility of your question. You used `kotlin` and `gradle` tags, are these tags really necessary?...
[ { "body": "<p>Nice implementation, find below my suggestions.</p>\n<hr />\n<blockquote>\n<p>Exercise 1 Please implement code and data structures that read the\nfiles</p>\n</blockquote>\n<p>The data structure (that represents the graph) in your implementation is <code>List&lt;People&gt;</code>, which is a bit co...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T04:06:38.427", "Id": "259746", "Score": "1", "Tags": [ "java" ], "Title": "Building a graph of people, and their relationships with each other" }
259746
<p>In a few hours I threw together this little text-based java game. Pretty much you're managing a forest and have to try and keep it together while keeping enough of a profit to move forward.</p> <pre class="lang-java prettyprint-override"><code>package com.company; import java.util.Arrays; import java.util.Scanner; ...
[]
[ { "body": "<ul>\n<li>naming should be consistent, choose either snake case or camel case, but not both.</li>\n<li>variables/fields should be declared one per line.</li>\n<li>all the fields should be <code>private</code></li>\n<li>name methods in a more meaningful way and do not shorten their names (for example,...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T04:27:58.770", "Id": "259747", "Score": "4", "Tags": [ "java", "game" ], "Title": "Basic java text-based management game" }
259747
<p>I am writing an API function using Django Rest Framework where it accesses many resources like AWS, Database, External APIs etc., I want the API execution to stop if it fails in any of the steps and return an appropriate response.</p> <p>I initially used ValueError to raise exceptions manually when something failed,...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T07:11:10.903", "Id": "259749", "Score": "0", "Tags": [ "python", "python-3.x", "error-handling", "django" ], "Title": "Stop Django Rest Framework API execution and return appr...
259749
<p>I'm working on a simple method that would censor emails (GPDR stuff) so they won't show the full name of a user, with 1st character, optional dot, 1st character after the dot and whatever is left after the @ to be left uncensored. So, the intent is like this:</p> <p>Email to be censored: <code>name.lastname@email.co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T13:06:02.383", "Id": "512447", "Score": "1", "body": "Please take into account that here on Code Review answers won't come as quick as on [SO], hence you should really wait at least a day before you accept an answer althought it is ...
[ { "body": "<p>Just a few remarks....</p>\n<ul>\n<li>if <code>username</code> doesn't contain a <code>@</code> the code should return early which saves one level of indentation.</li>\n<li>The condition <code>if (chars[i] == '.')</code> should better be <code>if (isCurrentCharacterADot)</code> but you could omit ...
{ "AcceptedAnswerId": "259757", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T11:43:13.610", "Id": "259756", "Score": "4", "Tags": [ "java", "strings" ], "Title": "Censoring emails in Java" }
259756
<p>I want to write the test case for Service class.</p> <p>My Service Class dynamic-form.service.ts</p> <pre><code>import { HttpClient, HttpBackend } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; @Injectable({ providedIn: 'root' }) export class Dyn...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T15:29:11.820", "Id": "512455", "Score": "0", "body": "Welcome to the Code Review Community. What we do here is review working code from one of your projects and make suggestions about how to improve the code. `I want to know it is g...
[ { "body": "<p>Personally i would create an interface for the expected data from the backend. <code>any</code> is something i try to avoid, because then my IDE can´t help me finding my stupid mistakes.</p>\n<p>For example</p>\n<pre><code>interface DynamicFormData {\n aValue: string,\n anotherValue: number,\n...
{ "AcceptedAnswerId": "259899", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T12:46:31.993", "Id": "259760", "Score": "0", "Tags": [ "unit-testing", "typescript", "angular-2+" ], "Title": "Unit Test case for services method in angular" }
259760
<p>I often come around a requirement where we have to perform a repetitive task on the user's screen (for eg, updating a counter like flash sale/ live class timer, autoscrolling the banner, etc) . I have written this small file which performs a basic task of pressing a button every 2 seconds for a total of 4 times as a...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T15:40:42.710", "Id": "259763", "Score": "1", "Tags": [ "multithreading", "android" ], "Title": "running a task on UI every x seconds" }
259763
<p>My code is working fine...</p> <p>but I want to remove <strong>below those(1)</strong> lines of code from my <strong>example code(2)</strong> (JS Code). If I remove those code then a tag is not working. (a tag do not open link or href is not working).</p> <p><strong>Is it a good approach to done it by writing those ...
[]
[ { "body": "<pre><code>e.preventDefault();\ne.stopPropagation();\n\nif (e.target.nextElementSibling == null) {\n\n if (e.target.getAttribute('target') != null) {\n window.open(e.target.getAttribute('href'), e.target.getAttribute('target'));\n } else {\n window.location.href = e.target.getAttr...
{ "AcceptedAnswerId": "260098", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T16:35:00.417", "Id": "259764", "Score": "1", "Tags": [ "javascript", "event-handling" ], "Title": "dispatch event listener problem after click" }
259764
<p>I have a text adventure game and I need to use OOP so I've chosen to use it when getting the player's name and age. I need to keep the OOP; but was wondering if there are any ways to clean up the code or simplify it while still getting the overall output.</p> <pre><code> class Player: def __init__(self): ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T16:57:26.253", "Id": "512461", "Score": "2", "body": "This is just the class. How will you be actually using this in your game?" } ]
[ { "body": "<p>The methods in this class are not really Player methods. They are a combination of game flow, user input and value verification methods. I'd organize it more like this.</p>\n<pre><code>class Game:\n def __init__(self):\n io.show(&quot;If ready, let's begin&quot;)\n name = self.get_valid_n...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T16:37:56.453", "Id": "259765", "Score": "1", "Tags": [ "object-oriented", "pygame" ], "Title": "Asking for player name and age using OOP" }
259765
<p>For example, given <code>[10, 15, 3, 7]</code> and a number <code>k</code> of <code>17</code>, return <code>True</code> since <code>10 + 7</code> is <code>17</code>.</p> <p>How can I improve the below solution?</p> <pre><code>from itertools import combinations def add_up_to(numbers, k): c_k_2 = list(combinations(...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T19:03:47.947", "Id": "512470", "Score": "0", "body": "consider sorting and using two pointers for quick performance" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T19:17:16.707", "Id": "512478", ...
[ { "body": "<hr />\n<p><strong>Indents</strong></p>\n<p><a href=\"https://www.python.org/dev/peps/pep-0008/#indentation\" rel=\"nofollow noreferrer\">PEP 8: <em>Use 4 spaces per indentation level.</em></a></p>\n<hr />\n<p><strong><code>True if condition else False</code></strong></p>\n<p>The pattern <code>True i...
{ "AcceptedAnswerId": "259790", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T16:38:58.630", "Id": "259766", "Score": "7", "Tags": [ "python" ], "Title": "Given a list of numbers and a number, return whether any two numbers from the list add up to" }
259766
<p>This is a follow up to <a href="https://codereview.stackexchange.com/questions/259438/a-simple-encryption-scheme-similar-to-otp">my previous post</a>.</p> <p>I've used a BCrypt library to create a key from the passed in password. I then separated out the salt from the hash. The encryption is done using the salt co...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T14:05:22.010", "Id": "512553", "Score": "0", "body": "Could you provide the link to NuGet package you're using to run this code? I can't find the package containing `Sha3` class. You well described how it works but it doesn't clear ...
[ { "body": "<p>Too fancy, too hard to read. The whole code can be compressed into something like\n<code> BCrypt.Net.BCrypt.HashPassword(salt+password).ToArray()</code></p>\n<p>Take a look at how to use this function here: <a href=\"https://jasonwatmore.com/post/2020/07/16/aspnet-core-3-hash-and-verify-passwords-...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T17:41:28.067", "Id": "259768", "Score": "1", "Tags": [ "c#", "encryption" ], "Title": "A simple encryption scheme 2.0" }
259768
<p>I was seeing alot of machine learning applications calculate fitness via <code>1.0 / x</code>. Division in computers is slow so I came up with a version that is about ~36% fast on my architecture (<code>-march=x86-64</code>).</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;cmath&gt; //std::exp2,...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T19:07:13.323", "Id": "512471", "Score": "3", "body": "It is very unlikely that applying two transcedental functions is faster than a single division. The runtime is dominated by the output to `std::cout`. Also, why use `std::exp2(st...
[ { "body": "<p>Including IO in a benchmark is no good. I tried some <a href=\"https://quick-bench.com/q/onmsxwkyLVdK7PUs3v4rrk5xqtc\" rel=\"nofollow noreferrer\">different benchmarks on quick-bench</a> and the results were different: the versions with Expensive Functions (<code>log</code>, <code>exp</code>, etc)...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T18:50:01.023", "Id": "259771", "Score": "0", "Tags": [ "c++" ], "Title": "fast reciprocal (1/x)" }
259771
<p>Edit:</p> <p>By adding the restrict keyword I was able to get my memcpy up to speed with the library implementation (and in this particular test, exceeding the library implementations speed). New results:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Test case</th> <th><code>mem_cpy</c...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T20:53:16.317", "Id": "512495", "Score": "3", "body": "One obvious optimization is you didn't declare the parameters `dest` and `src` with the qualifier `restrict` ( https://en.cppreference.com/w/c/language/restrict ), as in libc. Li...
[ { "body": "<blockquote>\n<pre><code>const uint64_t *restrict src64;\n</code></pre>\n</blockquote>\n<p>Portability problem - <code>uint64_t</code> is only defined if the platform has a type of exactly 64 bits. Consider using <code>uint_fast64_t</code> (or perhaps <code>uintmax_t</code>) instead.</p>\n<blockquo...
{ "AcceptedAnswerId": null, "CommentCount": "13", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T20:45:29.667", "Id": "259775", "Score": "4", "Tags": [ "performance", "c", "reinventing-the-wheel" ], "Title": "User implementation of memcpy, where to optimize further?" }
259775
<p>I am attempting to implement a <code>GetNeighborhood</code> function in order to get a specific region from <code>inputCells</code> by <code>sizeInput</code> and <code>centralLocation</code> parameters in 3D cells structure.</p> <p><strong>The experimental implementation</strong></p> <p>The experimental implementati...
[]
[ { "body": "<p>I think the biggest gain in efficiency you can get is to not use a cell array. Each element of a cell array is an array. Each array has a header data structure that takes up 104 bytes (if I remember that number correctly). Storing only one number in an array means that there is a memory overhead ...
{ "AcceptedAnswerId": "259884", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-20T23:58:43.867", "Id": "259780", "Score": "1", "Tags": [ "beginner", "matrix", "matlab" ], "Title": "GetNeighborhood function for 3D cells structure in MATLAB" }
259780
<p>I usually like to use <code>entr</code> when developing on my own hardware to run commands when a directory changes.</p> <p>However, sometimes I'm working in an environment where I don't have much control over the availability of helpful programs so many of us take for granted.</p> <p>I've been using Git Bash on Win...
[]
[ { "body": "<p>You're going to get false positives by comparing the output of <code>ls -l</code>. In many locales, this command gives date stamps in different formats for newer files (day+time) and older files (year+day). When any file transitions from &quot;new&quot; to &quot;old&quot; in this scheme, you'll ...
{ "AcceptedAnswerId": "259794", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T04:08:39.023", "Id": "259781", "Score": "2", "Tags": [ "bash" ], "Title": "Bash: call make when directory changes" }
259781
<p>So I got this short awk invocation wrapped in a bash script. unfortunately the bash script is kinda unreadable. Do you have any pointers?</p> <pre><code>#!/bin/bash action=&quot;printf \&quot;$1 \&quot; \$1 \&quot; \&quot;&quot; awk {&quot;$action&quot;} $2 </code></pre> <p>Invoking it like this <code>joinargs -s tm...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T10:51:16.633", "Id": "512532", "Score": "0", "body": "Can't you use just `echo` for printing to stdout?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T15:07:59.230", "Id": "512573", "Score": ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T08:36:27.710", "Id": "259787", "Score": "0", "Tags": [ "bash" ], "Title": "Short bash script to join arguments with dashoption, escaping quotes and $ dollar sign" }
259787
<p>Here is a code for BST that I have written , that does not use pass by reference. Help me to find flaws in its design. Also I do not like the function <code>getReqNodes</code>, can it be made more elegant.</p> <pre><code>#include &lt;iostream&gt; using namespace std; struct node { int data; node* left = nul...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T23:04:58.657", "Id": "512621", "Score": "0", "body": "This is C code. The only C++ thing is your usage of `std::cout`. You need to work on encapsulation and how classes work." } ]
[ { "body": "<h1>General Observations</h1>\n<p>The code compiles and runs in Visual Studio 2019 on Windows 10.</p>\n<p>The vertical spacing is inconsistent and could be improved.</p>\n<p>The code could be reusable if the Binary Search Tree was made into a class.</p>\n<p>The unit testing in main could be more effe...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T09:27:40.970", "Id": "259788", "Score": "1", "Tags": [ "c++", "binary-search-tree" ], "Title": "Binary Search Tree without pass by reference" }
259788
<p>I have written a simple program to represent the computer is doing an operation. It is suppose to show a rotating slash character to the user with every second passed however the program does not work as intended. It shows all the characters instead of cleaning the screen and show just the spinning slash character.<...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T19:03:06.897", "Id": "512595", "Score": "0", "body": "\"however the program does not work as intended\" That's a problem. Please take a look at the [help/on-topic]." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate":...
[ { "body": "<p>If you're running windows the command is &quot;CLS&quot; not &quot;clear&quot;.\nLearning modulo will help you a lot in programming - here you could use <code>wheel[j%3]</code> and skip the variable <code>i</code>.\nAlso try to find a way to move the cursor instead of clearing the entire screen.</...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T11:37:02.120", "Id": "259791", "Score": "-1", "Tags": [ "c" ], "Title": "Spinning slash wheel to represent an Ongoing operation" }
259791
<p>I am creating a metaclass which ensures that instances of an actual class <code>A</code> are kind of singletons. But rather than having only single instance of <code>A</code>, I would like to have one instance per argument set given to <code>A</code>.</p> <p>That is</p> <pre><code>class A(metaclass=ArgumentSingleton...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T12:19:17.240", "Id": "512542", "Score": "1", "body": "Hey, welcome to the community! The 2nd code snippet, where you show the pickling and unpickling, makes use of a variable `b` that is not defined! For the sake of clarity and corr...
[ { "body": "<p>The point of having to define either neither or both of <code>__init__</code> and <code>__reduce_ex__</code> is to set <code>_args</code>.\nHowever you can just set <code>_args</code> in <code>__call__</code> and then use the one you've set in your <code>__reduce_ex__</code>.<br />\n<sub><strong>N...
{ "AcceptedAnswerId": "259797", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T12:10:39.877", "Id": "259793", "Score": "6", "Tags": [ "python", "singleton" ], "Title": "Singleton metaclass for each argument set compatible with Pickle" }
259793
<p>I'm trying to develop a text-based game. Here is the concept-demo version.</p> <pre><code>class Arena { public static void battle(Hero h1, Hero h2){ h1.setHp(h1.getHp()-h2.getPhysical_attack()); h1.info(); } public static void main(String[] args) { System.out.println(&quot;Enteri...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T15:39:56.637", "Id": "512578", "Score": "4", "body": "This feels like it might be a bit early for a review. `static` can be ok, however there's questions I'd consider... are you going to support multiple Arena, with different Hero'...
[ { "body": "<h3>Few suggestions</h3>\n<ol>\n<li><code>Arena.battle</code> can be changed to instance method rather than a static method. This will help in conducting matches in different arenas.</li>\n<li>Use constructor to set the uname, initial hp and initial physical_attack</li>\n<li>Its better to use camel c...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T13:49:53.740", "Id": "259800", "Score": "-2", "Tags": [ "java" ], "Title": "Is it common to use static void method to handle objects, e.g. set some properties?" }
259800
<p>A couple of weeks ago I had to do a coding challenge for a job interview. I did the challenge using Python, the code was working and I got the job. But I would like to know how (if possible) I can improve/refactor the code I've written. The reviewer told my future employer there were too many if statements and that ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T07:59:57.137", "Id": "512657", "Score": "2", "body": "The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to **simply sta...
[ { "body": "<p>The reviewer was probably thinking that you can get the same result by adding together two independently-calculated surcharges:</p>\n<pre><code>def get_row_tax_percentage(product_name: str) -&gt; Decimal:\n nonexempt = Decimal(&quot;0&quot;) if is_exempt(product_name) else Decimal(&quot;.05&quo...
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T13:58:40.217", "Id": "259801", "Score": "15", "Tags": [ "python", "python-3.x" ], "Title": "Having a string representing items in a cart, elaborate taxes and totals. Interview task in...
259801
<p>I wrote the following Chess logic in Kotlin and am looking for feedback to make the code cleaner and follow good software design principles. I tried to adhere to <strong>object-oriented design</strong>.</p> <p>Some notes:</p> <p>• I ignored special moves like &quot;Castling&quot; and &quot;en pessant&quot; for simpl...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T10:35:31.030", "Id": "512671", "Score": "3", "body": "I have rolled back your latest edits. Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question + Answer style of Co...
[ { "body": "<p>There's several parts of your design that can be improved.</p>\n<p>There is currently lots of duplicate code regarding color, allowed moves, and Pawn1, Pawn2, Pawn3 etc.</p>\n<p>Is there really any difference between Pawn1, Pawn2, Pawn3, etc? I don't think so. A <code>Piece</code> could be a compo...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T15:18:25.107", "Id": "259807", "Score": "1", "Tags": [ "object-oriented", "game", "kotlin", "chess" ], "Title": "Chess game in Kotlin" }
259807
<p>I'm a beginner to intermediate in programming, and created a Tic-tac-toe game in python. I plan to add an AI player and a GUI using pygame.</p> <p>Any improvements I could make to the code, especially with the logic, or just formatting in general?</p> <pre><code>my_board = [ [&quot;1&quot;, &quot;2&quot;, &quot;...
[]
[ { "body": "<hr />\n<p><strong>Indents</strong></p>\n<p><a href=\"https://www.python.org/dev/peps/pep-0008/#indentation\" rel=\"nofollow noreferrer\">PEP 8: <em>Use 4 spaces per indentation level.</em></a></p>\n<hr />\n<p><strong>Main game loop</strong></p>\n<p>The way your game loop is set up now is a bit unele...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T15:40:24.627", "Id": "259809", "Score": "3", "Tags": [ "python", "object-oriented", "tic-tac-toe", "formatting" ], "Title": "Tic-tac-toe in python with OOP" }
259809
<p>I've been working on this for a while, and now that I've got a working program I thought I'd see what other people think about it.</p> <p>Basically if there is anything you think would make it faster or make it simpler, or make it better in general, please share your thoughts. As for actual strength, I have no idea ...
[]
[ { "body": "<p>Needs docstrings and better parameter names.</p>\n", "comments": [ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T21:07:31.607", "Id": "512612", "Score": "0", "body": "\"not useful\"-voter please explain how it isn't. That code is ...
{ "AcceptedAnswerId": "259842", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T17:10:53.683", "Id": "259814", "Score": "6", "Tags": [ "python" ], "Title": "Encryption/Decryption algorithm" }
259814
<p>I am trying to write a python script that can search through Fortran code ignoring comments. I didn't find a simple way of doing this using grep. So I startwed writing my own.</p> <p>The rules for comments that I am following are:</p> <ol> <li>the first character is not a space or a number. It is usually a c, C but ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T18:19:30.680", "Id": "512590", "Score": "0", "body": "@Peilonrayz, probably resulting from copy-pasting from my editor. Can you try now?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T18:30:39.623", ...
[ { "body": "<h1>Shebang</h1>\n<p><code>#!/usr/bin/python</code> is not portable, <code>#!/usr/bin/env python</code> is preferred.</p>\n<h1>White Space</h1>\n<p>There should be a blank line between your imports and your function declarations.</p>\n<h1>Efficiency</h1>\n<p>You are constantly converting your <code>c...
{ "AcceptedAnswerId": "259822", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T17:55:22.080", "Id": "259815", "Score": "1", "Tags": [ "python", "fortran" ], "Title": "Search through fortran source for a string ignoring comments" }
259815
<p>I wrote this code that's supposed to implement a 1-dimensional (!) <a href="https://en.wikipedia.org/wiki/Expectation%E2%80%93maximization_algorithm" rel="nofollow noreferrer">EM algorithm</a> with k-means initialization:</p> <pre><code>begin import Pkg Pkg.activate(temp=true) Pkg.add([&quot;StaticArrays...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T12:13:15.513", "Id": "513131", "Score": "0", "body": "I've tried some refactoring for fun: https://gist.github.com/phipsgabler/4d91bcee6d3d56021ee485b8dd00a5fc. But I can't really comment on whether this is working or an improvement...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T19:57:19.097", "Id": "259818", "Score": "1", "Tags": [ "performance", "julia" ], "Title": "How to make my 1D EM algorithm written in Julia faster?" }
259818
<p><code>Background</code>: I had created a macro few years ago and when I was reviewing this now, it was hard to understand. I recently went through all the articles from RubberduckVBA and started learning that VBA can also be Object Oriented language and, I tried implementing this concept in my macro.</p> <p><strong>...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T20:44:50.057", "Id": "512609", "Score": "3", "body": "Good stuff! Thanks for reading all my ramblings!" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T20:52:52.613", "Id": "512610", "Score": "...
[ { "body": "<p>The OOP version of the code generated some thoughts around separation of concerns: user interactions and data processing.</p>\n<p>Single Responsibility Principle(<a href=\"https://en.wikipedia.org/wiki/Single-responsibility_principle\" rel=\"nofollow noreferrer\">SRP</a>):</p>\n<blockquote>\n<p>E...
{ "AcceptedAnswerId": "259889", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T20:01:35.100", "Id": "259819", "Score": "5", "Tags": [ "object-oriented", "vba", "excel", "comparative-review", "rubberduck" ], "Title": "Copy Columns Forward Macro: F...
259819
<p>I made this super basic autoclicker using Python (v3.7) and the pynput (v1.7.3) library.</p> <p>Are there any changes that you could recommend to make the code more efficient, faster, and overall better?</p> <p>Here's the code:</p> <pre><code>from pynput.keyboard import Controller import time # Autoclicker Functio...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T22:57:57.763", "Id": "512620", "Score": "3", "body": "\"Are there any changes that you could recommend to make the code more efficient, faster\" conflicts with `time.sleep`." } ]
[ { "body": "<p>Your code is fairly simple (which is good) and there isn't much to make it &quot;more efficient&quot; or &quot;faster&quot;. There's only a couple of suggestions I have to clean it up and you'll end up with a textbook example of a nice and short Python script that does something useful :)</p>\n<h1...
{ "AcceptedAnswerId": "259858", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-21T22:29:13.400", "Id": "259824", "Score": "1", "Tags": [ "python", "python-3.x", "automation" ], "Title": "Python Autoclicker" }
259824
<p>I often see nested loops as a solution to the bubble sort, but my solution involves a recursive function. Is the following solution less efficient than the traditional method?</p> <pre><code>public static int[] BubbleSort(int[] arrayOfValues) { var swapOccurred = false; for (var i = 0; i &lt; arrayOfVal...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T03:34:33.190", "Id": "512636", "Score": "3", "body": "If it's recursive anything you can almost bet that it's less efficient the the iterative version of anything. It's much more interesting to find out why some particular recursive...
[ { "body": "<p>Less efficient? It consumes more stack space, which shouldn’t be a problem for any dataset where a bubble sort would be appropriate.</p>\n<p>With the latest version of the c# compiler, tuple deconstruction will allow you to swap the values with a single line of code (although it will probably be s...
{ "AcceptedAnswerId": "259836", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T01:36:51.273", "Id": "259832", "Score": "2", "Tags": [ "c#", "sorting" ], "Title": "Recursive function for bubble sort" }
259832
<p>I have been trying to learn c++ for the sake of being comfortable with a second language. I found a project that seemed relatively easy, although it may not be implemented perfectly, it was a simple project.</p> <p>I create a <code>std::map&lt;double, std::string&gt;</code>, which will represent the tax rate as a do...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T06:08:58.563", "Id": "512646", "Score": "1", "body": "You say that C++ is your second language - it's probably useful to say what your main programming language is, because a lot of the pitfalls you encounter will depend on your exi...
[ { "body": "<p>In <a href=\"https://en.cppreference.com/w/cpp/container\" rel=\"noreferrer\">C++ STL</a>, the <code>set</code> and closely related <code>map</code> containers are <em>sorted</em> and provide an efficient way to look up the set element (or map key) which is not less than a given value. This is acc...
{ "AcceptedAnswerId": "259840", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T02:24:23.013", "Id": "259833", "Score": "6", "Tags": [ "c++", "object-oriented", "hash-map" ], "Title": "Income tax rate calculator in c++" }
259833
<p>I've started to get far more familiar with C (and coding in general) and the way to use function to my advantage to create more complex programs. As a way of doing something actually useful instead of my &quot;Starting Programming with C: For Dummies&quot; book I decided to make a simple program to help me cheat my ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T13:48:29.717", "Id": "512704", "Score": "1", "body": "@IñakiUlibarri Please [edit] your question to include only your code file's *content*, not the visuals of your editor. In case you have only `nano` at hand, use `M-#` to disable ...
[ { "body": "<p>I would find it easier to understand if the comments were in English, but I'm not the one who will be making changes later, so write your comments for that person (whatever is most useful to future-you).</p>\n<p>What I find actively harmful is the very long lines such as</p>\n<blockquote>\n<pre><c...
{ "AcceptedAnswerId": "259868", "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T02:46:55.117", "Id": "259835", "Score": "1", "Tags": [ "beginner", "c" ], "Title": "Find solutions to a quadratic equation" }
259835
<p>How does the following look to list the directories on a posix system? This is actually the first piece of C code that I've written where I've actually been able to use for a real-world problem!</p> <pre><code>#define _GNU_SOURCE #include &lt;dirent.h&gt; #include &lt;string.h&gt; #include &lt;fcntl.h&gt; #include &...
[]
[ { "body": "<blockquote>\n<pre><code>#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)\n</code></pre>\n</blockquote>\n<p>There's a long-standing convention to use <code>UPPER_CASE</code> for preprocessor macros. This helps draw attention to them as <em>text replacements</em>, which don...
{ "AcceptedAnswerId": "259843", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T03:30:51.273", "Id": "259838", "Score": "4", "Tags": [ "beginner", "c", "posix" ], "Title": "Recursively list directories" }
259838
<p>I am a total beginner in Python and I am trying with the modules Turtle. I am currently trying to code for 3 sliders (R, G, B) for adjusting the colors of the turtle screen. However, I found parts of my codes filled with redundancies, could anyone please tell me how to trim the code to make it more compact and clear...
[]
[ { "body": "<h1>Review</h1>\n<p>I wasn't able to figure out a way to make the code more compact and in my opinion the code is pretty clear. However I do have some other feedback.</p>\n<h2>Use a proper main</h2>\n<p>Instead of:</p>\n<pre class=\"lang-py prettyprint-override\"><code>turtle.setworldcoordinates(0, 0...
{ "AcceptedAnswerId": "259853", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T07:31:34.343", "Id": "259844", "Score": "4", "Tags": [ "python", "turtle-graphics" ], "Title": "Python: screen colors adjuster using Turtles" }
259844
<p>I am writing a benchmarking tool from scratch in Python. However I can't get the performance of other benchmarking tools like <code>wrk</code> or <code>wrk2</code>. Using wr2 I can make 42k requests/s while my code can only create up to 2200 reqs/s. I have tried multiple ways to parallelize the code execution. I hav...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T11:44:37.930", "Id": "512680", "Score": "0", "body": "Bit hard to compare two ways if we see only one of them." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T11:52:57.913", "Id": "512682", "S...
[ { "body": "<p>Performance notwithstanding, there's some other cleanup that's worth doing:</p>\n<ul>\n<li>Capitalize <code>NUM_WORKERS</code> since it's a global constant</li>\n<li>Do not shadow your global <code>output</code> with a local variable of the same name; and ideally don't have a global <code>output</...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T07:42:37.180", "Id": "259847", "Score": "2", "Tags": [ "python", "performance", "benchmarking", "multiprocessing" ], "Title": "benchmarking requests to localhost" }
259847
<p>I am trying to find a N number of leading zeros from the output of the sha1 hash function. I would like N to go up to 10 or 9. Currently I can get to 7 in about 7 minutes (even though is not always that fast), but already 8 takes forever. The input to the sha1 must be a combination between an input_str and a random ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T09:44:01.087", "Id": "512664", "Score": "0", "body": "@Manuel see the EDIT, try to change the value in `get_time` function up to 10. How long does it take?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04...
[ { "body": "<ul>\n<li><code>zeros</code> or <code>zeroes</code>? Better make up your mind and stick with one.</li>\n<li><code>str.join</code> is good when you want to join an iterable. For two strings, just use <code>+</code>.</li>\n<li>Instead of always reencoding and rehashing the input string, you can do it <...
{ "AcceptedAnswerId": "259857", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T08:53:40.383", "Id": "259848", "Score": "1", "Tags": [ "python-3.x", "random" ], "Title": "find leading zeros: performance" }
259848
<p>This is an updated version of my first question: <a href="https://codereview.stackexchange.com/questions/259807/chess-game-in-kotlin?noredirect=1#comment512671_259807">Chess game in Kotlin</a></p> <p>I wrote the following Chess logic in Kotlin and am looking for feedback to make the code cleaner and follow good soft...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T11:27:26.040", "Id": "512933", "Score": "0", "body": "Your implementation is very much procedural as can be seen in `getAvailableMoves`. Since you are interested in OOO, you may want to take a look at the \"Anemic domain model\" ant...
[ { "body": "<p>I'd start with defining simple, self-contained things, such as a very generic vector:</p>\n<pre class=\"lang-kotlin prettyprint-override\"><code>data class Vector(val x: Int, val y: Int) {\n companion object {\n val perpendicular = listOf(Vector(-1, 0), Vector(+1, 0), Vector(0, -1), Vect...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T10:41:07.077", "Id": "259851", "Score": "0", "Tags": [ "object-oriented", "kotlin", "chess" ], "Title": "Chess in Kotlin" }
259851
<p>I have the following bit of code in a service worker that checks to see it the url contains any of the values in an array and if so it breaks out of the function. As it is run for every asset on a webpage, it can be run a lot of times so I was wondering if it could be optimised in any way:</p> <p><div class="snippe...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T12:14:45.990", "Id": "512687", "Score": "0", "body": "Do you have access to the HTML at all? Because you add an attribute that would determine if you have to cache the data or not." }, { "ContentLicense": "CC BY-SA 4.0", ...
[ { "body": "<p>If you can use ES6 Features in your code, use a <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set\" rel=\"nofollow noreferrer\">Set</a> for constant lookup time:</p>\n<pre><code>const urlsToIgnore = new Set([\n 'boldchat.com',\n 'pinimg.com',\n 'resp...
{ "AcceptedAnswerId": null, "CommentCount": "9", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T11:43:53.337", "Id": "259854", "Score": "5", "Tags": [ "javascript", "performance" ], "Title": "Check if an array value exists as part of the url" }
259854
<p>To improve my Python knowledge I started a small coding project: A telegram chat/quiz bot that is based on official questions about basketball rules. The bot reads them from one or multiple <code>.csv</code> files.</p> <p>The bot has two modes:</p> <ul> <li>Exercise mode: Questions are asked until the user selects t...
[]
[ { "body": "<p><strong><code>__location__</code></strong></p>\n<p>Here's a recommendation I have also started implementing recently: Using a <code>definitions.py</code> (naming up to preference of course) file at project level that exports all the references to directories and files I might need. I feel it signi...
{ "AcceptedAnswerId": "259869", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T12:00:18.337", "Id": "259856", "Score": "7", "Tags": [ "python", "python-3.x", "telegram" ], "Title": "Python Telegram Quiz Bot" }
259856
<p>I am making a simple file explorer with tkinter Python.<br /> This is the <a href="https://github.com/Adityasingh76/Explorer" rel="nofollow noreferrer">file repository on github</a>.<br /> I know that this is pretty much long code and it took that much time to write but i have somehow added the comments.<br /> And I...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T15:06:07.420", "Id": "512711", "Score": "5", "body": "Welcome to Code Review. Unfortunately your question is off-topic as of now, as the code to be reviewed must be [present in the question.](//codereview.meta.stackexchange.com/q/13...
[ { "body": "<p><em>Note: I don't have experience with <code>tkinter</code>, so this will be a review for general code style. I welcome anyone who has experience with <code>tkinter</code> to add their review as well!</em></p>\n<hr>\n<h1>Class Naming</h1>\n<p>Class names should be in <code>PascalCase</code>, not <...
{ "AcceptedAnswerId": null, "CommentCount": "9", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T14:23:45.167", "Id": "259862", "Score": "0", "Tags": [ "python", "tkinter" ], "Title": "Making a File explorer with Python tkinter" }
259862
<p>I am developing a system for runtime macro executions in an automatic test environment. Macros are defined in an xml and are for configuring multiple devices/DUTs for a specific use case. The xml parsing of these macros is outside of the scope of this question.</p> <p>For building the macros in code I created the co...
[]
[ { "body": "<p>Passing the context that way is acceptable but the problem with the context that you have is that it can grow larger the more you add custom statements. This is an anti pattern, because it can be a GOD Object. And if you create new custom statements in the future you may need to touch the context ...
{ "AcceptedAnswerId": "259942", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T16:05:52.177", "Id": "259866", "Score": "2", "Tags": [ "c#", "xml", "macros" ], "Title": "Is this a good design for runtime Macro execution?" }
259866
<p>After I have been doing some improvements from my <a href="https://codereview.stackexchange.com/questions/259561/check-if-new-dict-values-has-been-added/259622">Previous code review</a>. I have taken the knowledge to upgrade and be a better coder but now im here again asking for Code review where I think it could be...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T17:19:29.453", "Id": "512754", "Score": "0", "body": "This code will not run. You have imbalanced parens." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T17:22:29.687", "Id": "512756", "Score"...
[ { "body": "<p>I believe you are still facing some issues with <code>Real Classes</code> comment from the previous post. Why do I say this? Your <code>Product</code> class is not even necessary. It has only functions that can be without a class.</p>\n<ol>\n<li><p>Using <a href=\"https://docs.python.org/3/library...
{ "AcceptedAnswerId": "260265", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T16:09:43.233", "Id": "259867", "Score": "2", "Tags": [ "python", "python-3.x", "web-scraping" ], "Title": "Take information from a webpage and compare to previous request" }
259867
<p>Currently working on a pre-solve collision library. My goal is to have it be potentially usable in potential video game projects of mine, so time constraint is small as this should be used in a game loop: this algorithm currently takes too long. I am aware of broadphasing, but I believe there is gains to be made he...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T19:38:23.350", "Id": "512774", "Score": "2", "body": "Welcome to Code Review. There's some content missing. You seem to be using a 2d library that contains `Vec2` and `Aabb`, neither are part of the Rust standard library. Also, `Pol...
[ { "body": "<p>I have found a significant optimisation, in taking out all of the extra code I had added to the basic concept of the algorithm.</p>\n<p>I'm not entirely satisfied with this gain, as it still takes ~80ns for the 6 side-4 side test described. I have also identified a bug in the original code and mod...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T19:15:54.810", "Id": "259873", "Score": "4", "Tags": [ "performance", "rust", "computational-geometry" ], "Title": "Convex polygon-polygon swept collision test" }
259873
<p>The purpose of this code is to use it to calculate some number theoretic function efficiently for the numbers from 1 to 1000000, but I am not sure if it will be really useful. The main purpose was to program a piece of C++ code because I have almost no experience in this language. So it would be nice if you could g...
[]
[ { "body": "<h1>Questions</h1>\n<p>You’ve asked for a review of the C++ specifically, not the algorithm, so that’s what I’ll do. But first, I’ll answer your questions.</p>\n<p><strong>Should the duplication of the block with the case statement be avoided?</strong></p>\n<p>Yes.</p>\n<p>Unless it’s <em>really</em>...
{ "AcceptedAnswerId": "259921", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T20:01:11.983", "Id": "259874", "Score": "2", "Tags": [ "c++", "beginner" ], "Title": "splitting numbers in three factors" }
259874
<p>I have this code:</p> <pre><code>Sorted=False while not Sorted: Sorted=True for x,y in enumerate(List[:-1]): if List[x]&gt;List[x+1]: List[x],List[x+1]=List[x+1],List[x] Sorted=False </code></pre> <p>However the use of</p> <pre><code>Sorted=True/False </code></pre> <p>being re...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T21:18:24.480", "Id": "512786", "Score": "3", "body": "Hi and welcome to CodeReview. Unfortunately, `List` is missing. While its name indicates that it's a usual Python list, several other collections in Python also provide an iterat...
[ { "body": "<p>One approach is to move most of the logic into a helper function that does the\nswapping and returns the N of swaps. The outer part of the algorithm then\nreduces to almost nothing.</p>\n<p>While you're at it: (1) use conventional names for Python variables (lowercase\nfor variables, capitalized f...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T20:48:19.787", "Id": "259877", "Score": "1", "Tags": [ "python", "python-3.x" ], "Title": "How would I make this bubble sort more pythonic?" }
259877
<p>Been looking into some simple algorithms, I came up with the following piece of code in C to implement the Euclidean algorithm iteratively (I like to be clear here, I don't want the recursive implementation for now).</p> <p>I've seen various other implementations and in fact most books prefer a different pseudo code...
[]
[ { "body": "<h3>Unnecessary function calls</h3>\n<p>My quick thought is that you are making an unnecessary function call.</p>\n<pre><code>unsigned temp;\nwhile ((temp = a % b)) {\n a = b;\n b = temp;\n}\n</code></pre>\n<p>The thing with the doubled parentheses is a hack to keep some compilers from warning ...
{ "AcceptedAnswerId": "259885", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T21:00:30.467", "Id": "259878", "Score": "6", "Tags": [ "algorithm", "c", "iteration" ], "Title": "Euclidean algorithm to determine GCD (greatest common divisor) in C -- altern...
259878
<p>I implemented a key:value format file parser in C, or something that comes close to it as there is no such thing as dynamically creating structs in C.</p> <p>Assumptions: we are creating a C program that needs some config options (e.g. the number <code>K</code> of threads in a concurrent server that handles requests...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T02:53:09.740", "Id": "512813", "Score": "2", "body": "`SYSCALL_OR_DIE` seems like a good bumper sticker" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T13:45:19.127", "Id": "512856", "Score": ...
[ { "body": "<h1>General Observations</h1>\n<p>It would be much easier to review this code if there was either a unit test or example code to see how this code should be used.</p>\n<p>It also isn't clear why the code deletes the <code>key value pair</code> within the function <code>getValueFor()</code>. The funct...
{ "AcceptedAnswerId": "259903", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-22T22:23:16.263", "Id": "259881", "Score": "5", "Tags": [ "c", "parsing", "file" ], "Title": "C key: value file parser" }
259881
<p>I am running a PowerShell script that shows disk usage for drives into HTML reports. While this works quite well it has a problem on some file servers with a massive amount of files. It can sometimes take up to 1 day in a worst case scenario which obviously isn't ideal. I'm wondering if there if there any way to opt...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T17:31:31.787", "Id": "512872", "Score": "0", "body": "**1.** [Avoid `Out-Null` cmdlet](https://powershell-guru.com/powershell-best-practice-12-avoid-out-null/); **2.** Why do you repeat expensive operations in `function bytesFormatt...
[ { "body": "<p>Your primary performance problem is due to this pattern:</p>\n<pre><code>$Set = 1..10000\n$Array = @()\nforeach ($i in $Set) { $Array += $i }\n</code></pre>\n<p>This is an awful pattern whether you're concatenating arrays or strings, because both of those are immutable in .Net. That means when you...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T02:12:36.633", "Id": "259887", "Score": "3", "Tags": [ "performance", "powershell" ], "Title": "Disk usage reporting script performing poorly with lots of files" }
259887
<p>I have a set of Italian words in a <code>txt</code> file hosted on GitHub. I use it as stopwords vocabulary for further NLP tasks.</p> <p>When I dump from GitHub it returns me, obviously, also <code>\n</code></p> <p>Better or more efficient way to replace the special character compared with my working code?</p> <pre...
[]
[ { "body": "<p>Code is very readable, and that's a good start.</p>\n<p><code>file_name</code> is in fact the file_content; <code>splitted</code> (split) should be just <code>stop_words</code>; <code>stopwords_list</code> is a constant, so by PEP 8, should be uppercase <code>STOPWORDS_LIST</code>.</p>\n<p>The pro...
{ "AcceptedAnswerId": "259896", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T09:04:30.750", "Id": "259895", "Score": "4", "Tags": [ "python", "performance" ], "Title": "Remove \\n newline from a list of string dumped from github used for a Italian stopword...
259895
<p>I'm making a top-down dungeon minigame where you are a knight and can attack zombies by swinging a sword. So far I haven't implemented collision, player <code>rect()</code>, enemy <code>rect()</code>, a game over screen, or the player sword animation, but all the code I have so far is working well, even though the m...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T14:37:45.540", "Id": "512860", "Score": "2", "body": "Welcome to Code Review. I have rolled back your last edit. Please do not update the code in your question to incorporate feedback from answers, doing so goes against the Question...
[ { "body": "<h1>Streamlining blitting of the player</h1>\n<p>You did a good job in realising you can streamline some of your code, because you have some patterns that are repeated over and over again. That is always a good indication that something shorter can be done.</p>\n<p>Taking a look at the series of <cod...
{ "AcceptedAnswerId": "259939", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T12:56:19.653", "Id": "259900", "Score": "8", "Tags": [ "python", "classes", "pygame" ], "Title": "Top-Down Dungeon RPG" }
259900
<p>I am teaching myself c++ by doing a series of exercises. I liked the idea of working out how hash tables could be done using just the language and no std calls. I discovered that you cant do &quot;class member function partial template specialisation&quot; and so worked on options for how this would be achieved. The...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T19:43:58.740", "Id": "512887", "Score": "2", "body": "Here, we review *complete, finished* code. We don't want to see a \"stripped down\" version (unlike [so], for example). You'll get better reviews if you show the full code in c...
[]
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T16:39:39.987", "Id": "259908", "Score": "0", "Tags": [ "c++", "hash-map", "template", "classes" ], "Title": "Is this a good way to construct the class for a C++ template parti...
259908
<p>I have an event handler function which every time is triggered should clear a <code>setTimeout()</code> and set a new timeout.</p> <p>Now the callback for the timeout has to take few arguments, for example the event object received by the handler.</p> <p>And that's it. I did it, but I believe that my solution is not...
[]
[ { "body": "<p>Since you mention <code>useReducer</code> React hook I will assume you are using a functional component and thus can use other React hooks.</p>\n<p>I suggest:</p>\n<ol>\n<li>Use a React ref to hold a reference to the timer (versus global variable).</li>\n<li>Use an <code>useEffect</code> hook to c...
{ "AcceptedAnswerId": "259926", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T17:39:08.217", "Id": "259910", "Score": "3", "Tags": [ "javascript", "react.js" ], "Title": "Setting and clearing setTimeout() inside of an event handler" }
259910
<p>My objective with this code was to create a class and call it from other .py files. The code itself is working, but I would like to know what could be improved or be better implemented.</p> <p>I wrote another program just to call this class and its methods and it worked. I'm using functions that will only work on Wi...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T23:35:00.657", "Id": "512904", "Score": "2", "body": "You mention calling it from other code, and it appears to be encryption, but could you briefly say what is a use case when one would call this code? What does it do?" }, { ...
[ { "body": "<p>First lets discuss the class and method naming:</p>\n<p><code>StudingClassFirstTime</code> First of all, the word <code>Studing</code> is not in my vocabulary. But please just name classes after what they are supposed to do, and don't include the word <code>class</code>; we know it is a class.</p>...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T21:15:02.587", "Id": "259915", "Score": "3", "Tags": [ "python", "beginner", "object-oriented", "cryptography", "classes" ], "Title": "Creating a class and calling it from...
259915
<p><strong><a href="https://leetcode.com/problems/3sum/" rel="nofollow noreferrer">Question</a>:</strong></p> <blockquote> <p>Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.</p> </blockquote> <p>Notice that the ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T23:28:46.750", "Id": "512900", "Score": "4", "body": "Providing the problem statement and/or sample in- and output will help contributors point you towards a better or more straightforward solution. As it is now, it's hard to unders...
[ { "body": "<p>You can just create every possible triplets with nested loops and keep a record of those that satisfy the requirements.</p>\n<p>I don't know Python, so I learned a bit of it to write this code, take it as an example and translate it to proper Python. I think that the main issue of the code is the ...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T22:09:48.497", "Id": "259916", "Score": "2", "Tags": [ "python", "algorithm", "python-3.x", "hash-map" ], "Title": "3Sum - leetcode" }
259916
<p>This is my current code to check list of urls for response code within same domain.</p> <p>I would like to know if there's a way where i can improve my code performance more better.</p> <pre class="lang-py prettyprint-override"><code>import argparse import logging import os import smtplib import time import httpx i...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-23T22:49:52.640", "Id": "259917", "Score": "1", "Tags": [ "python", "performance" ], "Title": "check list of urls response code" }
259917
<p>I am trying to calculate some values using numpy. Here is my code,</p> <pre><code>x= np.zeros([nums]) for i in range (nums): x[i] = np.mean((Zs[i :] - Zs[:len(Zs)-i]) ** 2) </code></pre> <p>The code runs perfectly and give desired result. But it takes very long time for a large number <code>nums</code> valu...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-30T13:27:42.777", "Id": "513601", "Score": "2", "body": "How are you sure that this is where the code is slow? Have you profiled the entire program? For us to help you optimize the code we need to understand more about what the code do...
[ { "body": "<h1>Minor style edits</h1>\n<p>Like you said, the code seems to be perfectly fine and I don't see a very obvious way to make it faster or more efficient, as the consecutive computations you are making in your <code>for</code> loop don't seem to be easy to relate to one another.</p>\n<p>Of course this...
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T08:04:01.983", "Id": "259927", "Score": "-1", "Tags": [ "python", "numpy" ], "Title": "Speed up calculation time of for loop in numpy" }
259927
<p>I'm currently learning Go and I have decided to implement a Circular Doubly Linked List (Deque) structure for the training. Go is not my first language. I program mainly in Python, therefore I would like to learn if code follows Go structure and idioms and if you have any advice of improving.</p> <p><strong>About th...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T21:52:12.903", "Id": "513193", "Score": "0", "body": "Pop can return two variables an int and a bool to inform caller if queue is empty or not with bool instead of panicking or returning an error. Also you should not shadow types w...
[]
{ "AcceptedAnswerId": null, "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T08:22:34.633", "Id": "259928", "Score": "1", "Tags": [ "linked-list", "go" ], "Title": "Integer Double Ended Queue GO" }
259928
<p>I have a single producer and single consumer, and the producer never stops, but the consumer might not keep up. There's no need to consume every item, as long as we always access the most-recently produced item, and never process an item twice. In other words, we should drop items if the consumer isn't keeping up,...
[]
[ { "body": "<h1>Answers to your questions</h1>\n<blockquote>\n<p>Correctness. I believe it's correct in all cases, but concurrent code is notoriously hard to fully reason about, and I'd appreciate any insight into what I've missed.</p>\n</blockquote>\n<p>It don't see any correctness issues.</p>\n<blockquote>\n<p...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T08:42:32.323", "Id": "259929", "Score": "7", "Tags": [ "c++", "lock-free" ], "Title": "Lock-free triple buffer" }
259929
<p>I am working on the subject of the French championship 2019, composed of 20 teams, and each team plays 38 times, if team A plays with team B, whatever the result, each team plays another time with another team determined by the draw.</p> <p>If team A plays with team B, that means there are three possibilities 1/3 te...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T15:32:00.687", "Id": "259946", "Score": "1", "Tags": [ "r" ], "Title": "using R probability" }
259946
<p>This is my first month learning HTML and CSS, I have built a working download page for one of my Java projects and I wanted to see if there is anything to improve on my website.</p> <p>The website works as I expect, but I'm unsure if I'm doing anything wrong.</p> <p>Here is my code snippet, any feedback is appreciat...
[]
[ { "body": "<p>Not too much jumps out; some comments:</p>\n<ul>\n<li>You're missing your <code>DOCTYPE</code></li>\n<li>On the balance, if I were to be picky <code>&amp;times;</code> is more style than content where you've used it. You can leave your <code>button</code> empty and do a CSS <code>content</code> th...
{ "AcceptedAnswerId": "259952", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T17:09:52.373", "Id": "259950", "Score": "2", "Tags": [ "html", "css" ], "Title": "Personal Project Download Website" }
259950
<p>I am working on building a management interface for an ESL (English as a Second Language) institute, basically it is a language school where people learn English.</p> <p>I have prepared my models for each app and I really would like someone to review them and provide me with suggestions and possible mistakes in the ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T17:59:14.720", "Id": "259954", "Score": "1", "Tags": [ "python", "sql", "django" ], "Title": "Django Models for an ESL school" }
259954
<h2>Motivation</h2> <p>I and the company is working on building C++ SDK automatically for several platforms, including Windows.<br /> In summary, I have to test somehow if the private member of function pointers' type is correct, since <code>LoadLibrary</code> in Windows API only uses function names, ignoring its type....
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T12:56:47.333", "Id": "513019", "Score": "1", "body": "Welcome to the Code Review Community. We can answer questions like `And I can't understand why gcc<10 cannot compile the 4 overloads of call`. All we do on this site is review th...
[]
{ "AcceptedAnswerId": null, "CommentCount": "8", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T18:45:34.607", "Id": "259956", "Score": "2", "Tags": [ "c++", "template-meta-programming" ], "Title": "Generic way to access private/protected members" }
259956
<p>I've always struggled to create and sustainable, organizated, clean code. I tried to use a Factory method and it's working better now that I created another class.</p> <p>I know I should write documentation, but that's not the advice I'm looking for yet. Because I don't think documentation will help with organizati...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T20:14:29.067", "Id": "512989", "Score": "1", "body": "The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state...
[ { "body": "<p>Title idea: How to refactor simple API Client code in PHP CLI</p>\n<p>Here are a couple of tips:</p>\n<ol>\n<li><p>I would add <code>if</code>'s and <code>switch</code>'es as soon as possible. For example, you are setting fields and headers of <code>Request::class</code> inside it, just before the...
{ "AcceptedAnswerId": "259967", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T19:31:44.600", "Id": "259957", "Score": "2", "Tags": [ "php", "design-patterns", "factory-method", "php7" ], "Title": "Scrape multiple twitch IRC chats" }
259957
<p>Given a two-card poker hand and a board of 5 cards, I want to evaluate the player's hand strength as listed <a href="https://en.wikipedia.org/wiki/List_of_poker_hands" rel="nofollow noreferrer">here</a>.</p> <p>The evaluation of a poker hand was measured to be ~100 microseconds on average. Existing free equity calcu...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T02:41:27.243", "Id": "513003", "Score": "1", "body": "Hi @JGrohmann - the Card operator< and other operators are not \"stable\" ... i.e. given two cards with the same rank but different suit they don't make for a comparison that is ...
[ { "body": "<p>Your code looks very well written, following many C++ best practices. The only strange things I found is that you don't use <code>auto</code> inside <code>for</code>-statements, for example I would write <code>for (auto &amp;c: cards)</code> instead of <code>for (const Card &amp;c: cards)</code>, ...
{ "AcceptedAnswerId": "259981", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T19:48:13.993", "Id": "259959", "Score": "3", "Tags": [ "c++", "performance", "algorithm", "playing-cards" ], "Title": "Poker Hand Evaluation (speed optimization)" }
259959
<p>I have written a class library for creating timer-based bacground operations in .NET projects. The idea is to be able to create and manage (start/stop/resume/cancel) recurring background operations and also to be able to poll and/or react to changes in the background operation's state.</p> <p>The library consists ma...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T21:00:02.323", "Id": "512997", "Score": "0", "body": "Do you aware of existing `System.Threading.Tasks.Task`? [Asynchronous Programming](https://docs.microsoft.com/en-us/dotnet/csharp/async). Looks like inventing yet another wheel. ...
[]
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-24T20:04:35.347", "Id": "259960", "Score": "3", "Tags": [ "c#", "thread-safety", "classes", "library", "timer" ], "Title": "C# class library for managing recurring background...
259960
<p>I'm preparing for coding interviews and I wanted to get feedback on this question which asks you to write a simple ratelimiter that can handle 5 requests every 2 seconds for example. Since it is for a coding interview setting, I don't think it needs to be perfect.</p> <p>I looked at the guava Ratelimiter for inspira...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T06:58:47.250", "Id": "513005", "Score": "3", "body": "Welcome to Code Review. Would be better to provide an example of usage or some tests. Besides helping reviewers it can be useful for you, since most interview exercises expect un...
[ { "body": "<h2>Testability</h2>\n<p>Whilst not a prerequisite for a review, @Marc is correct that unit tests would be helpful here and you would usually want to include them in your exercise submission. You want to demonstrate both that you know the code works as importantly that you've considered how easy it ...
{ "AcceptedAnswerId": "259972", "CommentCount": "1", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T04:21:56.723", "Id": "259968", "Score": "1", "Tags": [ "java", "thread-safety" ], "Title": "Simple Ratelimiter Feedback" }
259968
<p>I wrote a simple softmax classifier to classify MNIST digit handwriting data set. Feel free to comment anything!</p> <pre><code>#include &lt;algorithm&gt; #include &lt;bit&gt; #include &lt;cassert&gt; #include &lt;chrono&gt; #include &lt;cmath&gt; #include &lt;cstdint&gt; #include &lt;execution&gt; #include &lt;file...
[]
[ { "body": "<p>That's a very big list of includes! It might be a sign that you have functionality that should be split out to separate source files (e.g. filesystem read/write away from the core computation). Keeping the standard library includes alphabetical is a good choice - it allows very easy checking of ...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T08:18:53.270", "Id": "259970", "Score": "9", "Tags": [ "c++", "machine-learning", "c++20" ], "Title": "C++20 : Simple Softmax classifier for MNIST dataset" }
259970
<p>I have made an Android Tic-Tac-Toe adaptation as a weekend-project.</p> <p><a href="https://i.stack.imgur.com/ldwqm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ldwqm.png" alt="image1" /></a></p> <p><a href="https://i.stack.imgur.com/Gn9fL.png" rel="nofollow noreferrer"><img src="https://i.stac...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-05-09T00:30:18.657", "Id": "514223", "Score": "0", "body": "By the way, you can change the checkmark to forsvarir's answer. His answer is much more useful than mine." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "202...
[ { "body": "<p><em>Disclaimer: I'm far from being an expert, but since no one has responded to you yet and it's already been a couple of weeks. I thought I would try giving you some feedback.</em></p>\n<p>Your function <code>checkGameState</code> contains a lot of duplicate code. Try using a helper function to g...
{ "AcceptedAnswerId": "260500", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T08:56:47.567", "Id": "259971", "Score": "2", "Tags": [ "android", "kotlin" ], "Title": "Android Tic-Tac-Toe" }
259971
<p>As per the title, I'm making a webapp that is intended to use as a JS exercise platform. Problems are shown to users, they submit code, that code is run against a few test cases, and a report of the outcome is given back to the user.</p> <p>I'm using Django for my backend, but to run the code I have also set up a no...
[]
[ { "body": "<blockquote>\n<h3>what kind of tampering it might still be vulnerable to</h3>\n</blockquote>\n<p>I am working on testing this locally and in the process of getting it set up so I am not sure if these things are actual areas of concern but test tampering with globals like <code>JSON</code>, <code>pret...
{ "AcceptedAnswerId": "260241", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T09:44:06.777", "Id": "259973", "Score": "3", "Tags": [ "javascript", "node.js", "ecmascript-6", "django", "virtual-machine" ], "Title": "Node backend to run user-submi...
259973
<p>I am a beginner, and I'm trying to secure a sign-login system on my website. Is my code good/enough to prevent SQL injection?</p> <p><em><strong>THIS IS THE SIGN FILES</strong></em></p> <p><strong>This is the index.php that takes user input:</strong></p> <pre><code>&lt;?php require('some_path\autoload_class.php'); ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-28T14:13:20.363", "Id": "513358", "Score": "0", "body": "`echo` is not a function. Adding parentheses is very confusing" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-28T14:14:04.740", "Id": "513359", ...
[ { "body": "<p>Your code is good enough at preventing sql injection. But it sucks (pardon me) in everything else.</p>\n<p>Don't print database error to the user.</p>\n<p>Don't put echoes into your logic.</p>\n<p>Don't double last letters of post fields names.</p>\n<p>Don't repeat yourself by integrating your dat...
{ "AcceptedAnswerId": "260008", "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T10:03:30.833", "Id": "259975", "Score": "4", "Tags": [ "php", "sql", "mysql", "security", "pdo" ], "Title": "Storing and confirming user input" }
259975
<p>I have wrote a <code>MutableLiveList</code> class for android, similar to existing <code>MutableLiveData</code>, but this class instead handles a list and notifies its observers on structural changes like adding items and removing items. It is intended to be used inside viewModels similar to <code>MutableLiveData</c...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T16:13:36.580", "Id": "513039", "Score": "0", "body": "@Tenfour04 huh.. kindof. I don't know how to write unit tests. Actually I doubt something in this code, which I have asked [here](https://stackoverflow.com/questions/67255037/is-...
[ { "body": "<p>You could define the class constructor this way to avoid manually delegating those basic functions:</p>\n<pre><code>class MutableLiveList&lt;E&gt; private constructor(private val list: MutableList&lt;E&gt;) : MutableList&lt;E&gt; by list {\n constructor(): this(mutableListOf())\n\n //...\n}\...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T10:18:43.063", "Id": "259977", "Score": "1", "Tags": [ "android", "kotlin" ], "Title": "MutableLiveList class for android" }
259977
<p>I have a object list like below. I want to join every two rows into single row based on column B. It is sure that only two rows would be there for every single column B value.</p> <p><strong>Input</strong></p> <p><a href="https://i.stack.imgur.com/cd0dV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur....
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T12:33:55.783", "Id": "513017", "Score": "4", "body": "Welcome to the Code Review Community. Can you provide more context about this code in the question. Why are you merging multiple rows? What does the rest of the program do? Why d...
[ { "body": "<p>If you want to reduce the iteration to get the value for ColumnC and ColumnD and make the code cleaner, you can try using Aggregate instead.</p>\n<pre><code>var output = input\n .GroupBy(d =&gt; new {d.ColumnA, d.ColumnB})\n .Select(\n g =&gt; g.Aggregate(\n...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T11:10:12.840", "Id": "259980", "Score": "0", "Tags": [ "c#", "linq", "linq-expressions" ], "Title": "Merging every two objects into single single object making group by a property...
259980
<p>I wrote a working program in C that takes an array with size 2ⁿ, and separates all the even numbers from the odd numbers.<br /> For example: Input: {1,2,3,4,5,6,7,8}, Output: {8,2,6,4,5,3,7,1}<br /> I want my program to be as efficient as possible and to have space complexity O(log n) and time complexity of O(n log ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T17:25:47.263", "Id": "513043", "Score": "1", "body": "Does the order matter?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T07:49:16.523", "Id": "513108", "Score": "1", "body": "The accep...
[ { "body": "<h1>Efficiency</h1>\n<p>Your code is already more efficient than you think. It has time complexity <span class=\"math-container\">\\$\\mathcal{O}(n)\\$</span>, and thanks to <a href=\"https://en.wikipedia.org/wiki/Tail_call\" rel=\"nofollow noreferrer\">tail recursion</a>, it also has space complexit...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T13:20:00.470", "Id": "259982", "Score": "5", "Tags": [ "performance", "c", "array", "recursion" ], "Title": "Separating the even and odd numbers in an array in C" }
259982
<p>I made a function that directly calculates the discrete Fourier transform in dimension two, as well as functions that automatically initialize a 2D array to either something random, or specific basis elements (when viewing multidimensional arrays as tensors, but that's not important). Also an approximate equality ch...
[]
[ { "body": "<p>This is not how to correctly use <code>assert()</code>:</p>\n<blockquote>\n<pre><code>double complex (*output)[N1] = malloc( sizeof(double complex[N0][N1]) );\nassert(output); // malloc returns a null pointer when the memory is not available\n // and this is the only pointer that ge...
{ "AcceptedAnswerId": "259990", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T15:06:49.203", "Id": "259984", "Score": "2", "Tags": [ "beginner", "c" ], "Title": "C test functions for 2D FFT" }
259984
<p>I've been assigned the following Python homework:</p> <blockquote> <p>Implement myrange that acts like <code>range</code> using iterators. Define a function <code>myrange</code>and define a class <code>MyRange</code>.</p> </blockquote> <p>We've just seen iterators, so I think I'm asked to use them. I am not require...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T17:25:04.010", "Id": "513042", "Score": "3", "body": "If `myrange()` is supposed to act like `range()`, shouldn't it take similar arguments: `start`, `stop`, and `step`? It doesn't seem like your implementation is following the inst...
[ { "body": "<h1>You have an iterator</h1>\n<p>Your code implements an iterator, you are right. You have defined a <code>__next__</code> method and it works well.</p>\n<p>I would tweak your code slightly, though:</p>\n<ul>\n<li>remove the <code>check</code> because iterators can be empty and that is okay;</li>\n<...
{ "AcceptedAnswerId": "259993", "CommentCount": "4", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T16:07:05.100", "Id": "259987", "Score": "2", "Tags": [ "python", "python-3.x", "object-oriented", "iterator", "interval" ], "Title": "Implement a range behaviour in Py...
259987
<p>This is a follow-up question for <a href="https://codereview.stackexchange.com/q/259780/231235">GetNeighborhood function for 3D cells structure in MATLAB</a>. Based on the existing <a href="https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.374.7899&amp;rep=rep1&amp;type=pdf" rel="nofollow noreferrer">2D non-...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T18:31:31.707", "Id": "259992", "Score": "1", "Tags": [ "performance", "algorithm", "array", "matrix", "matlab" ], "Title": "3D Non-local Mean Algorithm in MATLAB" }
259992
<p>I would like to have a <em>minimal</em> storable class in Python that I can use as ORM. I quite thinking my approach is bad, but I would like to have your opinion.</p> <p>I do not want to use SQLAlchemy or PeeWee as it is too complex for my application.</p> <p>I wrote a <code>Model</code> class from which I can deri...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T03:30:45.033", "Id": "513081", "Score": "1", "body": "A truly tiny persistent class is just a normal class serialised via pickle. Why not just do that?" }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-29T...
[]
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T20:21:52.847", "Id": "259995", "Score": "1", "Tags": [ "python", "database" ], "Title": "Tiny persistent storable class" }
259995
<p>This small programme is an exercise that my teacher gave us.</p> <p><code>n</code> is an alphabetic input that its length must be between 5 and 10. You have to insert the characters of the input one by one to a list called <code>T</code>. Then, add the reverse case of letters to another list called <code>V</code>. S...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T21:54:09.800", "Id": "513060", "Score": "0", "body": "Welcome to Code Review! The current question title is too general to be useful here. Please [edit] to the site standard, which is for the title to simply state **the task accompl...
[ { "body": "<p>A flexible approach to getting user input is to use a while-true loop, breaking\nwhen conditions are met. The structure is easy to remember and allows you to\nhandle user mistakes without awkward setup or code repetition:</p>\n<pre><code>while True:\n x = input('...')\n if x is OK:\n ...
{ "AcceptedAnswerId": "259999", "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T21:45:24.660", "Id": "259996", "Score": "3", "Tags": [ "python" ], "Title": "Get 5 to 10 characters and flip their case" }
259996
<h2>Background</h2> <p>I am writing a custom library whose keywords can be used with Robot Framework to verify configuration files, check running processes, and eventually other things tailored to a project I work on. The Robot tests would eventually be included as part of a Jenkins job.</p> <p>I'm not used to writing ...
[]
[]
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T22:50:57.393", "Id": "259998", "Score": "0", "Tags": [ "python", "python-3.x", "object-oriented", "robotframework" ], "Title": "Python Classes for Robot Test Framework which O...
259998
<p>As a purely pedagogical exercise, I've been trying to use Rust's (very expressive) type system to define the bare minimum one might expect from an <strong>ordinary</strong> list type.</p> <p>While there's likely a higher-level argument here about mutable vs immutable lists, and <a href="https://rust-unofficial.githu...
[]
[ { "body": "<h2>Don't force unnecessary bounds on your trait</h2>\n<p>You're requiring many bounds on your trait that simply aren't necessary. For example, it's nice to have the <code>Debug</code> trait so you can easily print out debug information, but you're currently having that as a <strong>requirement</stro...
{ "AcceptedAnswerId": "260005", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-25T23:21:00.660", "Id": "260000", "Score": "1", "Tags": [ "design-patterns", "rust", "library", "trait" ], "Title": "Minimal list definition in Rust" }
260000
<blockquote> <p>Create a class template named <code>ValueStore</code> that has a member variable, to store a value and a member variable, <code>hasValue</code> that holds a true value if there is data in the value member variable and false otherwise. Use the class to store three values of different types.</p> </blockqu...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T03:26:42.757", "Id": "513078", "Score": "7", "body": "You should separate this into two questions." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T03:26:56.307", "Id": "513079", "Score": "3", ...
[ { "body": "<h1>About these assignments</h1>\n<p>As someone who’s been teaching C++ for <del>15</del> holy shit, almost 20 years now, I have to say that these assignments are pretty terrible… especially the “vector” one. (To be clear, I mean the <em>assignments</em> are terrible… not the <em>attempts</em>. The a...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T02:02:52.800", "Id": "260004", "Score": "1", "Tags": [ "c++", "reinventing-the-wheel", "homework" ], "Title": "Value store (\"optional\" type)" }
260004
<p>I have extensively consulted Raku documentation and have tried many combinations to finally arrive at this working solution.</p> <pre><code>#!/usr/bin/perl6 use v6; my $a; my $b = 34; my $c; $a = prompt &quot;enter number: &quot;; $c = ($a * $b); say &quot;$a multiplied by $b is $c&quot;; </code></pre>
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T07:16:13.930", "Id": "513097", "Score": "0", "body": "Hey there, welcome to the community! CodeReview.SE is to ask for peer reviews of code that is _working as intended_! For help with problems in your code, like the ones you seem t...
[ { "body": "<p>To tighten your code a bit, you can declare <code>my $a</code> and assign in the same line:</p>\n<pre><code>my $a = prompt &quot;enter number: &quot;;\nmy $b = 34;\nmy $c;\n$c = ($a * $b);\nsay &quot;$a multiplied by $b is $c&quot;;\n</code></pre>\n<p>The above seems to solve your question, howe...
{ "AcceptedAnswerId": null, "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T03:31:06.787", "Id": "260006", "Score": "2", "Tags": [ "raku" ], "Title": "Raku multiplication using prompt and say" }
260006
<p>I have written a merge sort in C and would like any advice on how to improve it. Any advice helps to make the code better!</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;stdint.h&gt; #include &lt;string.h&gt; static void mergesort_helper(void *array, uint32_t index, uint32_t length, ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T15:10:38.740", "Id": "513149", "Score": "2", "body": "Merge sort makes little sense for random-access arrays." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T15:26:42.833", "Id": "513154", "Sc...
[ { "body": "<p>I'm not too confident with my knowledge on (void) pointers so I will avoid giving feedback on the pointer related stuff.</p>\n<h2>Unnecessary if...else statement.</h2>\n<pre class=\"lang-c prettyprint-override\"><code>if(length % 2 == 0)\n mergesort_helper(array, (index + (index + length)) / 2,...
{ "AcceptedAnswerId": null, "CommentCount": "6", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T04:11:00.537", "Id": "260010", "Score": "11", "Tags": [ "c", "sorting", "mergesort" ], "Title": "Mergesort Criticism in C" }
260010
<p>I am trying to filter the events table to get ongoing events and complete events, but pycharm keeps underlining my code because of duplicated code. How do I prevent for loop code duplicates on the two functions below? Better yet, how do I optimally refactor these two functions? Thanks</p> <pre><code> def get_ongoing...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T07:30:44.427", "Id": "513100", "Score": "5", "body": "The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to **simply sta...
[ { "body": "<h1>Factoring duplication out</h1>\n<p>Whenever I have (near-)duplicate code, what I do is take a look at the repeated code. The parts that change ever so slightly are going to be controlled with arguments to functions and etc, whereas the parts that remain the same will just be left more-or-less as-...
{ "AcceptedAnswerId": "260014", "CommentCount": "2", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T06:42:13.970", "Id": "260012", "Score": "1", "Tags": [ "python-3.x" ], "Title": "I am trying to filter a queryset based on dates, I keep getting a duplicate error on the for loops,How...
260012
<p>I have the problem, my methods become slower and slower after many data. My methods can generate 100 rows with 20 columns around 1-3s, but after that my methods become slower and slower.</p> <p>And for another information, i'm still using NPOI ver 2.4.1 in ASP.NET Web Form (Target framework 4.6.1)</p> <p>Here's my c...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T09:40:25.053", "Id": "513121", "Score": "3", "body": "The current question title, which states your concerns about the code, is too general to be useful here. Please [edit] to the site standard, which is for the title to simply stat...
[ { "body": "<p>I already found the problem, in the generate item row loop here</p>\n<pre><code>// Generate Item Row\nif (dataList != null &amp;&amp; dataList.Any())\n{\n int rowNumber = 1;\n foreach (var item in dataList)\n {\n item.RowNumber = rowNumber;\n var row = sheet.CreateRow(rowNum...
{ "AcceptedAnswerId": null, "CommentCount": "7", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T09:20:38.013", "Id": "260021", "Score": "0", "Tags": [ "c#", "performance", "excel" ], "Title": "Improvement for generating excel with many data" }
260021
<p>Any suggestions on improving the speed of below code. My dictionary is rather large in fold of * 100000 and expected to grow larger every day.</p> <p>I am open to completely new ideas or approaches to do the below operation.</p> <pre><code>from pyxdameraulevenshtein import damerau_levenshtein_distance, normalized_da...
[]
[ { "body": "<p>Take a look at <a href=\"https://en.wikipedia.org/wiki/BK-tree\" rel=\"nofollow noreferrer\">BKTrees</a>. <a href=\"http://nullwords.wordpress.com/2013/03/13/the-bk-tree-a-data-structure-for-spell-checking/\" rel=\"nofollow noreferrer\">Here</a> is a less technical description. There is a Python l...
{ "AcceptedAnswerId": "260151", "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T10:38:10.910", "Id": "260023", "Score": "0", "Tags": [ "performance", "python-3.x" ], "Title": "perform fuzzy matching on a large set of dictionary keys" }
260023
<p>I wrote a C++ program that merges two convex hulls in linear time. The algorithm is based on <a href="http://cgm.cs.mcgill.ca/%7Egodfried/teaching/cg-projects/97/Plante/CompGeomProject-EPlante/algorithm.html" rel="nofollow noreferrer">http://cgm.cs.mcgill.ca/~godfried/teaching/cg-projects/97/Plante/CompGeomProject-E...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T15:06:45.540", "Id": "513146", "Score": "0", "body": "Are you required to use a specific (non-current) version of C++? That is, if you can't use C++20 features we won't point out that you're doing things the old (hard, verbose) way...
[ { "body": "<p>General impression when starting to read your code is that it's good! You're using <code>constexpr</code>, defining your constructors nicely, etc.</p>\n<h1>includes</h1>\n<p>Generally, I'll list standard includes <em>first</em>, and project-local includes at the end of the list.</p>\n<h1>scope an...
{ "AcceptedAnswerId": null, "CommentCount": "3", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T12:42:47.257", "Id": "260027", "Score": "0", "Tags": [ "c++", "algorithm", "computational-geometry" ], "Title": "C++ : Merging two convex hulls" }
260027
<p>My primary coding language is C++, but I occasionally use C. I wrote some simple image segmentation using Union-Find algorithm. Feel free to comment anything!</p> <pre><code>#include &lt;stdlib.h&gt; #include &lt;stdbool.h&gt; #include &lt;stdio.h&gt; #include &lt;stdint.h&gt; #include &lt;math.h&gt; #include &lt;st...
[]
[ { "body": "<h2>Use const</h2>\n<p>In <code>FindCompress</code> and <code>Union</code> the parameters <code>N</code>, <code>i</code> and <code>j</code> could be passed as const as they are not changed in the functions.</p>\n<h2>Avoid using keywords as function names.</h2>\n<p>In C <code>union</code> is a keyword...
{ "AcceptedAnswerId": null, "CommentCount": "0", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T13:04:27.127", "Id": "260028", "Score": "5", "Tags": [ "algorithm", "c", "image" ], "Title": "C : Image Segmentation" }
260028
<p>I have a database, with tens of thousands of records, which I wish to represent in python. The python 2.x version has tables in which each record is an instance of a class and the values in the record are held in attributes of the object. Some of the attributes are terms which are used to classify records. The class...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T16:24:21.930", "Id": "513166", "Score": "1", "body": "How are you using your code? I can write a review without seeing how you're actually using the code. However my review may not factor in your usage and be sub-optimal. Can you sh...
[]
{ "AcceptedAnswerId": null, "CommentCount": "5", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T16:10:13.260", "Id": "260036", "Score": "0", "Tags": [ "python-3.x", "classes", "classification" ], "Title": "Using python classes to classify database records" }
260036
<p>I have made the decision to move the storing of session data to the database.</p> <p>Any new ideas, suggestions are welcome.</p> <p>Please also give security suggestions.</p> <p>Like SQL injection is possible here, etc...</p> <pre><code>&lt;?php /** * MySQL/MariaDB Session Handler - Handle Sessions using Database ...
[ { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T18:45:04.243", "Id": "513178", "Score": "0", "body": "The `gc()` metod is broken. It looks like a copy of destroy method." }, { "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T22:07:33.200", "Id": "5131...
[ { "body": "<ul>\n<li><p>Use the null coalescing operator for all occurrences where you want to provide fallback values for undeclared/<code>null</code> variables.</p>\n<pre><code>$this-&gt;tablename = $config[&quot;tablename&quot;] ?? $this-&gt;tablename;\n</code></pre>\n</li>\n<li><p>I agree with @Dharman's co...
{ "AcceptedAnswerId": "260144", "CommentCount": "9", "ContentLicense": "CC BY-SA 4.0", "CreationDate": "2021-04-26T16:26:02.837", "Id": "260037", "Score": "2", "Tags": [ "php", "mysql", "database", "mysqli", "session" ], "Title": "MySQL database custom session handler using PHP wit...
260037