body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>I'm trying to get this to run faster, even marginally so. Right now to update 470 rows it takes about 90 seconds. It works, but I know there are better ways. I understand calls to Spreadsheet API are slow, and batching getRanges and setValues would speed things up, but doesn't seem obvious given the brief bit I know... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-16T23:48:32.237",
"Id": "508130",
"Score": "0",
"body": "Welcome to Code Review! I [changed the title](https://codereview.stackexchange.com/posts/257269/revisions) so that it describes what the code does per [site goals](https://codere... | [
{
"body": "<h2>General review</h2>\n<p>Generally the code is OK and problems are due to lack of experience rather than bad style or habit.</p>\n<p>I am unfamiliar with SpreadsheetApp so you should wait in case someone that is adds another answer before you accept this answer, if so inclined.</p>\n<p>Rather than... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-16T20:55:26.560",
"Id": "257269",
"Score": "1",
"Tags": [
"javascript",
"performance",
"google-apps-script"
],
"Title": "Set Dates on Spreadsheet Rows"
} | 257269 |
<p>So, I code sometimes but I'm always bored with my code and I felt I have a lack of python skills and I see some piece of code when I finished it. This below is a piece that I did today and I want to share with you to take some advice in how I can improve this and so my Python proficiency.</p>
<p>The idea below is to... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T05:47:59.840",
"Id": "508152",
"Score": "4",
"body": "The site standard is for the title to simply state the task accomplished by the code, not your concerns about it. Please see [How do I ask a good question?](https://codereview.st... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T02:57:49.963",
"Id": "257280",
"Score": "0",
"Tags": [
"python"
],
"Title": "How to refine coding skills?"
} | 257280 |
<p>I have tried to design the parking lot problem. Here is the problem statement.</p>
<blockquote>
<p>Design a parking lot with multiple floors where customers can park
their cars. Each parking floor will have many parking spots. The
system should support multiple types of parking spots such as Compact,
Large, Handicap... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T09:28:58.923",
"Id": "508180",
"Score": "3",
"body": "Welcome Vivek to code review. While you have a nice question, it is off-topic here, as we will review *existing code*."
},
{
"ContentLicense": "CC BY-SA 4.0",
"Creati... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T06:26:27.743",
"Id": "257283",
"Score": "2",
"Tags": [
"java",
"algorithm",
"object-oriented",
"design-patterns"
],
"Title": "Design a parking lot"
} | 257283 |
<p>I am working on a <strong>online newspaper/blogging application</strong> with <strong>CodeIgniter 3.1.8</strong> and <strong>Twig</strong>.</p>
<p>The application is meant to offer developers and designers the possibility to very easily turn their HTML templates into database-powered websites. To achieve this, I use... | [] | [
{
"body": "<p>I will share here my thoughts and personal opinions:</p>\n<ol>\n<li>Use this array format <code>[]</code> and not <code>array()</code></li>\n<li>Instead of loading data and business logic inside the view (e.g subscribers list - <code><?php if(count($subscribers)):?></code>). Do everything on... | {
"AcceptedAnswerId": "257392",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T06:26:35.800",
"Id": "257284",
"Score": "1",
"Tags": [
"ajax",
"codeigniter"
],
"Title": "Newsletter Subscription Functionality in Codeigniter 3"
} | 257284 |
<p>I have some situations where I run <code>async</code> code inside <code>class constructor</code>:</p>
<h3>1. Run async code that returns a response</h3>
<p>I execute some <code>async</code> code that returns a response, then I apply <code>then</code> and <code>catch</code> inside <code>class constructor</code>:</p>
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T02:00:30.690",
"Id": "508261",
"Score": "0",
"body": "The mistake I usually see with using an async call in a constructor is that the call fetches data... every time an object is created. There's no opportunity for caching, lots of ... | [
{
"body": "<p>The job of a constructor is to initialize the instance, i.e. put it in a defined state. Using (encapsulated) async code there might result in an instance that is only partially initialized. This would result in the instance being in an undefined state and thusly in code using it, that relies on th... | {
"AcceptedAnswerId": "257313",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T08:20:22.303",
"Id": "257290",
"Score": "3",
"Tags": [
"javascript",
"typescript"
],
"Title": "Use async code in class constructor"
} | 257290 |
<p>I have this code to get audio output levels in dB to an array (peak_dB[8]) to be used in real time peakmeter:</p>
<pre><code>#include <emmintrin.h>
float channelsPeak[8] = { 0 };
float peak_dB[8] = { 0 };
__m128 log2_sse(__m128 x) {
// https://www.kvraudio.com/forum/viewtopic.php?p=7524831#p7524831
// 12... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T12:47:00.640",
"Id": "508204",
"Score": "0",
"body": "Why are you using SSE for this ? It seems pointless in this particular case - is it just for learning/experimental purposes ?"
},
{
"ContentLicense": "CC BY-SA 4.0",
... | [
{
"body": "<h1>Storing</h1>\n<blockquote>\n<p>Are there other (better) ways to insert data from s2 into last four elements of peak_dB (AVX excluded)?</p>\n</blockquote>\n<p>Yes, actually you already used that way: it's <code>_mm_store_ps</code>. For example:</p>\n<pre><code> s2 = lin2db(s2);\n _mm_store_p... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T12:25:32.520",
"Id": "257297",
"Score": "1",
"Tags": [
"c++",
"array",
"sse"
],
"Title": "Insert an array[4] to an array[8] (C++, SSE)"
} | 257297 |
<p>I want to build a barebones system according to the following spec:</p>
<p>Given a setup of <code>n</code> computers, if the <code>ith</code> computer receives an operation to update a given key-value pair, it should perform the update, and propagate it to all other nodes. I'd like communication between nodes to be ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T21:29:28.187",
"Id": "508371",
"Score": "1",
"body": "Could you be more specific on the \"fault-tolerant\" part? What would you expect to happen if two nodes receive the same key at (roughly) the same time? What should happen if a r... | [
{
"body": "<p>On the coding side, every <code>Node</code> has an attribute <code>Server</code> and the <code>Server</code> has a reference to the <code>Node</code> it belongs to. <code>Node</code> calls <code>Server</code>'s methods, and <code>Server</code> reads <code>Node</code>'s attributes, so they currentl... | {
"AcceptedAnswerId": "257383",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T12:32:21.800",
"Id": "257298",
"Score": "0",
"Tags": [
"python"
],
"Title": "Python RPC Design Pattern - is bidrectional coupling a good idea?"
} | 257298 |
<p><a href="https://www.mastersofgames.com/rules/mancala-rules.htm" rel="nofollow noreferrer">https://www.mastersofgames.com/rules/mancala-rules.htm</a></p>
<p>I am trying to create a working Mancala Game in scala, Currently, I have 3 classes, <code>Board</code>, <code>Mancala</code> and <code>Player</code>.</p>
<p>Her... | [] | [
{
"body": "<p>Without having seen the other classes, this one looks pretty good so\nfar.</p>\n<ul>\n<li>The comments are useful. That's fantastic!</li>\n<li><code>val space = " " * 28</code> lovely.</li>\n<li>Naming of variables is good and consistent. I usually argue for\nspelled out variable names... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T14:05:24.917",
"Id": "257301",
"Score": "4",
"Tags": [
"object-oriented",
"design-patterns",
"scala"
],
"Title": "Improving Mancala Game"
} | 257301 |
<p>I have been working with where I use watchdogs to be able read whenever I have created a file by the name -> <em>kill_</em>.flag and it contains:</p>
<pre><code>*kill_*.flag contains:
hello;https://www.google.se/;123
</code></pre>
<p>and my script is then going to read the created file, split the ";" b... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T13:05:24.630",
"Id": "508308",
"Score": "0",
"body": "Are you using Python 2?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T13:15:14.207",
"Id": "508314",
"Score": "0",
"body": "Python 3... | [
{
"body": "<p>I genuinely hope you don't take offence by this, but this implementation is so insane that it's frankly impressive.</p>\n<p>Since you have <code>delete_flag = "*kill_*.flag"</code>, calling <code>os.path.split</code> on it is pointless. Perhaps you're substituting that with something els... | {
"AcceptedAnswerId": "257329",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T15:18:29.583",
"Id": "257303",
"Score": "2",
"Tags": [
"python",
"python-3.x"
],
"Title": "Read created files in a folder"
} | 257303 |
<p>I have stuck with this script it would be great if you could help me with your inputs. My problem is that I think the script is not that efficient - it takes a lot of time to end running.</p>
<p>I have a fasta file with around 9000 sequence lines (example below) and What my script does is:</p>
<ol>
<li>reads the fir... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T15:37:36.677",
"Id": "508219",
"Score": "3",
"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>I think this should work - this is my own answer, please give your inputs</p>\n<p>I removed one list to avoid another layer of for loop in the code and performed the reverse-complement conversion in one compact loop. Also, I added the <code>pass</code> - <code>else</code> command to avoid writing ... | {
"AcceptedAnswerId": "257365",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T15:20:02.457",
"Id": "257304",
"Score": "1",
"Tags": [
"python",
"performance"
],
"Title": "Inefficient DNA heterodimerization script"
} | 257304 |
<p>This service takes in a report request object that can contain multiple reports that need to be rendered. This code works but I'm not sure if I've implemented anything wrong. Note the <code>exportedImage.Result</code> makes this synchronous but when I tried adding async and await to the <code>Parallel.ForEach</code>... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T17:49:52.667",
"Id": "508238",
"Score": "2",
"body": "No, you're not using it properly. Do not mix `async`/`await` with the TPL methods (`Parallel.`). They're two totally different approaches to scalability."
},
{
"ContentLi... | [
{
"body": "<p>Here's pure <code>async</code> example without any workarounds.</p>\n<pre class=\"lang-cs prettyprint-override\"><code>private async Task ProcessReport(Report report, ConcurrentDictionary<int, string> reportDictionary)\n{\n var (reportPath, bindingOrder, reportParameters) = report;\n \... | {
"AcceptedAnswerId": "257320",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T16:38:00.410",
"Id": "257306",
"Score": "1",
"Tags": [
"c#",
"asynchronous",
"task-parallel-library"
],
"Title": "Render multiple SSRS reports in parallel"
} | 257306 |
<p>I have an object array and i am using gulp 4.</p>
<pre><code>libs:
{
a: {
js: [
{
src: 'path/from/a1.js',
dest: 'path/to/a1.js',,
},
{
src: 'path/from/a2.js',
dest: 'path/to/a2.js',,
},
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T21:28:00.410",
"Id": "508249",
"Score": "0",
"body": "Welcome to Code Review! As it stands the title of the post isn't describing at all what the purpose of the code is, it would be good if you could revise it, c.f. [the FAQ](https:... | [
{
"body": "<p>I would recommend a generic <code>filter</code> generator. This way the code does not need any knowledge of the shape of your input and the caller is left to decide how to handle the individual values -</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-... | {
"AcceptedAnswerId": "257314",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T16:38:21.583",
"Id": "257307",
"Score": "3",
"Tags": [
"javascript"
],
"Title": "Simple way to loop through a JavaScript object array?"
} | 257307 |
<p>By reading this post <a href="https://symfony.com/doc/current/rate_limiter.html" rel="nofollow noreferrer">https://symfony.com/doc/current/rate_limiter.html</a> I had an idea to use the Symfony rate_limiter as a GuzzleRateLimiterMiddleware.</p>
<p><strong>What do you think about it? Do you think it is a good idea or... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T07:27:28.770",
"Id": "508268",
"Score": "0",
"body": "Welcome to CodeReview. Does your solution work as expected / intended?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T08:45:48.260",
"Id": "5... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T17:56:31.447",
"Id": "257312",
"Score": "1",
"Tags": [
"php",
"symfony4"
],
"Title": "Use Symfony5 native rate-limiter to build a GuzzleRateLimiter middleware"
} | 257312 |
<p>I am attempting to implement a converter which can convert <code>List<string></code> type <a href="https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#Tables" rel="nofollow noreferrer">markdown table</a> into two dimensional array <code>string[,]</code>.</p>
<p><strong>The experimental implementat... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T20:42:37.243",
"Id": "508245",
"Score": "0",
"body": "This does not seem to work as intended. You specify that each column should be centered with `:-:` but each is left aligned. This example seems too trivial to catch any problem... | [
{
"body": "<p>The <code>in</code> keyword in a parameter list is used to pass an argument by reference. This is used to speed up passing big structs. Since strings and lists are of a reference type, a reference is passed anyway. Specifying <code>ref</code>, <code>out</code> or <code>in</code> makes them be pass... | {
"AcceptedAnswerId": "257321",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T20:08:14.133",
"Id": "257315",
"Score": "0",
"Tags": [
"c#",
"strings",
"array",
"formatting"
],
"Title": "Markdown table strings to two dimensional array converter implem... | 257315 |
<p>The idea is to perform indexing of filetrees while excluding certain directories. I want to give the user a simple conf file instead of having to edit the script itself.
This is what I came up with:</p>
<p>conf.file:</p>
<pre><code>cache
home/files
</code></pre>
<p>program:</p>
<pre><code>#!/usr/bin/env bash
functi... | [] | [
{
"body": "<p>You can use subcommands in a command:</p>\n<pre><code>echo "This $(date) is a date calculated in the echo command"\n</code></pre>\n<p>When you don't need additional control statements, you can use combined code like:</p>\n<pre><code>find /data/data/com.termux \\\n $(awk '{printf("... | {
"AcceptedAnswerId": "257441",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T20:22:38.877",
"Id": "257316",
"Score": "0",
"Tags": [
"beginner",
"bash"
],
"Title": "Generate a find command with pruned directories based on a config file"
} | 257316 |
<p>I have been looking for a way to display tabular data in a way that is optimal both for large (desktop) and small (smartphone) devices.</p>
<p>I use divs instead of tables.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="sn... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T21:39:14.520",
"Id": "508252",
"Score": "0",
"body": "@ferada It is responsive tabular data. What is not clear?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T21:51:49.200",
"Id": "508255",
"... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T21:20:36.000",
"Id": "257319",
"Score": "1",
"Tags": [
"javascript",
"css"
],
"Title": "Responsive pseudo-tables"
} | 257319 |
<p>Here is my OpenGL "Hello, Triangles" program. I tried to avoid all the deprecated functions and put the triangles in a buffer. Even in two different ways.</p>
<p>It is a bit bloated by the shader compile status checking. But this error info is very helpful. It is why I mention the original author whose cod... | [] | [
{
"body": "<p>If you don't want obsolete and deprecated stuff, don't use GLUT, see\n<a href=\"https://gamedev.stackexchange.com/questions/23644/is-glut-obsolete\">Is GLUT obsolete?</a>. Use\n<a href=\"https://www.glfw.org/\" rel=\"nofollow noreferrer\">GLFW</a> instead. I've personally used it and it\nis in my ... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-17T23:11:34.257",
"Id": "257323",
"Score": "5",
"Tags": [
"c",
"opengl"
],
"Title": "OpenGL Hello Triangles"
} | 257323 |
<p>I have written program which following purpose</p>
<ol>
<li>Traverse directory in multi threading environment
First determine all top level directory and store into vector which have following result:</li>
</ol>
<ul>
<li>/home/dir1</li>
<li>/home/dir2</li>
<li>... more than 1000</li>
</ul>
<ol>
<li>create number of ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T09:11:49.460",
"Id": "508276",
"Score": "2",
"body": "Does multi-threading help. Intuition seems to suggest the bottleneck here is disk IO."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T17:17:37.680... | [
{
"body": "<h1>Use of multithreading</h1>\n<p>Multithreading is normally used when you have a lot of work to do on the CPU, and spreading it out over multiple cores speeds up your program. However, here you don't do much work at all, just traversing the directories. This means that most of the time, your progra... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T01:30:21.540",
"Id": "257324",
"Score": "2",
"Tags": [
"c++",
"multithreading",
"file-system"
],
"Title": "Traverse directory using multithreading"
} | 257324 |
<p>Here is a function for creating sliding windows from a 1D NumPy array:</p>
<pre><code>from math import ceil, floor
import numpy as np
def slide_window(A, win_size, stride, padding = None):
'''Collects windows that slides over a one-dimensional array.
If padding is None, the last (rightmost) window is dropp... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T21:06:28.773",
"Id": "508363",
"Score": "0",
"body": "`numpy.lib.stride_tricks.sliding_window_view` is written in pure python; if it is not for the sake of a programming exercise, is there any reason why you can't ... faithfully bor... | [
{
"body": "<p>Few suggestions:</p>\n<ul>\n<li><p><strong>Input validation</strong>: there is no input validation for <code>win_size</code> and <code>padding</code>. If <code>win_size</code> is <code>-3</code> the exception says <code>ValueError: Stride must satisfy 0 < stride <= -3.</code>. If <code>paddi... | {
"AcceptedAnswerId": "257330",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T01:33:42.033",
"Id": "257325",
"Score": "2",
"Tags": [
"python",
"numpy"
],
"Title": "Efficient NumPy sliding window function"
} | 257325 |
<p>I have an array which I want to check for some values in second and fourth column.
If I pass to function <code>GWPA4205022</code> and <code>1550</code> I want function to:</p>
<ul>
<li>find in array all matches to <code>GWPA4205022</code></li>
<li>find the best combination of elements which sum is close to <code>155... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T02:18:49.867",
"Id": "257327",
"Score": "0",
"Tags": [
"javascript",
"google-apps-script",
"google-sheets"
],
"Title": "Finding the best set of values in array"
} | 257327 |
<p>This is part of a project I built to visualise pathfinding algorithms. These files run the algorithms and gather a list of frames, which are used to show the animations.</p>
<p>algorithms.ts</p>
<pre><code>export type Algorithm = (start: Coord, goal: Coord, walls: boolean[][], weights: number[][], heuristic: string)... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T11:04:38.510",
"Id": "257337",
"Score": "0",
"Tags": [
"typescript",
"pathfinding",
"data-visualization"
],
"Title": "Animating Pathfinding Generically"
} | 257337 |
<p>I want to remove a connection string that may already have been set in a different config file and then set it again.</p>
<p>Say my application has a Web.config file and a Web.Debug.config file then I can achieve what I want to do in the following way:</p>
<p>Web.config:</p>
<pre><code> <connectionStrings>
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T12:46:43.520",
"Id": "508303",
"Score": "1",
"body": "Is there a reason you posted this question on Code Review rather than Stack Overflow? The question sounds very hypothetical and that would make it off-topic for code review."
}... | [
{
"body": "<p>Each <code>add</code> entry in <code>connectionStrings</code> section will be parsed as <a href=\"https://docs.microsoft.com/en-us/dotnet/api/system.configuration.connectionstringsettings\" rel=\"nofollow noreferrer\">ConnectionStringSettings</a> at the end of the day.\nThis class has 3 properties... | {
"AcceptedAnswerId": null,
"CommentCount": "11",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T12:18:37.173",
"Id": "257339",
"Score": "0",
"Tags": [
".net",
"configuration"
],
"Title": "Remove and add connection string"
} | 257339 |
<p>I have been working with where I use watchdogs to be able read whenever I have created a file by the name -> <em>kill_</em>.json and it contains:</p>
<pre><code>*kill_*.json & *start_*.json contains:
{"store": "twitch", "link": "https://www.twitch.tv/xqcow", "id&q... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T15:47:29.260",
"Id": "508336",
"Score": "0",
"body": "Again - the model for this site doesn't allow for in-place edits. You're free to ask for clarification the way you are in comments, but we don't support updates in your question ... | [
{
"body": "<h2>Individual parameters</h2>\n<p>You're best to replace the <code>payload</code> parameter to <code>start_script</code> with individual <code>store: str</code>, <code>id: str</code> and <code>link: str</code>. Or, if it's common enough for this triple to be carried around, then move it into a <code... | {
"AcceptedAnswerId": "257347",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T13:24:17.553",
"Id": "257341",
"Score": "1",
"Tags": [
"python-3.x"
],
"Title": "Read created json files inside a given folder"
} | 257341 |
<p>I am trying to make a ddos code, and that's what I got so far. I am trying to make it more efficient and powerful, just for testing purposes. I'm new and I was wondering if I could do that? Is there any way to make this better</p>
<p>My code ddosed the specfic ip adress until right now.</p>
<pre><code>##############... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-25T11:15:50.403",
"Id": "508946",
"Score": "0",
"body": "Quote from [DDoS Attack Scripts](https://www.imperva.com/learn/ddos/ddos-attack-scripts/) : *\"Not all DDoS scripts are developed to be malicious. In fact, some are written by wh... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:01:59.063",
"Id": "257343",
"Score": "2",
"Tags": [
"performance",
"perl"
],
"Title": "Amplifying this ddos code"
} | 257343 |
<p>To better familiarize with async requests I wrote a very simple scraper that relies on <a href="https://docs.aiohttp.org/en/stable/" rel="nofollow noreferrer"><code>aiohttp</code></a> to retrieve some basic information from the product page (product name and availability status) or an Italian e-commerce retailer.<br... | [] | [
{
"body": "<blockquote>\n<p>One thing I am not too fond of (probably need to dive deeper into\ninheritance) is the use of placeholder methods in AsyncScraper as\nit'll force me to implement n dummy methods (where n is the number of\nwebsite-specific methods that can be found in the other classes). I\nfeel this ... | {
"AcceptedAnswerId": "257374",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:15:57.543",
"Id": "257344",
"Score": "0",
"Tags": [
"python",
"python-3.x",
"asynchronous",
"async-await"
],
"Title": "Using asyncio and aiohttp in classes"
} | 257344 |
<h1>Problem</h1>
<p>I need to be able to grab a subset of characters but ensure that each set doesn't exceed a specified limit and must end with a defined set of characters. For example, say I have an entire book worth of characters, I need to chunk that into a set of 300 characters but ensure that none of those chunks... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:54:25.207",
"Id": "508327",
"Score": "0",
"body": "What if the sentence is longer than 300 chars? Which rule wins?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:56:15.007",
"Id": "508328"... | [
{
"body": "<p>Don't you need to test for delimiters here? From reading your code I assume we want to max chunk but if inside the chunk there are delimiters we want to break that up. If the last section fits in the entire chunk it's not checking for delimiters</p>\n<pre><code>if (pointer == sourceSpan.Length)\... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:20:21.053",
"Id": "257345",
"Score": "2",
"Tags": [
"c#",
"performance",
"algorithm",
"strings"
],
"Title": "Chunk a large set of characters by a specified set of delimiter... | 257345 |
<p>I have the following menu concept -</p>
<p><a href="https://codepen.io/morgancarbonfourteen/pen/GRNbgEO" rel="nofollow noreferrer">https://codepen.io/morgancarbonfourteen/pen/GRNbgEO</a></p>
<pre class="lang-javascript prettyprint-override"><code>const body = document.getElementsByTagName("body")[0];
const... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T14:55:52.850",
"Id": "257348",
"Score": "0",
"Tags": [
"javascript"
],
"Title": "Animated menu system - mobile and desktop"
} | 257348 |
<p>I regularly wish to convert poses (position 3d + orientation 3d = 6d total) between different coordinate frames. Use-cases are for example in game engines and simulations to compute the position of objects relative to one another, or for example in robotics (my use-case) to compute the position of an object relative... | [] | [
{
"body": "<p>You've type-hinted some of your parameters and none of your returns, as in</p>\n<pre><code>def transform(new_frame: np.array):\n</code></pre>\n<p>Add the missing return type hints, probably <code>-> np.ndarray</code>.</p>\n<p>It's "homogeneous", not "homogenious".</p>\n<p>It... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T15:02:25.920",
"Id": "257349",
"Score": "1",
"Tags": [
"python",
"coordinate-system"
],
"Title": "Utilities for Coordinate Transformations (via homogeneous coordinates)"
} | 257349 |
<p>I have implemented the below <code>_get_schema</code> method to ensure that <code>schema</code> attribute is always present on the <code>Todos</code> instance, and can therefore be used in the mixin.</p>
<p>Is it OK to do it like this? As far as I know, mixins usually do not implement constructors.</p>
<p>Is there a... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T17:18:29.867",
"Id": "508348",
"Score": "0",
"body": "Your code looks like it has errors (two Mixin definitions, for example). Also, where does the scheme come from -- passed as argument, read from an external source, etc? How many ... | [
{
"body": "<p>The point of a mixin, at least as I've always understood it, is to inject\nmethods into other classes -- and not to create instances of the mixin class\nitself. So putting an <code>__init__()</code> in a mixin does seem like an odd pattern. Of\ncourse, <code>__init__()</code> is just a method: why... | {
"AcceptedAnswerId": "257378",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T15:57:13.573",
"Id": "257352",
"Score": "0",
"Tags": [
"python",
"inheritance",
"mixins"
],
"Title": "Ensuring that attributes referenced by a mixin are present in the childre... | 257352 |
<p>Say I have the following two different states:</p>
<pre><code>state1 = [0, 1, 0, 1, 1]
state2 = [1, 1, 0, 0, 1]
</code></pre>
<p>And I want to generate <em>n</em> number of <em>new</em> states by <strong>only</strong> changing the values at where these states <strong>differ</strong>; and I want to do so randomly. So... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T19:43:11.363",
"Id": "508358",
"Score": "0",
"body": "If you want to create a data set from two others that only changes where the originals differ, XOR is your friend"
}
] | [
{
"body": "<p>You could use <code>np.random.choice()</code> to generate the states, while using <code>a==b</code> and <code>a!=b</code> as masks.</p>\n<pre><code>def new_states(a,b,n):\n return [\n a*(a==b) + np.random.choice(2,len(a))*(a!=b)\n for _ in range(n)\n ]\n\nstate1 = np.array([0, ... | {
"AcceptedAnswerId": "257361",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T18:55:21.683",
"Id": "257360",
"Score": "3",
"Tags": [
"python",
"python-3.x",
"array",
"numpy"
],
"Title": "Generating multiple new arrays using numpy"
} | 257360 |
<p>To determine whether the specified array contains specific element or not, <a href="https://docs.microsoft.com/en-us/dotnet/api/system.array.exists?view=net-5.0" rel="nofollow noreferrer">Array.Exists</a> can be used if the given array is one dimensional. I am attempting to implement <code>Exists</code> method for m... | [] | [
{
"body": "<p>You can simply use the LINQ <a href=\"https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.any?view=net-5.0\" rel=\"nofollow noreferrer\">Enumerable.Any extension Method</a>.</p>\n<pre><code>bool result = array4.Cast<int>().Any(x => x == 1);\n</code></pre>\n<p>This works for... | {
"AcceptedAnswerId": "257368",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-18T20:41:00.053",
"Id": "257366",
"Score": "0",
"Tags": [
"c#",
"array",
"generics",
"reflection"
],
"Title": "Exists Method Implementation for Multidimensional Array in C#"
... | 257366 |
<p>I saw the expression below in a dining philosophers problem, and I didn't understand it. What is this style of coding called(assuming there is a special name for it)? What does the expression do? Please help explain it to me.</p>
<pre><code>int right = i;
int left = (i - 1 == -1) ? NO_OF_PHILOSOPHERS - 1 : (i - 1);
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T01:15:52.027",
"Id": "508381",
"Score": "1",
"body": "Aside from being a Stack Overflow question [rather than a Code Review one](https://codereview.stackexchange.com/help/on-topic), why would you tag C++ programmers with this when t... | [
{
"body": "<p>The line is equivalent to the following:</p>\n<pre><code>int left;\nif (i - 1 == -1) {\n left = NO_OF_PHILOSOPHERS - 1;\n} else {\n left = i - 1;\n}\n</code></pre>\n<p>Which simplifies to:</p>\n<pre><code>int left = i - 1;\nif (left == -1) {\n left = NO_OF_PHILOSOPHERS - 1;\n}\n</code></p... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T01:04:14.657",
"Id": "257375",
"Score": "1",
"Tags": [
"c",
"dining-philosophers"
],
"Title": "C code structure"
} | 257375 |
<p>How does the following look for doing a string replace in C? Is this approach more common than allocating memory within the function and returning a new string pointer, or is the bring-your-own-buffer more common?</p>
<pre><code>#include <stdio.h>
#include <string.h>
// return size of string, -1 if err... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T04:09:38.973",
"Id": "508384",
"Score": "0",
"body": "What about not passing a string? or something not properly terminated?"
}
] | [
{
"body": "<p>Few things to consider.</p>\n<ol start=\"0\">\n<li><p>Why are you writing your own implementation of something that already exists, long history of reliable use with well defined behaviour (fun/assignment - sure, generally - waste of effort likely to lead to problems)?</p>\n</li>\n<li><p>What if <... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T01:29:39.910",
"Id": "257376",
"Score": "2",
"Tags": [
"c",
"reinventing-the-wheel"
],
"Title": "Doing a string replace"
} | 257376 |
<p>I am creating a planner/scheduling app using objects. I am just a beginner with object oriented programming, so any tips on how to better structure my classes would be very helpful.</p>
<hr />
<p><strong>Program Basics</strong></p>
<p>The program consists of "objectives" and "checkpoints." An obj... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-25T23:20:54.787",
"Id": "509016",
"Score": "0",
"body": "Welcome to Code Review! Would you please [edit] your post to provide sample usage code? I could utilize the API of the code but am curious what your recommendations would be..."
... | [
{
"body": "<p>I notice that you have many member functions entitled <code>getX</code> or <code>setX</code>. It would be much more idiomatic in JavaScript to use <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get\" rel=\"nofollow noreferrer\">getters</a> and <a href=\"https... | {
"AcceptedAnswerId": "258767",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T03:25:48.817",
"Id": "257379",
"Score": "4",
"Tags": [
"javascript",
"object-oriented",
"classes"
],
"Title": "Javascript Object Oriented Planner App"
} | 257379 |
<p>A code that determines the roots of a quadratic equation.
Also, determine the following based on the discriminant <em>b² – 4ac</em>:</p>
<blockquote>
<p>If <em>b² − 4ac</em> is <strong>positive</strong>, display: “There are TWO REAL SOLUTIONS.”</p>
<p>If <em>b² − 4ac</em> is <strong>zero</strong>, display: “There is... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T06:56:50.293",
"Id": "508394",
"Score": "3",
"body": "In case `d < 0` you print two identical values. Copy-paste error?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T03:07:14.450",
"Id": "508471... | [
{
"body": "<p><code>int main(void)</code> is preferable, as that's clear about the number of arguments.</p>\n<p>I don't understand why the coefficients must be integers - surely a quadratic equation can have any real coefficients?</p>\n<p>We don't test whether the <code>scanf()</code> actually converted all thr... | {
"AcceptedAnswerId": "257393",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T06:22:49.260",
"Id": "257386",
"Score": "5",
"Tags": [
"c",
"mathematics"
],
"Title": "Determine the roots of a Quadratic Equation"
} | 257386 |
<p>Here is a basic itoa function that I've written trying to use recursion:</p>
<pre><code>void itoa(int number, char buffer[])
{
static int idx=0, size=0;
if (number == 0) {
buffer[size] = '\0';
idx = size = 0; // reset for next call
}
else {
size++, idx++;
itoa(number/1... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T07:23:28.757",
"Id": "508396",
"Score": "4",
"body": "_How does it look?_ - scary. Besides, if `number` is 0 to begin with, it doesn't give the correct result."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "202... | [
{
"body": "<blockquote>\n<p>How does it look?</p>\n</blockquote>\n<p>Not so good.</p>\n<ol>\n<li><p>Not thread safe.</p>\n</li>\n<li><p>Does not handle negative numbers well.</p>\n</li>\n<li><p>Forms <code>""</code> with 0.</p>\n</li>\n<li><p>Prone to buffer overflow.</p>\n</li>\n<li><p><code>itoa()</... | {
"AcceptedAnswerId": "257422",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T06:39:31.527",
"Id": "257387",
"Score": "0",
"Tags": [
"c"
],
"Title": "Writing an itoa function"
} | 257387 |
<p>I'm currently doing old exams from my course to train for my upcoming exam. What I'm wondering is about a code block which I will specify after I've presented the different files with code.</p>
<h3>//<code>upggift1.cc</code> aka the main</h3>
<pre><code>#include "date.h"
#include <iostream>
using na... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T09:30:05.813",
"Id": "508398",
"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": "<h2><code>upggift1.cc</code></h2>\n<p>Please don't do this:</p>\n<blockquote>\n<pre><code>using namespace std;\n</code></pre>\n</blockquote>\n<p>We have namespaces for good reason, and it's a bad habit to throw away their benefits like that.</p>\n<blockquote>\n<pre><code>Date d1;\nbool create_date_ag... | {
"AcceptedAnswerId": null,
"CommentCount": "7",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T08:29:10.343",
"Id": "257389",
"Score": "3",
"Tags": [
"c++",
"datetime"
],
"Title": "Add 10000 days to a date"
} | 257389 |
<p>In the context of a library to generate random credit card, it would be nice to let the user the possibility to set some optional options on some cards. Lets take Visa. Two lengths are available: 13 or 16 digits.</p>
<p>In C# a common implementation would be:</p>
<pre class="lang-csharp prettyprint-override"><code>e... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T22:31:54.627",
"Id": "508543",
"Score": "0",
"body": "Just for the sake of being pedantic: credit card numbers are not \"random\": usually the first six digits represent the BIN, that is a prefix that is assigned to issuers (of cour... | [
{
"body": "<p>First, I don't think you want an enum there, but I don't have the full context of your actual usage, my examples use a Discriminated Union rather than an enum.</p>\n<p>I'm not sure which is idiomatic but here are 2.5 ways to do it.</p>\n<pre><code>type VisaLengthOptions = \n | Thirteen\n | S... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T09:31:15.723",
"Id": "257391",
"Score": "1",
"Tags": [
".net",
"f#",
"library"
],
"Title": "What would be the idiomatic F# way to write optional parameters?"
} | 257391 |
<p>I have WP Query like this:</p>
<pre><code> $map_args = array(
'post_type' => 'spots',
'post_status' => 'publish',
'posts_per_page' => -1
);
$markers_query = new WP_Query($map_args); ?>
<?php if ($markers_query->have_posts()) : ?>
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T00:18:14.433",
"Id": "508469",
"Score": "4",
"body": "Your title is not appropriate because it describes your concern / the kind of review that you are seeking. Your title should uniquely describe what your script does. The `if` ... | [
{
"body": "<p>If those <code>get_</code> routines are fetching from the WP database, then that may be the problem. It is better to combine queries together in the database rather than going back and forth between db server had your 'client'.</p>\n",
"comments": [
{
"ContentLicense": "CC BY-SA... | {
"AcceptedAnswerId": "259963",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T12:32:09.007",
"Id": "257395",
"Score": "0",
"Tags": [
"php",
"wordpress",
"leaflet"
],
"Title": "Optimizing large WP Query"
} | 257395 |
<p>An attempt to find Mersenne primes using the <a href="https://en.wikipedia.org/wiki/Lucas%E2%80%93Lehmer_primality_test" rel="nofollow noreferrer">Lucas-Lehmer primality test</a>:</p>
<pre><code>n=int(input("Enter n to check if 2^n-1 is a prime:"))
a=4
for i in range(0,n-2):
b=a**2
a=b-2
if i==... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T14:34:22.367",
"Id": "508425",
"Score": "2",
"body": "The solution to the problem with n <= 2 would just be returning `True` for 0 < n <= 2 and `False` for n <= 0?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": ... | [
{
"body": "<p>The page you linked to has pseudocode, and it does <code>s = ((s × s) − 2) mod M</code>. And right below the pseudocode it says:</p>\n<blockquote>\n<p>Performing the mod M at each iteration ensures that all intermediate results are at most p bits (otherwise the number of bits would double each ite... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T13:38:28.980",
"Id": "257397",
"Score": "0",
"Tags": [
"python",
"performance",
"beginner",
"mathematics"
],
"Title": "Finding Mersenne primes"
} | 257397 |
<p>I have been studying front-end development for 2 .5 months, I decided to switch to practice and wrote a todo list in 8 hours</p>
<ol>
<li>Please write your opinion about the code and how it can be improved (preferably in html, css too, but JS is a priority)</li>
<li>I want to start learning React, is it already poss... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T14:58:25.397",
"Id": "257399",
"Score": "2",
"Tags": [
"javascript",
"html",
"css",
"to-do-list"
],
"Title": "Todolist in vanillaJS"
} | 257399 |
<p>In my Motorola 6809 CPU emulator (written in C++14) I'm working on an abstraction to represent the wiring between emulated devices, such as the ports on a 6522 VIA, or the interrupt lines connecting a peripheral to the CPU.</p>
<p>The abstraction uses functional composition. Each <code>OutputPin</code> encapsulates... | [] | [
{
"body": "<h1>Overhead of <code>std::function</code></h1>\n<p>The main problem is that you are using <code>std::function</code>, and this <a href=\"https://stackoverflow.com/questions/5057382/what-is-the-performance-overhead-of-stdfunction\">comes with some overhead</a>. In particular, it will allocate storage... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T15:10:59.167",
"Id": "257400",
"Score": "1",
"Tags": [
"c++",
"performance",
"functional-programming"
],
"Title": "Abstracting device IO / glue logic in a CPU emulator"
} | 257400 |
<p>I've started learning Rust and decided to implement something on my own from scratch. I've implemented a PRNG and I use it to generate random passwords.</p>
<p>Project tree:</p>
<pre><code>| .gitignore
| Cargo.lock
| Cargo.toml
|
+---src
| main.rs
| password.rs
| xorshift.rs
|
</code></pre>
<... | [] | [
{
"body": "<p>Welcome to Rust, and welcome to Code Review!</p>\n<h1><code>rustfmt</code> & <code>clippy</code></h1>\n<p>Always run <code>cargo fmt</code> and <code>cargo clippy</code> first. <a href=\"https://github.com/rust-lang/rustfmt\" rel=\"nofollow noreferrer\"><code>cargo fmt</code></a>\nformats you... | {
"AcceptedAnswerId": "257434",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T17:29:06.820",
"Id": "257404",
"Score": "2",
"Tags": [
"beginner",
"reinventing-the-wheel",
"random",
"rust"
],
"Title": "Pseudo-random number generator & password generat... | 257404 |
<p>This is a simple arithmetic calculator, which parses mathematical expressions specified in infix notation using the <a href="https://en.wikipedia.org/wiki/Shunting-yard_algorithm" rel="nofollow noreferrer">shunting-yard algorithm</a>. This is one of my personal projects and I would love to receive expert advice.</p>... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T11:49:25.523",
"Id": "508650",
"Score": "0",
"body": "Welcome to Stack Review and great first question."
}
] | [
{
"body": "<h1>Keep the stack as simple as possible</h1>\n<p>You have given your stack implementation knowledge of the types that are stored in the stack; either <code>float</code> or <code>char</code>. This complicates the code, since now you have to have two node <code>struct</code>s, and two sets of push and... | {
"AcceptedAnswerId": "258870",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T18:37:56.980",
"Id": "257409",
"Score": "6",
"Tags": [
"algorithm",
"c",
"parsing",
"calculator",
"stack"
],
"Title": "Calculator in C - Parsing arithmetic expression ... | 257409 |
<p>I am using a function that returns a list of all files (full path for each of them) with the given extension in the given folder and all subfolders.
As the process is quite long and user can get feeling that the app freezes, every 5 seconds I write to the output the name of the file the script is working on.
The cod... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T08:00:06.283",
"Id": "508495",
"Score": "0",
"body": "Please share your imports. Is there a reason you're restricted to Python 2.x?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T12:50:26.607",
"... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T18:44:16.633",
"Id": "257411",
"Score": "3",
"Tags": [
"python",
"python-2.x",
"file-system",
"timer"
],
"Title": "Python script that getting list of all files with specific e... | 257411 |
<p>I made a 3D object in OpenGL. But I think my code is extremely bad and now, I want to make my code better.</p>
<p>Here is my code:</p>
<pre><code>#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(0.5, 0.5, 0.5);
glVertex2f(0.0, 0.0);
glVerte... | [] | [
{
"body": "<p>There is not much code to review.</p>\n<ol>\n<li><p>GLUT is deprecated. The original GLUT ceased support more than 20 years ago. FreeGLUT is an open source alternative, but I'm not sure what the status is, since the last release was 18 months ago. Use something modern like GLFW or SDL2.</p>\n</li>... | {
"AcceptedAnswerId": "257425",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T19:10:49.650",
"Id": "257412",
"Score": "1",
"Tags": [
"c",
"opengl"
],
"Title": "3D object in OpenGL"
} | 257412 |
<p>So reading about functional programming, applications to dynamic programming, and learning Scala. I figured I would try it out with a popular example, Pascal's Triangle, tests against known values work out fine. Any tips for optimization? Am I doing anything totally wrong? Is there a way to do this with tail recursi... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T19:49:59.880",
"Id": "508455",
"Score": "1",
"body": "tested with values c=5 and r=109 and the runtime was quite long, so there seems to be an issue with the cache"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": ... | [
{
"body": "<p>Your code is clearly organized and well presented, but it suffers from a number of problems, from the trivial to the profound.</p>\n<ul>\n<li><code>var i = 0</code> is never used and doesn't need to be there.</li>\n<li><strong>safety</strong>: There's no check for bad input. <code>pascal(2,1)</cod... | {
"AcceptedAnswerId": "257431",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T19:33:56.750",
"Id": "257413",
"Score": "3",
"Tags": [
"recursion",
"functional-programming",
"scala",
"dynamic-programming",
"memoization"
],
"Title": "Efficiently ca... | 257413 |
<p>The goal of the code is to display a live camera feed sent by GStreamer over UDP, and to give an indication of when the signal is lost by displaying a static blue screen instead of the last frozen frame. Qt is used to display the image, and to provide a label, and a button for taking snapshots.</p>
<p>I would be int... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T21:25:57.160",
"Id": "257417",
"Score": "1",
"Tags": [
"c++",
"qt"
],
"Title": "Indicating a lost signal when streaming live video with GStreamer and Qt"
} | 257417 |
<p>In the following code I used a <code>while True:</code> loop and implemented <code>break</code>, because I couldn't figure out a cleaner solution than an infinite loop. Is this approach considered bad practice? Here is my code:</p>
<pre><code>while True:
z = int(input("Y: "))
if (z >= 0 and z &... | [] | [
{
"body": "<blockquote>\n<p>I couldn't figure out a cleaner solution than an infinite loop. Is this approach considered bad practice?</p>\n</blockquote>\n<p>You can't do much better, since Python doesn't have the equivalent of a C-style <code>do/while</code>.</p>\n<p>This is a trivial program so I doubt it's ev... | {
"AcceptedAnswerId": "257426",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T22:24:30.930",
"Id": "257420",
"Score": "3",
"Tags": [
"python",
"python-3.x",
"ascii-art"
],
"Title": "Printing dynamic ascii-art shapes based on user input"
} | 257420 |
<p>I'm looking for a more elegant (eg., with less many functions, eg., "copy into contiguous array then reinterpret") or more efficient way (with less complexity) to transcode a <code>IEnumerable<uint></code> (~ array of 32bits int), which is a compact way to represent a <code>byte[4]</code> array, into... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T08:50:18.653",
"Id": "508502",
"Score": "0",
"body": "what do you mean by `more elegant or more efficient` performance ? memory ? ..etc. you have to be specific."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2... | [
{
"body": "<p>Well, I could propose few improvements for you:</p>\n<ol>\n<li>Try to use SelectMany instead of just Select;</li>\n<li>No need to call ToArray since the string.Concat could consume IEnumerable;</li>\n</ol>\n<pre><code>public static string UintArrayToString(this IEnumerable<uint> x) =>\n ... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-19T23:06:09.257",
"Id": "257421",
"Score": "2",
"Tags": [
"c#"
],
"Title": "decode `IEnumerable<uint>` to string made of 1 byte characters (eg., ASCII)"
} | 257421 |
<p>I wrote an <a href="https://codereview.stackexchange.com/questions/257387/writing-an-itoa-function">itoa function yesterday</a>, which based on feedback I am now working on improving. How does the below look? Are there any ways in which I can improve it?</p>
<pre><code>#include <stdio.h>
#include <string.h&... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T08:09:49.193",
"Id": "508496",
"Score": "0",
"body": "To answer your first question (which is not a CR Answer, since it's not reviewing the code): yes, C demands a lot of care with edge cases. It's lower-level than many modern lang... | [
{
"body": "<p><strong>Incorrect size check</strong></p>\n<p><code>itoa(num, 2, buffer);</code> forms <code>"17"</code>, which needs 3 <code>char</code>, even though only 2 provided.</p>\n<p>Perhaps OP meant 2 to be the string <em>length</em> allowed and not the string <em>size</em> needed. In which c... | {
"AcceptedAnswerId": "257430",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T04:50:49.000",
"Id": "257428",
"Score": "2",
"Tags": [
"c",
"reinventing-the-wheel"
],
"Title": "Improving an itoa function"
} | 257428 |
<p>This is my working code for a HTML auto dealer template which does the job, but esthetically, isn't quite that pleasing and is very functional
(use Expand snippet on all of these to see the design properly):</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div cl... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T13:16:04.480",
"Id": "257437",
"Score": "1",
"Tags": [
"html",
"css"
],
"Title": "Getting images to align side-by-side and making DIV with image not move with text?"
} | 257437 |
<p>I am runing this function that finds an object in an array and toggles the boolean <code>lead</code> property.</p>
<p>I am actually doing this in react so in there I do change the data via state and in the end if I run it again it would toggle <code>Gary</code> true/false, so it works fine.</p>
<p>My question is reg... | [] | [
{
"body": "<p>This could be accomplished via an XOR, or boolean not equal in other words.</p>\n<p><div class=\"snippet\" data-lang=\"js\" data-hide=\"false\" data-console=\"true\" data-babel=\"false\">\r\n<div class=\"snippet-code\">\r\n<pre class=\"snippet-code-js lang-js prettyprint-override\"><code>const pe... | {
"AcceptedAnswerId": "257439",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T13:28:45.513",
"Id": "257438",
"Score": "0",
"Tags": [
"javascript"
],
"Title": "Best way to toggle a property in an array"
} | 257438 |
<p>This code checks the type, length and depth (highest number of nested containers) of the container as well as the type of its sub-containers and its elements. There are also two simple methods for type checking non-nested list / tuples. I mainly want a code review on readability and the quality of the docstrings.</p... | [] | [
{
"body": "<p>Assuming that you decide to retain <code>_check_parameters()</code>, here's an\nillustration of some alternative techniques for organizing a complex boolean\ncheck. (1) The <code>isinstance()</code> function will take a tuple of types, so you can\ndo some consolidation. (2) If you need to check fo... | {
"AcceptedAnswerId": "257448",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T15:19:44.813",
"Id": "257444",
"Score": "2",
"Tags": [
"python",
"python-3.x",
"recursion",
"validation"
],
"Title": "Recursive type checking for containers"
} | 257444 |
<p>This is a follow up of <a href="https://codereview.stackexchange.com/questions/257197/skyscraper-solver-for-nxn-size-version-2-using-backtracking">Skyscraper Solver for NxN Size Version 2 (Using Backtracking)</a></p>
<p>I followed the advice in the last Codereview and did the following optimizations:</p>
<ul>
<li><p... | [] | [
{
"body": "<p>My overall impression of this code is that you are trying too hard to add abstractions to the code, but are not paying attention to performance. Of course, the trick is to find the right balance between the two. It might be an interesting excercise to write a solution to the problem in C, where it... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T18:51:55.943",
"Id": "257451",
"Score": "1",
"Tags": [
"c++",
"performance",
"c++17"
],
"Title": "Skyscraper Solver for NxN Size Version 3 (Using Bitmasks)"
} | 257451 |
<p>I have a file called paths.php which is the first file that loads on every page request. I read that I should make a constant of the root folder path but not for every file, but the main point why I did constants for commonly used paths: when the path changes I don't need to go around different files changing requir... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T22:08:57.610",
"Id": "508540",
"Score": "0",
"body": "Start using a template engine like Twig"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T22:22:23.463",
"Id": "508542",
"Score": "0",
"... | [
{
"body": "<p>If this is the first thing that loads on every page, then the chance of any of these constants being already defined is very small. Why then define them conditionally? These are <strong>constants</strong>, they should always have the same value. Therefore you can change:</p>\n<pre><code>defined(&q... | {
"AcceptedAnswerId": "257464",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T19:37:15.157",
"Id": "257453",
"Score": "1",
"Tags": [
"php",
"constants"
],
"Title": "List of path constants"
} | 257453 |
<p>I wrote a simple function for retrying the passed function in case it throws.
I did it for my app that needs to call an external API through the network, which may spuriously fail.</p>
<pre><code>export async function retry(fn, retries, delayMs, onFailedAttempt = null) {
let lastError = null;
for (let attem... | [] | [
{
"body": "<p>Your code looks good and will work well. I have made some minor improvements to improve readability and reduce redundancy.</p>\n<pre><code>export async function retry(fn, retries, delayMs, onFailedAttempt) {\n let attempt = 0;\n\n while (true) {\n try {\n return await fn();\n } catch ... | {
"AcceptedAnswerId": "257573",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T22:28:35.640",
"Id": "257457",
"Score": "3",
"Tags": [
"javascript",
"async-await"
],
"Title": "Simple retrier of async function"
} | 257457 |
<p>I know this piece of code is quite strange, but it does its job very well performance-wise , reducing the running time of a very computation intensive operation by 3 - 5 times without using a better algorithm. But since the code using the controversal keyword <code>register</code> and I use pointer arithmetic quite ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T01:19:27.423",
"Id": "508545",
"Score": "3",
"body": "The `register` keyword doesn't do anything in C++, and in fact has been removed from C++17. See what happens when you remove all the `register` keywords: https://godbolt.org/z/zP... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "11",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-20T23:38:01.317",
"Id": "257459",
"Score": "0",
"Tags": [
"c++",
"performance",
"c++11",
"matrix"
],
"Title": "Optimizing matrix vector multiplication with keyword \"register\" ... | 257459 |
<p>I am using RandomForestRegressor to predict a set of soccer matches to predict the number of goals scored for a given match/set of matches is as below:</p>
<pre><code> dte.head()
HomeTeam
AwayTeam B365H B365D B365A FTHG FTAG
-- -------------- ---------- ------- ------- ------... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-07-16T20:53:43.593",
"Id": "521652",
"Score": "0",
"body": "Can I see the full code? Some of the dataframes are not defined..."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-07-17T02:08:39.570",
"Id": "52166... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T03:35:07.990",
"Id": "257462",
"Score": "0",
"Tags": [
"python",
"performance"
],
"Title": "My implementation of RandomForestRegressor application to predict soccer goals"
} | 257462 |
<p>I have written a ArrayList class in C and I just wanted some criticism on what I can improve on. Any criticism helps, and I was wondering if there is any better way of doing error handling other than returning a enum.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#includ... | [] | [
{
"body": "<h1>How I Review Code</h1>\n<p>I have performed Code Reviews for over 30 years both on the Code Review Community and professionally. I have also had to maintain code written by others and this generally requires a thorough code inspection before starting.</p>\n<p>The criteria I use for code reviews i... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T05:37:29.067",
"Id": "257463",
"Score": "1",
"Tags": [
"c",
"error-handling",
"memory-management",
"vectors"
],
"Title": "C ArrayList implementation"
} | 257463 |
<p>I am new to python and I had the task to find the US zip code based on latitude and longitude. After messing with arcgis I realized that this was giving me empty values for certain locations. I ended up coding something that accomplishes my task by taking a dataset containing all US codes and using Euclidean distanc... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T07:27:06.180",
"Id": "508550",
"Score": "3",
"body": "Welcome to Code Review. It would be helpful to provide an example of input files and the expected result. Is `resultZip` the result? Why is it not saved/printed? Please include t... | [
{
"body": "<p>So a better approach may be to :</p>\n<ol>\n<li>covert your myFile to a Numpy array <code>[[lat0, long0], [lat1, long10], ...]</code>.</li>\n</ol>\n<pre><code>lat_long = np.asarray(myFile)\n</code></pre>\n<ol start=\"2\">\n<li>Sort this array on <code>latitude</code></li>\n</ol>\n<pre><code>lat_lo... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T07:07:09.493",
"Id": "257465",
"Score": "1",
"Tags": [
"python",
"performance"
],
"Title": "Can I optimize two for loops that look for the closest zip code based on lat/lon?"
} | 257465 |
<h1>del-files</h1>
<p>Delete files and directories from the command line. <a href="https://github.com/sarthakgaur/del-files" rel="nofollow noreferrer">https://github.com/sarthakgaur/del-files</a></p>
<h2>Installation</h2>
<ol>
<li><code>git clone https://github.com/sarthakgaur/del-files</code></li>
<li><code>node main.... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T07:49:18.257",
"Id": "257466",
"Score": "0",
"Tags": [
"javascript",
"node.js"
],
"Title": "Command Line Utility to Delete Files/Directories"
} | 257466 |
<p>So I have encountered a problem with asking user for input to be exact what is the best way to ask yes/no, for example accepting y / n and why is <code>if i == no or i == c_n:</code> not working? What are other mistakes or bad practices that I'm doing here?</p>
<pre><code>i = input('yes/no: ')
success = "Succe... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T16:34:58.830",
"Id": "508574",
"Score": "2",
"body": "Does this exist as part of a larger program? If so, please show the full source."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T21:45:17.403",
... | [
{
"body": "<p>Your updated code looks way cleaner already. Your membership tests <code>answer in yesAnswers</code> / <code>answer in noAnswers</code> are obviously not performance critical here. But in general (especially on large datasets) it's preferrable to use sets for membership tests since they can provid... | {
"AcceptedAnswerId": "257530",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T09:56:04.917",
"Id": "257469",
"Score": "6",
"Tags": [
"python",
"python-3.x"
],
"Title": "Asking for a yes/no user input"
} | 257469 |
<p>I would like to see if my code below can still be optimized, resulting in lesser lines of code. My code retrieves the values from a multiselect field and assign them to hidden fields that will be passed to an integrated googlesheet. Thanks</p>
<pre><code> jQuery(".ff-btn-submit").click(function() {
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T07:27:14.760",
"Id": "508630",
"Score": "0",
"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>I have few hints save jQuery in $ variable:</p>\n<pre class=\"lang-javascript prettyprint-override\"><code>(function($) {\n // your code\n})(jQuery);\n</code></pre>\n<p>$ is common for jQuery and it's easier to read because it shorter.</p>\n<p>Second and obvious is using loop to run calls in:</p... | {
"AcceptedAnswerId": "257483",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T11:29:31.020",
"Id": "257471",
"Score": "0",
"Tags": [
"jquery"
],
"Title": "How can I have jQuery code further optimized?"
} | 257471 |
<p>Just created my first C++ project, and wondering if I could get some feedback on where to improve? I might swap from arrays to vectors and add alpha beta pruning later, but wanted to first see where I can improve on the base code.</p>
<pre><code>#include <iostream>
#include <cmath>
const char PLAYER_ONE... | [] | [
{
"body": "<p>This is not at all a bad effort for someone new to the C++ language. Here are some things that may help you improve your program.</p>\n<h2>Use the required <code>#include</code>s</h2>\n<p>The code uses <code>std::fill</code> which means that it should <code>#include <algorithm></code>. It ... | {
"AcceptedAnswerId": "257522",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T13:21:12.777",
"Id": "257473",
"Score": "3",
"Tags": [
"c++",
"beginner"
],
"Title": "Basic TicTacToe implementation in C++"
} | 257473 |
<p>I am working on a Flask application (side-project) to send text-messages to customers using Twilio. There is two different list of customers, 1 for <code>testing</code> and for <code>production</code> (stored in MongoDB). Current functionalities:</p>
<ul>
<li>user login/ logout</li>
<li>Add, remove or search a user... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T14:02:20.933",
"Id": "257474",
"Score": "0",
"Tags": [
"python",
"object-oriented",
"design-patterns",
"flask"
],
"Title": "Flask blueprints and context_processor - Best appro... | 257474 |
<p>I have made a <em>password verification</em> "program" which takes user input and checks whether the password is valid or not. Based on that, a reply is printed.</p>
<pre><code>print("Create a password! Your password must have 8 to 12 digits. Numbers and lower as well as upper case letters must be a p... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-23T18:28:27.183",
"Id": "508771",
"Score": "8",
"body": "Don't worry, I was not planing on using this for anything. It was just a small project so that I have something specific to look into. Otherwise getting into programming seems pr... | [
{
"body": "<p>Two general points about your code:</p>\n<ol>\n<li><p><strong>Variable naming:</strong> <code>res, res2, res3</code> are not descriptive, so it's harder to understand at first glance what their purpose is. Instead\nI would recommend something similiar to <code>contains_digit, contains_lower_char, ... | {
"AcceptedAnswerId": "257478",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T16:23:39.930",
"Id": "257476",
"Score": "20",
"Tags": [
"python",
"beginner",
"python-3.x",
"strings"
],
"Title": "Password validator"
} | 257476 |
<p>I am working on a <strong>online newspaper/blogging application</strong> with <strong>CodeIgniter 3.1.8</strong> and <strong>Twig</strong>.</p>
<p>The application is meant to offer developers and designers the possibility to very easily turn their HTML templates into database-powered websites. To achieve this, I use... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T07:51:52.767",
"Id": "508636",
"Score": "0",
"body": "...I don't wish to repeat myself. You should not be accessing any superglobals in your model -- but I've said this already. By not implementing the insights that I've provided ... | [
{
"body": "<p>those are my considerations:</p>\n<ul>\n<li>Do not use Globals like $_POST, $_GET directly. Use that provided by CI, are already XSS cleaned and analyzed</li>\n<li>Always validate IDs, check that is an integer at least because, in theory, I can write an SQL there instead of an ID</li>\n<li>Do not ... | {
"AcceptedAnswerId": "257567",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T16:52:25.197",
"Id": "257477",
"Score": "2",
"Tags": [
"php",
"mysql",
"codeigniter"
],
"Title": "Newsletter subscribers management system in CodeIgniter 3"
} | 257477 |
<p>I have been trying to refactor my code since I found I've been doing a lot of copying and pasting to implement the logic of the web API controllers. Here's how the controllers looked like before refactoring</p>
<p>Controller for <code>EducationalGroups</code> table:</p>
<pre><code>public class EducationalGroupsContr... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T08:10:39.487",
"Id": "508640",
"Score": "0",
"body": "Do I understand correctly that the refactored version is not complete?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-25T11:24:33.177",
"Id": "5... | [
{
"body": "<p>Honestly, don't try to invent new ways of doing things and instead learn well-documented ways of doing things, like <a href=\"https://github.com/jbogard/MediatR\" rel=\"nofollow noreferrer\">MediatR</a> and <a href=\"https://www.c-sharpcorner.com/article/using-mediator-in-web-apis-for-cqrs-pattern... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T17:27:06.177",
"Id": "257479",
"Score": "0",
"Tags": [
"c#",
"mvc",
"generics",
"entity-framework",
"asp.net-web-api"
],
"Title": "Making a generic web API controller when... | 257479 |
<p>This is my first program in C. Do you have any improvements to this program? The program allows you to guess a number and also returns the attempts.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
/*
* Sophie
* 21.03.2021
*/
void main() {
int... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T14:25:56.010",
"Id": "508671",
"Score": "0",
"body": "This is a great program to learn with! The first program I ever wrote — in BASIC on a borrowed [Video Genie](https://en.wikipedia.org/wiki/Video_Genie), no less — was a guessing... | [
{
"body": "<p>It looks good for a first program in C, good job.</p>\n<p>An improvement would be to ask the user to insert a number which will be the maximum number to guess (instead of the default 100 value).</p>\n<p>You also could change the <code>try</code> variable name to <code>tries</code>.</p>\n",
"co... | {
"AcceptedAnswerId": "257489",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T18:18:06.427",
"Id": "257481",
"Score": "12",
"Tags": [
"beginner",
"c",
"number-guessing-game"
],
"Title": "\"Guess the Number\" in C"
} | 257481 |
<p>I have made a sorting algorithm in Python 3. This sorting algorithm is a modified optimized <em>median of 3 quicksort</em>, with <em>network sorting</em> for lists of size up to 16 and for finding the median. I have tried using the O(N) approach to finding the median, but sorting normally was faster.<br />
Can I get... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T22:21:35.740",
"Id": "508596",
"Score": "0",
"body": "Python is not a good choice for benchmarking algorithms, since it is an interpretive language and slow. I would recommend C or C++ compiled with an optimizing compiler."
},
{... | [
{
"body": "<p>(This begins with opinions about the way the <em>partition&network sort</em> presented by <a href=\"https://codereview.stackexchange.com/users/239448/sola-sky\">Sola Sky</a> is coded.<br />\nI intend to get to comments on resource requirements - don't hold your breath.)</p>\n<p>In your questio... | {
"AcceptedAnswerId": "257523",
"CommentCount": "12",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T20:05:50.977",
"Id": "257486",
"Score": "5",
"Tags": [
"python",
"algorithm",
"python-3.x",
"sorting",
"quick-sort"
],
"Title": "Quicksort Algorithm Speed"
} | 257486 |
<p>I'm quite new to C, and I decided to create a generic vector library. Here is the code:</p>
<pre><code>#ifndef VECTOR_H
#define VECTOR_H
#define DEFAULT_CAPACITY 10
#define EXPAND_RATIO 1.5
#include <stdlib.h>
#include <string.h>
enum error {
NO_ERROR,
INDEX_ERROR,
KEY_ERROR,
NULL_POIN... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T20:28:46.550",
"Id": "508587",
"Score": "0",
"body": "Is `VECTOR_NEQ` a typo?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T21:52:33.703",
"Id": "508590",
"Score": "0",
"body": "map is p... | [
{
"body": "<h2>Naming</h2>\n<p>Very good comments and documentation. I had a clear picture of what you were trying to accomplish.</p>\n<p>Instead of giving your users the ability to create any <code>##vec_name</code>, I would consider, <em>eg</em> <code>vec_##name</code>, to give my vector types a naming consis... | {
"AcceptedAnswerId": null,
"CommentCount": "13",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T20:14:41.023",
"Id": "257487",
"Score": "2",
"Tags": [
"performance",
"c",
"generics",
"vectors",
"macros"
],
"Title": "C - Generic vector library"
} | 257487 |
<p>I have begun coding a simple graph plotter for my schoolchildren using JavaScript. I have used the paper.js library as I would like to be able to export the graphs as svg files.</p>
<p>I am only a beginner to all this (just a humble maths teacher) so I would hugely welcome any thoughts you may have. The code does no... | [] | [
{
"body": "<p>I'm not familiar with Paper so can't say anything about that. And I won't say much about the HTML, as it's obviously just a functional placeholder, except two points:</p>\n<ul>\n<li>Use double quotes <code>"</code> consistently on all attributes.</li>\n<li>Don't use <code>on...</code> attribu... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T21:55:26.723",
"Id": "257490",
"Score": "0",
"Tags": [
"javascript",
"paper.js"
],
"Title": "A JavaScript graph plotter for schoolchildren using paper.js"
} | 257490 |
<p>I solved this problem: given an array/vector of numbers, return how many of them contain an even number of digits.</p>
<p>Constraints:</p>
<pre><code>1 <= nums.length <= 500
1 <= nums[i] <= 10^5
</code></pre>
<p>Please review the code:</p>
<pre><code>impl Solution {
pub fn find_numbers(nums: Vec<i... | [] | [
{
"body": "<p>A couple of points. Firstly about the code you have listed.</p>\n<ul>\n<li><p>Are the constraints problems to be enforced or assumptions you can make while writing your solution? It's odd to artificially limit it.</p>\n</li>\n<li><p><code>len</code> does not need to be defined outside the loop. It... | {
"AcceptedAnswerId": "257582",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T21:59:28.163",
"Id": "257491",
"Score": "1",
"Tags": [
"algorithm",
"programming-challenge",
"rust"
],
"Title": "Counting numbers that have an even number of digits"
} | 257491 |
<p>Minimal vector-like dynamic arrays, <code>min_array.h</code>. This is not new at all, but since I use a lot of functions similar to this in larger projects, I was hoping for comments about the documentation, especially the names, and interface.</p>
<pre><code>/** Macro for a type-specific minimal dynamic array: `MIN... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-21T23:13:07.010",
"Id": "257492",
"Score": "0",
"Tags": [
"c",
"file",
"vectors",
"c89"
],
"Title": "Extracting integers from arbitrary text and storing them in a dynamic array"
... | 257492 |
<p>Here is the RPS game I made. I watched a 4 hour tutorial about C++ from freecodeacademy and produced this game right after it. If you have any feedback or suggestions please let me know. Or if there's anything I should be aware of or shouldn't be doing that would be great.</p>
<pre><code>#include <iostream>
#i... | [] | [
{
"body": "<h3>Use C++ standard library headers</h3>\n<p>Don't use C headers such as <code><stdlib.h></code>, use the equivalent C++ headers like <code><cstdlib></code>. You should be using the C++ library functions anyway.</p>\n<h3>Don't rely on transitive includes</h3>\n<p>It happens that <code>&l... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T00:56:59.693",
"Id": "257494",
"Score": "1",
"Tags": [
"c++",
"beginner"
],
"Title": "Single player Rock Paper Scissors game"
} | 257494 |
<p>Before I go on with how I tried to do this, some background.</p>
<p>WCAG provides a method that computes luminance as part of the <a href="https://www.w3.org/TR/WCAG20-TECHS/G17.html" rel="nofollow noreferrer">contrast ratio computation</a>.</p>
<p>What I am trying to do is given a color in RGB space convert it to H... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T05:11:01.300",
"Id": "257504",
"Score": "0",
"Tags": [
"performance",
"typescript",
"color"
],
"Title": "How do I avoid doing a search to compute a \"normalized color\"?"
} | 257504 |
<p>I write this program that checks if a file is executable, and if so, to check if it is an ELF binary or a shell script.</p>
<pre><code>#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <string.h>
int Search_in_File(char *fname, char *str);
in... | [] | [
{
"body": "<blockquote>\n<pre><code>if(argc < 2){\n printf("The path to the file is\\n");\n return 1;\n}\n</code></pre>\n</blockquote>\n<p>The error message is unfinished (appropriately enough, <code>missing</code> is missing), and it should go to <code>stderr</code>, not <code>stdout</code>.... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T08:28:56.623",
"Id": "257509",
"Score": "1",
"Tags": [
"c",
"file"
],
"Title": "Check type of executable file"
} | 257509 |
<p>I have a cycle which goes from -55 to -1, then from 1 to 55 before going back to -55 again. I want to make a loop going from an arbitrary point in this loop to another arbitrary point, but never as far as a full cycle.</p>
<p>Since the end value of the counter might be either a larger or smaller than the start value... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-26T00:38:09.003",
"Id": "509021",
"Score": "0",
"body": "Will the initial value of `fra` ever be positive?"
}
] | [
{
"body": "<p>Maybe this looks better to you. Encapsulating a loop's contained logic in dedicated single-purpose procedures generally makes a loop easier to read and understand(IMO). In this case, the loop conditions requiring the repeated code to run 'one last time' becomes a little more clear as well.</p>\n... | {
"AcceptedAnswerId": "257518",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T08:56:36.037",
"Id": "257510",
"Score": "1",
"Tags": [
"vba",
"iteration"
],
"Title": "Is there some way to simplify this loop"
} | 257510 |
<p>I have these two classes and they should remain separate classes, but I have a feeling that this could be implemented more efficiently and with less duplicate code. After googling around I still didn't figure a better way, so perhaps someone here could point me out. Ideally I want to get tick() method from Clock and... | [] | [
{
"body": "<p>I have refactored some of your code, please note that I am ignoring pre-existing libraries since I assume there's a particular reason (educational or otherwise) behind implementing <code>Clock</code>, <code>tick</code>, etc. this way on your own.</p>\n<p><strong>class Clock:</strong></p>\n<pre><co... | {
"AcceptedAnswerId": "257535",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T09:13:16.460",
"Id": "257511",
"Score": "3",
"Tags": [
"python",
"object-oriented",
"inheritance"
],
"Title": "Alarm clock subclass of a clock"
} | 257511 |
<p>This is a question, I'm just not quite sure about:
Every Android development tutorial you find, will put all of the code simply into the <code>MainActivity</code> class (or some other class, that inherits from an <code>Activity</code> class).</p>
<p>But what if you want to put code into your own classes? How do you ... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T09:14:35.750",
"Id": "257512",
"Score": "0",
"Tags": [
"android"
],
"Title": "How does one handle activity stuff in custom classes in Android?"
} | 257512 |
<p>I am using angular and rxjs, and I am doing the following :</p>
<p>I would like to upload an image to GCP, so I need to generate a signed url, upload the image,and while showing status of all the request.</p>
<p>Component => ask a Service A to upload a file.</p>
<pre><code> this.uploadProgress$ = this.uploadHel... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T10:00:29.583",
"Id": "257514",
"Score": "0",
"Tags": [
"typescript",
"angular-2+",
"rxjs"
],
"Title": "Simplifiy the following flow for upload file status tracking"
} | 257514 |
<p>I'd like to show you a type I made while experimenting with literal, non-type template parameters in C++20.</p>
<p>The idea is to provide a type that wraps up tuple-like types (std::tuple, std::pair, even std::variant) and provides access to its fields using a string literal. Also, it has to respect the constexpr-ne... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T12:15:26.843",
"Id": "508653",
"Score": "1",
"body": "`constexpr StringLiteral(const char (&str)[N]) {` is only taking a non-const ref - limiting it's useful-ness - try `constexpr StringLiteral(const char (& const str)[N]) {` wh... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T10:30:52.920",
"Id": "257516",
"Score": "1",
"Tags": [
"c++",
"template-meta-programming",
"c++20"
],
"Title": "\"tuple with named fields\" implementation"
} | 257516 |
<p>I have a requirement to format all my string to the format ##.###/##.### Example: If input value is 3/4 then i need to format it to 03.000/04.000 If my input value is 1.4/2.0 then i need to format it to 01.400/02.000 I have tried the below, which is giving the expected output. Can someone suggest is there any direct... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T12:29:27.250",
"Id": "508656",
"Score": "1",
"body": "Welcome to CodeReview. What is the scope of your question? The program or the string formatting pattern?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021... | [
{
"body": "<p>One way of being more concise is to split the string by <code>'/'</code> and <code>'.'</code>and rebuild the 2 strings with padding. This eliminates 2 conversions and gives the required format:</p>\n<pre><code>static void Main(string[] args) \n{ \n \n var input = "23.3/4.0";\n ... | {
"AcceptedAnswerId": "257543",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T12:09:16.933",
"Id": "257520",
"Score": "-1",
"Tags": [
"c#"
],
"Title": "Format String to particular format ##.###/##.###"
} | 257520 |
<p>I saw quite a few posts about making a dynamic array so I tried making my own for learning purposes.</p>
<p>Here it is:</p>
<pre><code>#ifndef VECTOR_H
#define VECTOR_H
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#ifndef VECTOR_RESERVE_SIZE
#define VECTOR_RESERVE_SIZE 4
#endif
... | [] | [
{
"body": "<p>In C, as in C++, object pointers can be freely converted to <code>void*</code>, so quite a few casts can be removed.</p>\n<p>It's probably convenient to store <code>data</code> as a <code>char*</code>, since that's how we use it. We should still use <code>void*</code> as external interface, of co... | {
"AcceptedAnswerId": "257594",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T14:06:35.153",
"Id": "257526",
"Score": "6",
"Tags": [
"beginner",
"c",
"array",
"cache"
],
"Title": "Another dynamic array implementation in C"
} | 257526 |
<p>I'm working on Rcpp and I wrote the following code</p>
<pre><code>#include <RcppArmadilloExtensions/sample.h>
using namespace Rcpp;
// [[Rcpp::export]]
arma::mat SIZA(int K){
arma::mat P;
P.ones(K,K);
P = trimatu(P);
for(int idx=1; idx<K; ++idx){
arma::mat W;
arma::mat Hlp;
W.ones(K... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T16:16:19.753",
"Id": "508685",
"Score": "0",
"body": "Please [edit] your question's title to reflect what the code actually does instead of using a generic title."
}
] | [
{
"body": "<p>First of all I would try to avoid all the matrix operations like trimming, joining, etc.</p>\n<p>And instead just find a function that tells what value is on each position</p>\n<pre><code>bool tell(int x, int y, int K);\n</code></pre>\n<p>This would of course require more mathematical skill then p... | {
"AcceptedAnswerId": "257532",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T15:00:41.187",
"Id": "257529",
"Score": "0",
"Tags": [
"c++",
"r",
"rcpp"
],
"Title": "Algorithm that creates in a systematic form, matrix with zero-one elements"
} | 257529 |
<p>I'm a long standing PHP, JS, C#(Unity) dev looking to get outside objects and lower down. I've written a quick program to read binary data from a .sav file, and output the data section into CSV's in either long or flat format, with optional leading row indexes.</p>
<p>Wanted to learn more about C so I can start to p... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T19:37:06.317",
"Id": "508696",
"Score": "0",
"body": "Thanks @Sam Onela"
}
] | [
{
"body": "<p>compile with warnings enabled. Then fix those warnings.</p>\n<pre><code>gcc -c -Wall -Wextra -Wconversion -pedantic -std=gnu90\n</code></pre>\n<p>several header files are being included but their contents are not being used. This is a very bad programming practice.</p>\n<p>The makefile needs a ... | {
"AcceptedAnswerId": "257558",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T16:54:48.267",
"Id": "257534",
"Score": "1",
"Tags": [
"beginner",
"c",
"csv",
"converting"
],
"Title": "convert .sav SPSS files into long or flat format CSVs"
} | 257534 |
<p>I want to create a state machine for menu in my SDL game. So this is my code without the SDL. I just want to ask if this is a good way to create it. I am trying to implement a screen and then mouse events, but I have a problem there so this is a reason why I ask if this is okay. Here is a code:</p>
<pre><code>#inclu... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T19:21:40.147",
"Id": "508695",
"Score": "3",
"body": "Is that really how your code is formatted?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T21:17:37.047",
"Id": "508704",
"Score": "0",
... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T17:23:10.257",
"Id": "257536",
"Score": "1",
"Tags": [
"c",
"state-machine",
"sdl2"
],
"Title": "State machine in C for SDL game"
} | 257536 |
<p>I find that a common pattern when outputting a message is the need to pluralize a word. For example, if I need to output a count of files found I would need to write something like</p>
<pre><code>std::cout << "Found " << count << " " << (count == 1 ? "file" : &qu... | [] | [
{
"body": "<p>To be honest, I don't understand why we need the root replacement stuff at all. Couldn't we just pass the full singular and plural words to the function? ... Which would simply become:</p>\n<pre><code>template<class N>\nstd::string pluralize(N n, std::string const& singular, std::string ... | {
"AcceptedAnswerId": "257541",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T17:40:18.847",
"Id": "257537",
"Score": "3",
"Tags": [
"c++",
"strings"
],
"Title": "Pluralize a string"
} | 257537 |
<ul>
<li>Write a program to read strings from standard input looking for duplicated words.</li>
<li>The program should find places in the input where one word is followed immediately by itself.</li>
<li>Keep track of the largest number of times a single repetition occurs and which word is repeated.</li>
<li>Print the m... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T22:13:25.497",
"Id": "508710",
"Score": "1",
"body": "Sure you need to keep track of all words and their counts until there are only \"M\" words left (where M < the distinct words) at that point you can throw away the counts for the... | [
{
"body": "<p>Nothing awful here.</p>\n<p>If this was production code then putting things in named functions would be nice to help with self documenting code.</p>\n<hr />\n<p>Don't particularly like this.</p>\n<pre><code> using std::cin; using std::cout; using std::endl;\n using std::string;\n</code></pre... | {
"AcceptedAnswerId": "257580",
"CommentCount": "6",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T17:54:04.100",
"Id": "257538",
"Score": "1",
"Tags": [
"c++",
"beginner",
"strings"
],
"Title": "Read strings from a standard input, and find the most duplicated word"
} | 257538 |
<p>I was working on <a href="https://leetcode.com/problems/3sum/" rel="nofollow noreferrer">3sum problem on leetcode</a></p>
<h2>Question</h2>
<p>Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.</p>
<p>Note:... | [] | [
{
"body": "<h2>Performance</h2>\n<p>This is a performance only review and does not address any styling or composition.</p>\n<p>Code examples are focused on performance with no attention given to readability, naming, or re-usability</p>\n<h3>Time complexity != performance</h3>\n<p>Time complexity is not a measur... | {
"AcceptedAnswerId": "257574",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T18:38:34.057",
"Id": "257539",
"Score": "2",
"Tags": [
"javascript",
"performance",
"algorithm",
"programming-challenge",
"time-limit-exceeded"
],
"Title": "Leetcode 3... | 257539 |
<p><strong>Update</strong>:</p>
<ul>
<li>Fixed last item is not removed during iteration</li>
<li>Fixed <code>clear()</code> during iteration does nothing</li>
<li>Fixed addition of removed item is ignored</li>
</ul>
<p>The lasted code can be found <a href="https://github.com/gazman-sdk/signals/blob/master/library/src/... | [] | [
{
"body": "<p>I haven't done much Kotlin, however something looked wrong and I was curious, so I wrote some tests. I had a couple of failures, so you may have issues, or it may be that I'm expecting the wrong behaviour. There's three scenarios to consider. I've defined a list of string to make it easy to tes... | {
"AcceptedAnswerId": "257596",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T19:28:28.647",
"Id": "257540",
"Score": "2",
"Tags": [
"algorithm",
"linked-list",
"hash-map",
"kotlin"
],
"Title": "Linked list that support modifications during iteratio... | 257540 |
<p>I made a randomized algorithm to solve the three sum problem. There are two key parameters: number of solutions, and total. Notably, the algorithm might generate a duplicate solution. This is not checked since there is no guarantee that there is N unique solutions. The code is below.</p>
<pre><code>
import random
... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T20:01:16.173",
"Id": "257542",
"Score": "0",
"Tags": [
"algorithm",
"python-3.x"
],
"Title": "Three Sum Algorithm"
} | 257542 |
<p>This is a lightweight text based version of the popular game <a href="https://en.wikipedia.org/wiki/Snake_(video_game_genre)" rel="nofollow noreferrer">Snake</a> written entirely in C. In order to build it, <a href="https://www.gnu.org/software/ncurses/ncurses.html" rel="nofollow noreferrer">ncurses</a> needs to be ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T15:38:13.443",
"Id": "510759",
"Score": "0",
"body": "I have rolled back Rev 4 → 3. Please see [_What to do when someone answers_](https://codereview.stackexchange.com/help/someone-answers)."
}
] | [
{
"body": "<p>Overall this is quite nice code, it is split nicely into functions that each have their own responsibility. Some minor improvements are possible:</p>\n<h1>Avoid global variables</h1>\n<p>While there are no problems with the global variables in this program, the use of global variables is problemat... | {
"AcceptedAnswerId": "259005",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T20:35:06.207",
"Id": "257544",
"Score": "2",
"Tags": [
"c",
"game",
"linked-list",
"snake-game"
],
"Title": "Ncurses Snake Game using a Linked List in C"
} | 257544 |
<p>Last week I posted <a href="https://codereview.stackexchange.com/q/257190/120114">a previous version of this code</a>. I improved the program and worked on it for a few days and I would love to get reviews, feedback and tips so I could learn more and more from you guys.<br />
So here is the program:</p>
<h3>config_m... | [] | [
{
"body": "<h1>Missing <code>const</code></h1>\n<p>I see you are using <code>const</code> in a lot of places, but you have missed a few:</p>\n<ul>\n<li><code>check_unit_existence()</code>: both arguments can be made <code>const char *</code></li>\n<li><code>read_reg_syntax()</code>: the first arugment can be ma... | {
"AcceptedAnswerId": "257640",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T21:11:33.793",
"Id": "257546",
"Score": "2",
"Tags": [
"beginner",
"c",
"linux",
"unix"
],
"Title": "Rsync helper in C (Improved)"
} | 257546 |
<p>So I have a square matrix with the diagonal and antidiagonal elements different from zero in a vector</p>
<pre><code>vector<int> matrix = {1,2,3,4,5,6,7,8};
</code></pre>
<p>The matrix:</p>
<pre><code>1 0 0 5
0 2 6 0
0 7 3 0
8 0 0 4
</code></pre>
<p>I try to multiply this with another matrix</p>
<p><code>xmatr... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T22:43:52.720",
"Id": "508711",
"Score": "4",
"body": "It is unclear what the problem is. Is the code working as intended or not? If it is, then we'll just review the code you posted here. If it is not working as intended, Code Revie... | [
{
"body": "<p>I believe your issue is that you're altering your matrix (the multiplicand) as you are performing the multiplication. This is why part of the result is correct while the other part is incorrect. For example, the top-right cell (which should be 25) is evaluated from <span class=\"math-container\">\... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T22:24:04.933",
"Id": "257547",
"Score": "2",
"Tags": [
"c++",
"matrix",
"classes"
],
"Title": "Multiply a square matrix with only the diagonal and antidiagonal elements different ... | 257547 |
<p>The main goal of this task is to take values from the query parameter and put it in inputu. The first problem is that I don't know much about how to do it so that the code doesn't repeat itself and I don't know how specifically I could improve the code so that multiple things don't happen again.
Next, the function s... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-23T15:33:57.700",
"Id": "508749",
"Score": "0",
"body": "I was little refactor, but still there is space to improve, for any help I will be so glad."
}
] | [
{
"body": "<p>The <code>validation</code> function:</p>\n<pre><code>const validation = (value, min, max) => {\n if (value < min) {\n return min;\n } else if (value > max) {\n return max;\n }\n return value;\n};\n</code></pre>\n<p>Bounds the <code>value</code> between some mini... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-22T23:54:54.287",
"Id": "257550",
"Score": "3",
"Tags": [
"beginner",
"ecmascript-6",
"react.js"
],
"Title": "Get default value from query params + repeating code"
} | 257550 |
<p>I have implemented a program that carries out ordinary least squares in raw python (but using numpy arrays rather than lists). I would like for my code to be critiqued by the community.</p>
<p>What is a faster/more efficient way to implement ordinary least squares than what I have done in my code snippet below?</p>
... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-23T00:46:31.433",
"Id": "257553",
"Score": "0",
"Tags": [
"python"
],
"Title": "Guidance to implement Ordinary least squares more efficiently"
} | 257553 |
<p>Follow up to <a href="https://codereview.stackexchange.com/questions/257413/efficiently-calculate-value-of-pascals-triangle-using-memoization-and-recursion">Efficiently calculate value of Pascal's Triangle using memoization and recursion</a></p>
<p>Based on feedback given by jvwh in the answers</p>
<pre><code>de... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-24T01:45:34.737",
"Id": "508802",
"Score": "1",
"body": "Just FYI. After staring at a Pascal Triangle for a few hours I came up with a [very different solution](https://scastie.scala-lang.org/hFu1Q7K2QYqIJjVRp0rajg)."
},
{
"Con... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-23T02:46:34.477",
"Id": "257554",
"Score": "0",
"Tags": [
"recursion",
"functional-programming",
"scala",
"dynamic-programming",
"memoization"
],
"Title": "Efficiently calcul... | 257554 |
<p>This is a follow-up question for <a href="https://codereview.stackexchange.com/q/252053/231235">A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++</a> and <a href="https://codereview.stackexchange.com/q/252404/231235">A recursive_count_if Function with Unwrap Level for Var... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-23T05:46:18.847",
"Id": "257556",
"Score": "1",
"Tags": [
"c++",
"strings",
"recursion",
"vectors",
"c++20"
],
"Title": "A batch_recursive_count_if Function with Unwrap Level... | 257556 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.