body stringlengths 25 86.7k | comments list | answers list | meta_data dict | question_id stringlengths 1 6 |
|---|---|---|---|---|
<p>I found this interesting challenge in Exercism.
This is my approach to comparing poker hands in Rust. I've strived for code clarity.
I wish I had figured out how to only implement Ord or PartialOrd, in the end I had to implement both for all structs.</p>
<p>It would be nice also if I had a way to avoid using the ran... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-29T12:28:46.327",
"Id": "510336",
"Score": "3",
"body": "If you're using `char` for suits, you should definitely use `'♠'`, `'♥'`, `'♣'`, and `'♦'` instead of `'S'`, `'H'`, `'C'`, `'D'` ;-)"
}
] | [
{
"body": "<h1>General observations</h1>\n<ul>\n<li><code>rustfmt</code>-compliant formatting </li>\n<li>no warnings </li>\n<li><code>#[derive(Debug)]</code> on everything that might be useful to debug-print </li>\n<li>no tests or <code>main</code> (I guess this is built in to Exercism?) Some of the remainder ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-29T12:18:04.340",
"Id": "258836",
"Score": "4",
"Tags": [
"programming-challenge",
"rust"
],
"Title": "Comparing Poker hands in Rust"
} | 258836 |
<p>So I'm very new if JavaScript and my question is this a right way to implement this functionality? How could I improve this code.</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<head>
<title>TEST</title>
<script>
document.addEventListen... | [] | [
{
"body": "<p>Congrats on getting something like this working! I obviously don't know anything about the background of the project, so keep in mind that while my feedback may be valuable, if it's just a small side project you might not want to overengineer it.</p>\n<p>Regardless, here are some points for you to... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-29T15:43:05.630",
"Id": "258844",
"Score": "2",
"Tags": [
"javascript",
"html"
],
"Title": "Asking and checking if the answer is correct"
} | 258844 |
<p>I need help to format all the input values to the format ‘##-##/##'.
My input might include whole number, fraction or mixed fraction...Sample input 3, 1/1, 1 1/2. I have tried the below code it is giving expected result. Can someone please help for a standard and concise way of doing this</p>
<pre><code>using System... | [] | [
{
"body": "<p>Does this help?</p>\n<p><a href=\"https://github.com/qqtf/StringFormat\" rel=\"nofollow noreferrer\">StringFormat on GitHub</a></p>\n<p>The actual string-logic worked, so I didn't touch it.\nEvery time you want to subject a new string to your logic, you had to adjust your code. This is against ope... | {
"AcceptedAnswerId": "258855",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-29T17:45:55.343",
"Id": "258846",
"Score": "2",
"Tags": [
"c#"
],
"Title": "String format C#"
} | 258846 |
<p>I need to create a component for displaying a list of avatar users....If the users present in the array is more then 3 I have to display a number to indicate the remaining amount of users.</p>
<p>Example:</p>
<pre><code>[{id:1, name: 'Paul', surname: 'Rudd'}, {id:2, name: 'Rose', surname: 'Pink'}, {id:3, name: 'Rich... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T05:40:30.950",
"Id": "510398",
"Score": "0",
"body": "I see little code, nothing but modelling."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T06:07:19.943",
"Id": "510399",
"Score": "0",
... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-29T19:23:37.490",
"Id": "258854",
"Score": "0",
"Tags": [
"javascript",
"typescript",
"angular-2+"
],
"Title": "Is there a better way for this ui component?"
} | 258854 |
<p>I'm a Haskell beginner and trying to hone my skill by solving algorithmic problems. Here's what I got for <code>maxheapify</code> from <code>Introduction to Algorithms</code></p>
<pre><code>ixParent :: Int -> Int
ixParent = floor . flip (/) 2 . fromIntegral
ixLeft :: Int -> Int
ixLeft = (*) 2
ixRight :: Int ... | [] | [
{
"body": "<p>It's unusual to partially apply infix functions by first prefixing them, <code>(*) 2</code> is equivalent to <code>(2 *)</code> and the latter is so much more common I can't recall ever even seeing the former. Note that you can also partially apply the second argument, as in <code>(/ 2)</code>.</p... | {
"AcceptedAnswerId": "258884",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T06:57:13.680",
"Id": "258862",
"Score": "2",
"Tags": [
"haskell"
],
"Title": "Haskell maxheapify"
} | 258862 |
<p>I'm making a user interface for an online coffee shop. I need to call methods that have already been created. The user is also able to make customisations to their drink order such as a different choice of milk, brown or white sugar etc. Once the user choice has been made it will add the drink to their basket. The u... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T18:04:36.867",
"Id": "510435",
"Score": "0",
"body": "I think there's probably (?) enough code here to be on topic, but you would benefit from showing your other submodules - `user`, `display`, etc."
}
] | [
{
"body": "<h2>Strings</h2>\n<p>Given your current code, it doesn't make sense to have <code>Strings</code>. This kind of string centralization is typically seen if you're doing internationalization, but there's no evidence of that.</p>\n<p>Among other problems, <code>Strings</code> isn't used whatsoever as a c... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T13:50:28.293",
"Id": "258873",
"Score": "4",
"Tags": [
"python",
"git",
"e-commerce"
],
"Title": "Making a coffee shop UI"
} | 258873 |
<p>The integration field needs to get recalculated every time the starting or goal coordinates change. I wanted to use the flow field algorithm for a problem that includes bigger mazes with changing starting or ending points every 0.5 seconds. Right now the algorithm is far too slow to be useful because the integration... | [] | [
{
"body": "<p>The code, at least in terms of style, is already pretty decent. Consider:</p>\n<ul>\n<li><p>Add PEP484 type hints</p>\n</li>\n<li><p>Your <code>draw_*_line</code> methods have a confusing name - they don't actually draw anything; they're data construction/setup routines. Also, rather than mutating... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T14:20:14.817",
"Id": "258874",
"Score": "2",
"Tags": [
"python",
"python-3.x",
"numpy"
],
"Title": "Reducing running time of creating integration field in flow field algorithm (py... | 258874 |
<p>This is my third day of learning Javascript through an online class. I learned about arrays and while/for loops today, and to practice all of that stuff the challenge I'm working on is to make a function that produces <span class="math-container">\$(n)\$</span> terms of the Fibonacci sequence in an array.</p>
<p>So ... | [] | [
{
"body": "<p>For a beginner this code looks okay. Good job using strict equality comparisons - i.e. <code>===</code>. The indentation is mostly consistent, although the first indentation level is 4 spaces while all subsequent levels appear to be 2 spaces.</p>\n<p>The biggest thing I would change is spacing. Fo... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T14:40:59.260",
"Id": "258876",
"Score": "1",
"Tags": [
"javascript",
"beginner",
"fibonacci-sequence"
],
"Title": "Fibonacci sequence array in Javascript"
} | 258876 |
<p>I have to do a program in PHP that reads <a href="https://xp-soaring.github.io/igc_file_format/index.html" rel="nofollow noreferrer">IGC files</a> like <a href="https://xcportal.pl/sites/default/files/tracks/2020-06-09/069daro396091568.igc" rel="nofollow noreferrer">this IGC file</a> and gets records about the glide... | [] | [
{
"body": "<p>I don't think I understand the point of declaring a class if you aren't going to write any methods in it. I mean why go the expense of declaring a class just to store some variables outside of the global scope. Assuming this class can never populate its properties without parsing a document, so i... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T15:21:09.753",
"Id": "258877",
"Score": "2",
"Tags": [
"php",
"strings",
"array",
"parsing"
],
"Title": "Parsing glider data from IGC files"
} | 258877 |
<p>I have a code that does applies Dijkstra's algorithm for an adjacency list.</p>
<p>The data are taken from a file. In the file, the first line contains the number of vertices and edges, and the remaining lines contain three elements each (the first 2 are the numbers of the vertices and 3rd are the weight of the edge... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T17:04:45.930",
"Id": "510421",
"Score": "0",
"body": "Without looking at the details, your vector is probably resized and thereby reallocated many many times while it grows. If you know the total count upfront, resize the vector onc... | [
{
"body": "<h1>Avoid <code>using namespace std</code></h1>\n<p>Avoid <code>using namespace std</code>, it is <a href=\"https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice\">considered bad practice</a>. It saves only a little bit of typing, but you can run into issues i... | {
"AcceptedAnswerId": "258897",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T16:42:38.507",
"Id": "258879",
"Score": "3",
"Tags": [
"c++",
"performance",
"file"
],
"Title": "Shortest path algorithm"
} | 258879 |
<p>In the early days of Basic (1970's when i started coding) the midStr() function used left and right positions directly rather than left and length we now use with mid(). I always found it more efficient in my mind to code using the old midStr() method, so I finally just created some code to do it. It's certainly not... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T23:44:37.440",
"Id": "510463",
"Score": "0",
"body": "It is interesting that `midStr(\"Hello World\", 2, 4)` returns `ell`. I would have thought that it would return 2 characters. Not character 2, 3 and 4."
}
] | [
{
"body": "<p>While the <code>Optional ByVal rightPos As Variant</code> is a cool idea because you can use the <code>IsMissing</code> function, it introduces unnecessary errors. For example, <code>Debug.Print midStr("Hello World", 1, Nothing)</code> will print "Error 2015" in the Immediate w... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T16:47:21.223",
"Id": "258881",
"Score": "4",
"Tags": [
"strings",
"vba",
"excel"
],
"Title": "Excel VBA code midStr() function using left and right position instead of length used... | 258881 |
<pre><code>//MEM = initial memory, INDATA, the actual floating point value
#define atomicAddFloatX(MEM, INDATA)\
{\
float data = INDATA;\
float prev_mem = uintBitsToFloat(MEM);\
float exchange_mem = prev_mem;\
float input_mem = (data + prev_mem);\ //initially this is what we assume we want to put in he... | [] | [
{
"body": "<p>I did not realize what atomicCompSwap did nor that it was common for this kind of usecase: <a href=\"https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atomicCompSwap.xhtml\" rel=\"nofollow noreferrer\">https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atomicCompSwap.xhtml</a> . Th... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T16:54:50.990",
"Id": "258883",
"Score": "0",
"Tags": [
"floating-point",
"atomic",
"glsl"
],
"Title": "GLSL atomic float add for architectures with out atomic float add"
} | 258883 |
<p>I have been trying to improve my Python coding and was just wondering if there was a more pythonic way to perform what I have done so far, namely around the date in the <code>main()</code> function.</p>
<pre><code>import datetime
import sybase
account_list = []
def get_date(): # Date -1 day unless Monday then -3 d... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T17:41:05.860",
"Id": "510426",
"Score": "0",
"body": "Sybase, though? Why?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T17:43:06.937",
"Id": "510428",
"Score": "0",
"body": "I have no c... | [
{
"body": "<p>I will focus on the <code>get_date()</code> method. First of all, what sort of date is it? Currently the name makes me think it will get the current date, but it's sort of a banking date? Something along the lines of <code>get_last_banking_day()</code> would be more descriptive?</p>\n<p>You can mo... | {
"AcceptedAnswerId": "258914",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T17:31:04.640",
"Id": "258885",
"Score": "2",
"Tags": [
"python"
],
"Title": "Bank database program"
} | 258885 |
<h1>Enumerating all fixed-length paths from a vertex in a graph</h1>
<h2>1. Graph-related classes</h2>
<p>Base implementations of the relevant classes in my graph library. I'm using C#9 in a .NET 5 project. I opted to use <code>struct</code>s for my <code>Vertex</code> and <code>Edge</code> types to disallow <code>null... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T19:27:20.700",
"Id": "510443",
"Score": "1",
"body": "C# isn't slow, it's a myth, the code you can write may be slow. I say more, it's possible to write code that faster in some cases than C++ because CLR have shiny GC, C++ require ... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T18:06:02.520",
"Id": "258888",
"Score": "0",
"Tags": [
"c#",
"algorithm",
"object-oriented",
"recursion",
"graph"
],
"Title": "Enumerating all fixed-length paths from a ve... | 258888 |
<p>I'm writing a code where a class member, if != -1, set its own position at array. If the value is == -1, the next free index (whose range is 0 too array's length) is used. In this review, I'm more interested in the algorithm, making it faster, accurate and readable than anything else. despite I'm using C#, I'd like ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T20:08:17.077",
"Id": "510445",
"Score": "0",
"body": "Is `arr.Add(new A(0, \"aaa\")); arr.Add(new A(0, \"bbb\"));` a wrong input? How sorting method must behave with such input? `arr.Add(null)`? `arr.Add(new A(-456, \"ccc\"))`? `arr... | [
{
"body": "<h3>Review</h3>\n<ul>\n<li><p>In your test cases, why not use array directly (<code>new A[] { new A(-1, "a"), new A(-1, "b"), new A(0, "c"),... };</code>) instead of <code>List<A>.ToArray()</code>?</p>\n</li>\n<li><p>In the part of <code>isSorted</code> method, do ... | {
"AcceptedAnswerId": null,
"CommentCount": "10",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T19:18:52.910",
"Id": "258890",
"Score": "0",
"Tags": [
"c#",
"array",
"sorting"
],
"Title": "Array member set its own index in the array"
} | 258890 |
<p>So in my free time, I made a discord bot to play around with and learn a bit of python. I'm mainly a java developer. The bot has a few commands that allow it to find and output recipe for cocktails and a few other things revolving around cocktails.</p>
<p>In the background, there are 2 JSON files. My bot mainly read... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T13:36:32.310",
"Id": "510508",
"Score": "1",
"body": "_\"I am used to streams which I don't have in python\"_ -- when you learn a bit more of python, you'll be delighted to see that Javas Streams are just a kludge to achieve a subse... | [
{
"body": "<p>You could replace some for loops with list comprehensions.\nI think list comprehensions are generally preferred and often faster.\nI've also:</p>\n<ul>\n<li>added a default value to the get command in case your JSON is malformed or missing the ABV for some reason, and</li>\n<li>replaced the <code>... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T19:33:48.130",
"Id": "258892",
"Score": "7",
"Tags": [
"python",
"python-3.x",
"json"
],
"Title": "Python discord bot"
} | 258892 |
<p>I need to store sensitive strings in DB, so decided to encrypt it in a DB and decrypt it at the application layer. And noticed that it is not so easy to find ready to use an example. Please check my code below. It is based on <a href="https://damienbod.com/2020/08/19/symmetric-and-asymmetric-encryption-in-net-core/... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T21:42:19.200",
"Id": "510451",
"Score": "0",
"body": "What .NET version? 3.1?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T21:51:49.250",
"Id": "510452",
"Score": "1",
"body": "@aepot, ... | [
{
"body": "<p>This code looks complicated for me. Not because I don't know how to use AES encrypter but it contains a lot of redundancy. From setting <code>CipherMode.CBC</code> which is default to <code>GetNewIv()</code> which is random by default.</p>\n<p>Is a lot of code is targeting the a security improveme... | {
"AcceptedAnswerId": "258898",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-30T20:54:40.460",
"Id": "258896",
"Score": "4",
"Tags": [
"c#",
".net",
"asp.net-core",
"encryption"
],
"Title": ".Net core string symmetric encryption"
} | 258896 |
<p>I'm building a very simple Lisp interpreter. Similar to the the one <a href="https://norvig.com/lispy.html" rel="nofollow noreferrer">from here</a>. Here is what I have so far for the parsing part, that is, everything from "text is passed to the the program" to "ast is built". How does the below ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T05:24:59.353",
"Id": "510478",
"Score": "0",
"body": "No string literals?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T07:34:30.350",
"Id": "510487",
"Score": "0",
"body": "@vnp nope, n... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T01:40:08.170",
"Id": "258908",
"Score": "3",
"Tags": [
"python",
"parsing",
"recursion"
],
"Title": "Lisp expression parser"
} | 258908 |
<p><strong>Goal</strong></p>
<p>In the vector <code>x</code>, I would like to insert the elements of the vector <code>values</code> at indices stored in vector <code>positions</code>. Note that the vector <code>positions</code> is not sorted.</p>
<p>For example, from the following input</p>
<pre><code>std::vector<ch... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T18:30:13.483",
"Id": "510535",
"Score": "0",
"body": "A single tiny hint: for `.size() == 0`, I'd write `.empty()` due to better readability of the intentions IMO."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": ... | [
{
"body": "<ul>\n<li><p>We need to include <code><algorithm></code> for <code>std::sort</code> and <code><cassert></code> for <code>assert</code>.</p>\n</li>\n<li><p><code>void print(std::vector<T> &x)</code>: Since we don't modify the vector, this should take a <code>const&</code> (an... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T07:09:05.130",
"Id": "258910",
"Score": "2",
"Tags": [
"c++",
"performance",
"vectors",
"insertion-sort"
],
"Title": "Inserting multiple elements at known locations in a vecto... | 258910 |
<p>I have created Azure Blob Trigger function. If file is inserted in Azure Blob Container at that time this function is trigger and based on that file data we need to insert into our database table.</p>
<p>My Trigger Function Class be like below</p>
<pre><code>public static class StockCountTrigger
{
[FunctionName(... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T10:49:41.583",
"Id": "510495",
"Score": "0",
"body": "You can easily make you function nonstatic or even go forward and use DI. Why is your environment constant? Probably it should be in the environment variables. I don't think it i... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T07:44:15.640",
"Id": "258911",
"Score": "0",
"Tags": [
"c#",
"beginner",
"object-oriented",
"design-patterns"
],
"Title": "Implementation in Azure Blob Function Trigger for In... | 258911 |
<p>To find neighbors of a vector and return array of Vectors which are neighbors of a Vector:</p>
<pre class="lang-cpp prettyprint-override"><code>vector<XY> neighboursOf(XY coord){
short x = coord.x;
short y = coord.y;
vector<XY> neighbours;
neighbours.reserve(9);
neighbours.push_back... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T11:45:47.517",
"Id": "510496",
"Score": "5",
"body": "A bit more context would be helpful to reviewers. First, it would be helpful to see the `XY` class or struct. Second, I don't believe that `XY[]` is a valid return type. It wo... | [
{
"body": "<p>The <code>XY</code> class looks like it would be better as a plain <code>struct</code>:</p>\n<pre><code>struct XY\n{\n short x;\n short y;\n};\n</code></pre>\n<p>Then we don't need to declare a constructor, because it can be <em>aggregate-initialised</em>.</p>\n<p>I'll assume that your <code... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T11:22:51.640",
"Id": "258915",
"Score": "2",
"Tags": [
"c++",
"c++17",
"vectors"
],
"Title": "Find neighbours of a vector"
} | 258915 |
<p>For a project I have a large dataset with a multitude of variables from different questionnaires. Not all variables are required for all analyses.</p>
<p>So I created a preprocessing script, in which subsets of variables (with and without abbreviations) are created. However it gets confusing pretty fast.
For conveni... | [] | [
{
"body": "<h2>One approach</h2>\n<p>If the description is to serve only as a metadata, <code>R</code> allows you to add any number of metadata to objects with attributes feature. you can add it as an attribute for the <code>data.frame</code> object.</p>\n<pre><code>attr(sub_data, "Description") <-... | {
"AcceptedAnswerId": "259611",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T11:41:19.953",
"Id": "258916",
"Score": "1",
"Tags": [
"r",
"collections"
],
"Title": "R Container for Multiple data.frame with a Brief Description of the Content of the data.fram... | 258916 |
<p>I'm just starting to learn website coding with html, css, and JavaScript. To get a bit of a hang for it, I'm trying to build a complete web page.</p>
<p>So far, I've only done the navbar. I started with a basic Bootstrap 5 navbar and modified it to get it to look and behave like I want. It took me three days, but it... | [] | [
{
"body": "<p>First off, congrats on getting your navbar working and sticking with this over several days! </p>\n<p>There are a lot of things which could be improved, but at a glance the most glaring issue is that your styles are spread all across the HTML, CSS, and JS files. This makes it very difficult to rea... | {
"AcceptedAnswerId": "258953",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T13:29:33.917",
"Id": "258921",
"Score": "1",
"Tags": [
"javascript",
"jquery",
"html",
"css"
],
"Title": "Web-site navigation bar"
} | 258921 |
<p>This is a follow up of <a href="https://codereview.stackexchange.com/questions/257451/skyscraper-solver-for-nxn-size-version-3-using-bitmasks/257468?noredirect=1#comment508823_257468">Skyscraper Solver for NxN Size Version 3</a></p>
<p>I know its getting old...</p>
<p>So I still have the same Issue the code is to sl... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T13:56:05.343",
"Id": "510833",
"Score": "0",
"body": "I didn't read very carefully what the problem is, but it appears to be some kind of a puzzle (like Sudoku or something similar). You could borrow ideas for solving constraint sat... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T16:46:10.427",
"Id": "258925",
"Score": "1",
"Tags": [
"c++",
"performance",
"c++17"
],
"Title": "Skyscraper Solver for NxN Size Version 4"
} | 258925 |
<p>Here is the problem.</p>
<p><em>Repeatedly ask the user to enter game scores in a format like team1 score1 - team2 score2. Store this information in a dictionary where the keys are the team names and the values are tuples of the form (wins, losses).</em></p>
<p>Here is my Solution, what can I change for the better i... | [] | [
{
"body": "<p><strong>add_tuples</strong></p>\n<p>Since you need <code>tuple[int, int] + tuple[int, int]</code> multiple times, I'd put it into a simple function. This will make the rest of your code more concise and readable.</p>\n<pre><code>def add_tuples(tuple1: tuple[int, int], tuple2: tuple[int, int]):\n ... | {
"AcceptedAnswerId": "258939",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T17:02:04.417",
"Id": "258926",
"Score": "5",
"Tags": [
"python"
],
"Title": "Count wins and losses for each team in a league"
} | 258926 |
<p>My code currently doesn't insert data into MySQL fast enough. However I don't know how to measure the current speed.</p>
<pre><code>def insert():
mycursor = mydb.cursor()
plik = input(":::")
agefile = open("C:/Users/juczi/Desktop/New Folder/" + plik, "r")
sql = &... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T17:14:45.623",
"Id": "510526",
"Score": "0",
"body": "\"I was wondering if there is any faster way ...\" why? Is your code currently not fast enough, or do you just want speed for speed's sake?"
},
{
"ContentLicense": "CC BY... | [
{
"body": "<p>If you are trying to insert data in bulk to Mysql the best would be to use <a href=\"https://dev.mysql.com/doc/refman/8.0/en/load-data.html\" rel=\"nofollow noreferrer\">LOAD DATA</a> instead of doing it in a loop on top of an interpreted language, which is inevitably slower. However there is less... | {
"AcceptedAnswerId": "258937",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T17:05:43.370",
"Id": "258927",
"Score": "1",
"Tags": [
"python",
"mysql",
"time-limit-exceeded"
],
"Title": "Inserting data into MySQL"
} | 258927 |
<p>I implemented the <a href="https://en.wikipedia.org/wiki/Maze_generation_algorithm#Iterative_implementation" rel="nofollow noreferrer">iterative randomized depth-first search</a>, with my goal for it to be <em>performant</em>, and have code that made complete sense.</p>
<p>It utilizes <code>AtomicReference<T>... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T05:09:57.867",
"Id": "510595",
"Score": "0",
"body": "Welcome to CodeReview@SE. Every question here is required to be about (coding) an implementation, and I can tell *Java* from the \"required\" language tag: leave both from the ti... | [
{
"body": "<h3>Review</h3>\n<ul>\n<li><p><code>private final int x;</code> and <code>private final int y;</code> part in <code>Cell.java</code>, do you consider to use <a href=\"https://docs.oracle.com/javase/7/docs/api/java/awt/geom/Point2D.html\" rel=\"nofollow noreferrer\">Point2D</a> class?</p>\n</li>\n<li>... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T21:25:16.747",
"Id": "258942",
"Score": "1",
"Tags": [
"java",
"algorithm"
],
"Title": "Iterative Random Depth First Search implementation in Java"
} | 258942 |
<p>I've recently started learning Python again after a long time away from it and doing MATLAB at university. Today, I spent some time working on a first little project of mine. Right now it works as it should minus ending the game when all the fields are full. I would love to get advice on how I could improve the code... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T06:37:24.080",
"Id": "510605",
"Score": "0",
"body": "Welcome to CodeReview. Here we can review complete and working code. If your application is not finished and you are struggling with some problem then please consider to ask ques... | [
{
"body": "<p>The first thing I notice is the two separate maps. Since the only actual information you're storing is X / O positions in a 3x3 grid, I think it is good practice to only store those values. Then add any additional formatting when you print. I've also used <code>snake_case</code> for function and v... | {
"AcceptedAnswerId": "258972",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-31T23:56:44.530",
"Id": "258945",
"Score": "1",
"Tags": [
"python",
"beginner",
"tic-tac-toe"
],
"Title": "Text-based Tic Tac Toe in Python (First Project)"
} | 258945 |
<p>In my data I have few hierarchy values - example address</p>
<blockquote>
<p>Name -> Street -> City -> County -> State -> Country</p>
</blockquote>
<p>The validation I need is: if a value in the above hierarchy is present, then all the previous/higher order values should be present.</p>
<p>Below is a ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T02:29:55.583",
"Id": "510586",
"Score": "1",
"body": "Why was this tagged C/C++? It's java."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T04:31:12.030",
"Id": "510589",
"Score": "0",
"bo... | [
{
"body": "<p><strong>What I'd recommend:</strong><br />\nIf Gapless, only a single complete iteration of the sequence is required. Otherwise, checks till the first gap found.</p>\n<pre class=\"lang-java prettyprint-override\"><code> private boolean isGapLessHierarchy(String... args) { //Hierarchy \n ... | {
"AcceptedAnswerId": "258952",
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T00:26:43.600",
"Id": "258947",
"Score": "5",
"Tags": [
"java"
],
"Title": "Program for checking gaps in hierarchy?"
} | 258947 |
<p>See code below and my comment with questions:</p>
<pre class="lang-rs prettyprint-override"><code>pub fn factors(n: u64) -> Vec<u64> {
let mut m = n; // is it possible to convert n to a mutable type without using another variable?
let mut a:Vec<u64> = Vec::new();
while m % 2 == 0 {
... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T05:05:16.123",
"Id": "510591",
"Score": "0",
"body": "Your while loop is infinite, because m never changes. Does this code have a copy-paste error?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T05:0... | [
{
"body": "<pre><code>pub fn factors(n: u64) -> Vec<u64> {\n let mut m = n; // is it possible to convert n to a mutable type without using another variable?\n</code></pre>\n<p>use <code>pub fn factors(mut n: u64)</code> to allow the parameter to be mutable</p>\n<pre><code> let mut a:Vec<u64>... | {
"AcceptedAnswerId": "258951",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T04:29:59.153",
"Id": "258948",
"Score": "0",
"Tags": [
"performance",
"primes",
"rust"
],
"Title": "Function returning a vec with prime factors of number"
} | 258948 |
<p>I'm new to C# and would appreciate any feedback you might have on the following doubly-linked list implementation, particularly WRT the following language features:</p>
<ul>
<li>Exception handling</li>
<li>Debug.Assert</li>
<li><a href="https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nul... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T05:28:24.867",
"Id": "510597",
"Score": "0",
"body": "If someone with 300+ rep could create the `nullable-reference-types` tag I'll add it to this question. [StackOverflow](https://stackoverflow.com/questions/tagged/nullable-referen... | [
{
"body": "<p>In this review I'll focus on the implementation.</p>\n<h3><code>LinkedList</code></h3>\n<p>I have two problem with this name:</p>\n<ul>\n<li>It is a <strong>doubly</strong> linked list</li>\n<li>There is a <a href=\"https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.linkedlist-... | {
"AcceptedAnswerId": "258960",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T05:24:33.660",
"Id": "258950",
"Score": "1",
"Tags": [
"c#",
"unit-testing",
"null",
"xunit",
"nullable-reference-types"
],
"Title": "Conventional C# for LinkedList wi... | 258950 |
For questions related to C# 8's nullable reference types. | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T07:37:04.747",
"Id": "258957",
"Score": "0",
"Tags": null,
"Title": null
} | 258957 |
<p>I would like to get some feed back on my code; the goal is to get all agencies address of banks. I wrote a pretty simple brute force algorithm.
I was wondering if you would have any advice to improve the code, design it differently (do I need an OOP approach here) etc .</p>
<pre><code>import requests
from lxml impor... | [] | [
{
"body": "<ul>\n<li>It's fine for your strings - and scraped web content - to be localised in French; but ensure that your variables are in English (groupe -> group) for consistency</li>\n<li>Prefer tuples over lists when you have immutable data</li>\n<li>Add PEP484 type hints when possible</li>\n<li>Do not... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T09:11:57.237",
"Id": "258961",
"Score": "2",
"Tags": [
"python",
"design-patterns",
"web-scraping"
],
"Title": "Web scraping and design pattern lifting"
} | 258961 |
<p>This is my implementation of the divide-and-conquer Quicksort algorithm using the <a href="https://en.wikipedia.org/wiki/Quicksort#Lomuto_partition_scheme" rel="nofollow noreferrer">Lomuto partition scheme</a> in C. This is part of a personal project and I'm following Linus Torvalds's <a href="https://www.kernel.org... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T10:42:11.697",
"Id": "510820",
"Score": "0",
"body": "HI @andySukowsiBang - partition function doesn't seem to be correct ... It always does a swap on the first element with itself ... should it perhaps be `for (j = l+1;`"
},
{... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T13:01:49.157",
"Id": "258962",
"Score": "3",
"Tags": [
"algorithm",
"c",
"array",
"sorting",
"quick-sort"
],
"Title": "Quicksort using Lomuto partition scheme in C"
} | 258962 |
<p>If used right, <code>strcmp</code> is not dangerous. However <a href="https://stackoverflow.com/q/1623769/10870835">the code calling it might be</a>. Limiting the opportunity for bugs I might in large teams "dictate" some kind of preemptive strike against bugs from bad calling code. It seems problem number... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T15:00:26.960",
"Id": "510643",
"Score": "0",
"body": "This looks more like a question of how to do something than a request for a code review. Consider asking this on [StackOverflow](https://stackoverflow.com/) instead."
},
{
... | [
{
"body": "<p>The macro is only safe when passed string literals, it is not safe when you pass it pointers to strings. In particular, given a <code>char *s</code>, the result of <code>COUNT_OF(s)</code> is 8 on 64-bit machines. This means that if you pass it pointers to strings shorter than 8 characters (includ... | {
"AcceptedAnswerId": null,
"CommentCount": "8",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T14:03:12.117",
"Id": "258964",
"Score": "0",
"Tags": [
"c",
"strings"
],
"Title": "My safer strcmp"
} | 258964 |
<p>I made simple interpreter in C and now, I want to make my code better.</p>
<p>Here is my code:</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include "def.h"
int main(int argc, char *argv[])
{
int i;
char ch[100];
char in... | [] | [
{
"body": "<h1>Use a parser generator</h1>\n<p>Since it seems like you intend to extend the language you are currently supporting, I cannot recommend that you continue writing the parsing code yourself. It is already not pretty, and even though it could be improved, there are <a href=\"https://en.wikipedia.org/... | {
"AcceptedAnswerId": "258970",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T16:04:35.157",
"Id": "258966",
"Score": "0",
"Tags": [
"c",
"interpreter"
],
"Title": "Simple interpreter in C"
} | 258966 |
<p>I wrote my own dynamic array library for C as I was not happy with the others I found. It is very crude but the basic logic should be correct, it mainly revolves making <code>realloc</code> easier to use and avoiding repetitive code.</p>
<p>Please offer your suggestions and criticisms!</p>
<pre class="lang-c prettyp... | [] | [
{
"body": "<h1>Regarding incrementing by a fixed amount</h1>\n<p>The problem with resizing the storage by a fixed amount each time you reach capacity is that it effectively makes pushing a new element to the array an <span class=\"math-container\">\\$\\mathcal{O}(N)\\$</span> operation. If you instead double th... | {
"AcceptedAnswerId": "258977",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T16:14:08.967",
"Id": "258968",
"Score": "1",
"Tags": [
"c",
"array",
"memory-management",
"library"
],
"Title": "dynarr - yet another simple C dynamic array library"
} | 258968 |
<p>In my real case I have a set of time series related to different IDs stored in a single <code>DataFrame</code>
Some are composed by 400 samples, some by 1000 samples, some by 2000.
They are stored in the same df and:</p>
<p><em><strong>I would like to drop all the IDs made up of time series shorter than a custom len... | [] | [
{
"body": "<p>There are many solutions. For example, you can use a groupby-transform and drop the "small" samples. An appropriate solution will depend on what your requirements are more closely, i.e., will you do the preprocessing once, and then drop different samples?</p>\n<p>Anyway, consider:</p>\n<... | {
"AcceptedAnswerId": "258995",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T16:25:45.057",
"Id": "258969",
"Score": "2",
"Tags": [
"python",
"pandas"
],
"Title": "Pandas Filtering based on the length of the same kind variables in a column"
} | 258969 |
<p>I wasn't sure about how to name it, maybe "follow_ptr", "self_updating_ptr", or "stalking_ptr" or something on those lines. For now it's called Identifier.</p>
<p>What I'm trying to achieve is a pointer wrapper which will always refer to the same object even when that object is moved in... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T18:31:05.950",
"Id": "510665",
"Score": "0",
"body": "Yay time to check if I just wasted 6 hours of my life..."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T18:37:17.650",
"Id": "510669",
"S... | [
{
"body": "<p>The fundamental problem is that the mechanism as it is very non-thread-safe. If you hold identifier in one thread and move it in another thread then it results in data racing as you don't use any memory synchronisation routines.</p>\n<p>Furthermore, you cannot move the object when another thread u... | {
"AcceptedAnswerId": "258983",
"CommentCount": "16",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T18:19:11.577",
"Id": "258973",
"Score": "4",
"Tags": [
"c++",
"memory-management",
"c++17",
"pointers"
],
"Title": "\"observer pointer\" meant to stay updated when the po... | 258973 |
<p>This is a <a href="https://en.wikipedia.org/wiki/Steganography" rel="nofollow noreferrer">steganography</a> tool enabling you to conceal any file within a PNG file. In order to compile the program you need <a href="http://www.libpng.org/pub/png/libpng.html" rel="nofollow noreferrer">libpng</a> to be installed on the... | [] | [
{
"body": "<h2>Unconditional masks</h2>\n<p>This:</p>\n<pre><code> if (byte & (1 << (CHAR_BIT - bit - 1)))\n *value = (*value & ~1) + 1; /* 1 */\n else\n *value = *value & ~1; /* 0 */\n</code></pre>\n<p>is really just</p>\n<pre><code>*value &= ~1;\nif (byte & (1 <... | {
"AcceptedAnswerId": "258996",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T21:51:12.027",
"Id": "258986",
"Score": "2",
"Tags": [
"algorithm",
"c",
"file",
"image",
"steganography"
],
"Title": "PNG steganography tool in C"
} | 258986 |
<p>this is an Angular application, this page will have a list and sublist with action for each one (add/edit/delete)
<a href="https://i.stack.imgur.com/jgdMN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jgdMN.png" alt="enter image description here" /></a>
the buttons (add/edit) will show a popup w... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-01T22:17:22.747",
"Id": "258988",
"Score": "0",
"Tags": [
"javascript",
"typescript",
"angular-2+"
],
"Title": "JS, a multi purpose function"
} | 258988 |
<p>I'm practicing refactoring and Java 8 with very simple examples of Powerball.</p>
<p>I used LottoRank enum to write a function that returns the matched LottoRank based on the number of matches and bonus balls.</p>
<ul>
<li><p>The 1st place is when you hit all 6 numbers.</p>
</li>
<li><p>The 2nd place is when you hit... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T05:17:00.367",
"Id": "510716",
"Score": "0",
"body": "@Marc I added that part, and there's a refactoring part, so I'll add this part as well."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T06:18:55.4... | [
{
"body": "<p>The constants of an <code>enum</code> are <em>full featured classes</em>. This means, in any of that constants you can override any non private method of the <code>enum</code> class itself and change the behavior to something constant specific. Basically this is the OO best practice <em>exchange b... | {
"AcceptedAnswerId": "259010",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T02:09:19.703",
"Id": "258993",
"Score": "1",
"Tags": [
"java"
],
"Title": "how to remove trinocular operator in Java8 Stream filter"
} | 258993 |
<p>So this time I am going to use ActionableWrapper on
<a href="https://github.com/ScottLilly/SOSCSRPG" rel="nofollow noreferrer">https://github.com/ScottLilly/SOSCSRPG</a> which is a simple RPG game.</p>
<p>The main portion of which is GameSession.cs which is the controller and owner of all the game pieces like player... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T02:52:01.350",
"Id": "258994",
"Score": "0",
"Tags": [
"c#",
"properties"
],
"Title": "ActionableWrapper<T> Creating a conversationservice"
} | 258994 |
<p>I been trying to implement a text processor in JavaScript that can handle 4 different types of operations: append, backspace, undo, redo.</p>
<p>The input for this text processor is an array of arraries of a single element or tuples. For example:</p>
<pre class="lang-js prettyprint-override"><code> const input = [[... | [] | [
{
"body": "<h2>Unusual undo redo</h2>\n<p>Your undo and redo operations have a strange behavior in that they are them selves undo-able. Generally undo and redo operations are themselves not undo-able.</p>\n<h2>Bug?</h2>\n<p>Unknown commands will throw the error <code>TypeError: this.operations[operation] is not... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T07:09:25.427",
"Id": "258999",
"Score": "1",
"Tags": [
"javascript",
"object-oriented"
],
"Title": "JavaScript: Text Processor"
} | 258999 |
<p>As a Haskell beginner I'm currently playing around the IO monad and prepared simple program which gets from the user two information:</p>
<ul>
<li>URL (http)</li>
<li>Output file path</li>
</ul>
<p>Then it performs <code>GET</code> request to the provided URL and stores the result in the selected file. HTTP status c... | [] | [
{
"body": "<p>Right from the top I notice you could benefit from some factoring.</p>\n<pre><code>prompt :: String -> IO String\nprompt str = do\n putStr str\n hFlush stdout\n getLine\n</code></pre>\n<p>Then <code>getURL</code> is <code>prompt "URL: "</code> (and maybe doesn't even need to ... | {
"AcceptedAnswerId": "259032",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T10:27:47.417",
"Id": "259003",
"Score": "3",
"Tags": [
"haskell",
"monads"
],
"Title": "Haskell - saving content of HTTP request in selected file"
} | 259003 |
<p>I would like to generate Millions of Random String and Hashes in Java fast as possible. For the moment, @Turing85 gave me a pretty good code who was pretty fast only 5 sec for 50M of random String but the next problem to which I am confronted is the slowness when I hash my passwords in my String. The only problem is... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T11:20:12.357",
"Id": "510749",
"Score": "0",
"body": "To my mind it's a bad idea to be storing the passwords and hashes like this. It would make more sense to generate the password, display it to the user and store only hash with t... | [
{
"body": "<p>"I would like to increase the speed of the SHA256 algorithm"</p>\n<p>You're using a library for the hash so there's really no way for you to make it faster. In theory, if you're an expert in cryptography and in computer science you could maybe build something faster yourself but most lik... | {
"AcceptedAnswerId": null,
"CommentCount": "4",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T10:44:08.717",
"Id": "259004",
"Score": "4",
"Tags": [
"java",
"beginner"
],
"Title": "Generating millions of hashes sha256 and random String in Java"
} | 259004 |
<p>I implemented a convenience class to time code execution and print it to the user. This is part of a bigger project that will be distributed to external users. The timer however is only called by other procedures, not by the user directly. I was interested in implementing this myself, so I'm not looking for an exter... | [] | [
{
"body": "<p>Regarding your question about attribute initialization:</p>\n<p>It's not necessarily better to put all attributes into <code>__init__</code>. It's generally recommended, since we expect to find all class attributes inside of <code>__init__</code>, but I would argue in this case, it's just as reada... | {
"AcceptedAnswerId": "259014",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T12:51:34.243",
"Id": "259011",
"Score": "3",
"Tags": [
"python",
"python-3.x"
],
"Title": "Timer convenience class to time code execution for user output"
} | 259011 |
<p>I'm beginner on doing programming and just started learning C language. Then, i decide to make Tic-Tac-Toe as my first program.</p>
<p>My Tic-Tac-Toe summary: User can choose whether want to play 2 player or against computer. For computer player, i use <strong>Minimax Algorithm</strong> so it's not easy for user to ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T23:44:21.740",
"Id": "510798",
"Score": "0",
"body": "Always write your main() at the bottom of your C file and try not to use global variables."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T01:47:5... | [
{
"body": "<p>regarding the posted code:</p>\n<p>Running it through the compiler results in:</p>\n<pre><code>gcc -ggdb3 -Wall -Wextra -Wconversion -pedantic -std=gnu11 -c "untitled2.c" -o "untitled2.o"\n\nuntitled2.c: In function ‘human_move’:\n\nuntitled2.c:95:31: warning: conversion from ‘... | {
"AcceptedAnswerId": "263559",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T15:00:35.467",
"Id": "259015",
"Score": "3",
"Tags": [
"algorithm",
"c",
"tic-tac-toe"
],
"Title": "Tic-Tac-Toe in C language"
} | 259015 |
<p>I have a Scrabble game program which takes two players' words and calculates who has the winning score.</p>
<p>Whichever player has the highest score is the winner; there's a tie if the scores are the same.</p>
<p>It all seems to work how I have written it; however I am sure it can be done better. Just wondering if ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T08:26:41.557",
"Id": "510812",
"Score": "0",
"body": "I compiled and executed your code: 1) the code did not cleanly compile. Always enable the warnings, then fix those warnings. 2) I ran your code with inputs of `rich` and `chuc... | [
{
"body": "<p>and welcome to C programming! Also, to Code Review.</p>\n<h1>Style</h1>\n<p>There are a couple of "style" issues with your code. The most obvious one is that your indentation is not consistent. I don't know if that's due to pasting it into the browser, or if it appears that way in your c... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T15:44:21.433",
"Id": "259016",
"Score": "1",
"Tags": [
"beginner",
"c"
],
"Title": "Scrabble word scoring"
} | 259016 |
<p>I am fairly new to C++ and I was wondering if there is anything I can improve in this code(perf, readability)? Thanks. This is the full code: <a href="https://github.com/test1230-lab/graphing_calc_cpp/blob/master/MathParser/MathParser.cpp" rel="noreferrer">Github Link</a></p>
<p>I will post the parser that creates a... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T17:33:30.240",
"Id": "510769",
"Score": "0",
"body": "Elaborate in what way?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T19:08:07.967",
"Id": "510783",
"Score": "1",
"body": "Welcome t... | [
{
"body": "<h1>Avoid overly large indentation</h1>\n<p>I can't read the contents of the maps and set being declared at the start of the code without scrolling far to the right. I suggest you reduce the indentation by putting the first element inside the initializer list on its own line, like so:</p>\n<pre><code... | {
"AcceptedAnswerId": null,
"CommentCount": "6",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T17:11:45.900",
"Id": "259019",
"Score": "5",
"Tags": [
"c++",
"c++20"
],
"Title": "A C++ Program to Plot An Equation"
} | 259019 |
<p>I have written a Common Lisp implementation of Scheme's s-expression comments (<a href="https://srfi.schemers.org/srfi-62/srfi-62.html" rel="nofollow noreferrer">SRFI 62</a>):</p>
<pre class="lang-lisp prettyprint-override"><code>(eval-when (:compile-toplevel
:load-toplevel
:execute)
(defu... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-10-17T03:55:44.837",
"Id": "530744",
"Score": "0",
"body": "`(read stream)` should be `(read stream t nil t)` instead. Refer to: [read's recursive-p argument when used inside a reader macro](https://stackoverflow.com/questions/69248229/re... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T17:27:10.473",
"Id": "259020",
"Score": "2",
"Tags": [
"common-lisp"
],
"Title": "S-expression comments in Common Lisp"
} | 259020 |
<p>How could i improve the following code. This part was easy to implement but there is a lot of redondancy and i use pandas to return as dict which seems quite odd.</p>
<pre><code>def pipeline_place_details(place_id, fields, lang):
"""Return a dataframe with useful information
Args:
pla... | [] | [
{
"body": "<p><strong>1. Getting data from dict</strong></p>\n<p>When <code>details</code> is a <code>dict</code>, then instead of writing:</p>\n<pre><code>try:\n address = details['result']['formatted_address']\nexcept KeyError:\n address = ""\n</code></pre>\n<p>you can do:</p>\n<pre><code>addr... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T18:19:23.890",
"Id": "259021",
"Score": "0",
"Tags": [
"python"
],
"Title": "Return target informations from nested api json output"
} | 259021 |
<p>I'm trying to make a console application to sort and delete duplicate image files. I have a folder with about 20000 images which take up roughly 70GB of space.</p>
<p>I wrote the following script and it seems to work fine, but the issue is that my PC runs out of available RAM memory (it has 16GB) without reaching ha... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T18:45:04.180",
"Id": "510776",
"Score": "0",
"body": "What is this code doing?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T18:46:56.597",
"Id": "510777",
"Score": "0",
"body": "Welcome... | [
{
"body": "<p>You don't need to store the whole file contents, compute hash instead. Also converting each image to JPEG is not necessary, use <code>image.RawFormat</code>, it would be a bit faster.</p>\n<pre><code>using (SHA256 sha = SHA256.Create())\nusing (var ms = new MemoryStream((int)new FileInfo(file).Len... | {
"AcceptedAnswerId": "259024",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T18:35:51.173",
"Id": "259022",
"Score": "1",
"Tags": [
"c#",
"time-limit-exceeded",
"image"
],
"Title": "Sort and Delete duplicate image files"
} | 259022 |
<p>I have a table <code>data</code> stored in a database <code>ships.db</code>,
the data are informations of tracked ships hourly.
The table data looks like this.</p>
<pre><code>time | shipId | longitude | latitude
---------------------------------------------------------------------
00:00:00 1 ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T22:30:20.293",
"Id": "510794",
"Score": "1",
"body": "What is your table structure ? Do you have indexes ? Your three nested loops produce a total of 62209 DB calls. I am thinking that *maybe* a more sophisticated SELECT could retri... | [
{
"body": "<p>There are multiple things that I would like to point out to you, just to help you improve coding style. Currently you are not noticing as performance issues as they are hidden due to you DB performance.</p>\n<ol>\n<li><p>Fixed values: You are computing fixed list every time through 'range'. Try to... | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T19:45:19.063",
"Id": "259025",
"Score": "1",
"Tags": [
"python",
"performance",
"sqlite"
],
"Title": "Speed performance of sqlite3 queries looped in python"
} | 259025 |
<p>This is an experiment to see what's involved in adding new functional
capability to the Common Lisp baseline. In this case, it's adding a
sequence function to select elements from a sequence satisfying a
predicate. I don't regard such baseline functions as simple utilities,
because they seem more foundational, bette... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-13T07:11:25.283",
"Id": "511731",
"Score": "0",
"body": "“If there's a way to combine these functions to easily select items from an arbitrary sequence...” it seems to me that your function has the same semantics as [`remove-if-not`](h... | [] | {
"AcceptedAnswerId": null,
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T20:56:23.297",
"Id": "259027",
"Score": "0",
"Tags": [
"performance",
"common-lisp"
],
"Title": "Constructing Functions Patterned After Common Lisp Built-in Functions"
} | 259027 |
<p>I am processing an unknown "length" of generator object.
I have to keep things "lazy" because of memory management.
The processing is compute heavy, so writing it multiproc style is the solution (or at least it seems for me).</p>
<p>I have solved this problem of multiproc on generator object wit... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T01:41:31.093",
"Id": "510803",
"Score": "0",
"body": "The idea behind `multiprocessing.Pool` is that it handles queuing work for the processes. If you want more control, then use Process and Queue."
}
] | [
{
"body": "<p>Here's a condensed illustration of how to achieve your stated purpose, namely\nto <strong>compute the outputs of a generator in parallel</strong>. I offer it because\nI could not understand the purpose of most of the complexity in your current\ncode. I suspect there are issues that you have not ex... | {
"AcceptedAnswerId": "259034",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-02T21:18:35.857",
"Id": "259029",
"Score": "6",
"Tags": [
"python",
"queue",
"generator",
"multiprocessing"
],
"Title": "Compute the outputs of a generator in parallel"
} | 259029 |
<p>I'm trying to get a list of unique colors (rgba values) in an image. Here are my attempts:</p>
<pre><code># 1 - too ugly and clunky
all_colors = []
for i in range(width):
for j in range(height):
color = pix[i, j]
if color not in all_colors:
all_colors.a... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T02:51:45.983",
"Id": "510806",
"Score": "1",
"body": "`as it adds the whole list into memory` both options do that. Or you mean something else?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T09:18:38... | [
{
"body": "<p>It isn't necessary to pass a <code>list</code> to <code>set()</code>. Use a generator expression:</p>\n<pre><code>all_colors = set(pix[i,j] for i in range(width) for j in range(height))\n</code></pre>\n<p>or, use a set comprehension:</p>\n<pre><code>all_colors = {pix[i,j] for i in range(width) for... | {
"AcceptedAnswerId": "259071",
"CommentCount": "7",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T01:33:43.487",
"Id": "259036",
"Score": "-3",
"Tags": [
"python"
],
"Title": "memory-efficient & clean set() in python"
} | 259036 |
<p>Intended as a small project to test out various C++20 features, as well as learn a little bit more about matrices and their uses, I decided to implement a relatively simple matrix class.</p>
<p>After implementing it, I figured out that every single part of it should be able to be done in a compile time context, and ... | [] | [
{
"body": "<p>Stylistically, I'd prefer to see <code>requires</code>-clauses (like <code>noexcept</code>-clauses and trailing return types) indented. That is, where you have</p>\n<pre><code>template <class T>\nrequires foo<T>\nauto foo()\nnoexcept(bar)\n-> baz\n</code></pre>\n<p>I'd prefer to see... | {
"AcceptedAnswerId": "259040",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T02:58:13.083",
"Id": "259038",
"Score": "5",
"Tags": [
"c++",
"matrix",
"c++20",
"constant-expression"
],
"Title": "Compile-time Matrix Class"
} | 259038 |
<p>This Python code</p>
<pre><code>im_data = np.ones((100,100))
im_data[20:50,20:50]=np.zeros((30,30))
</code></pre>
<p>can generate a 2d array that could be used to create an image</p>
<pre><code>plt.axis('off')
axi = plt.imshow(im_data, cmap='Greys')
</code></pre>
<p><a href="https://i.stack.imgur.com/t6fqO.png" rel=... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T07:21:13.753",
"Id": "510810",
"Score": "1",
"body": "Crossposting from [how-do-i-create-a-black-and-white-image-from-a-2d-array-in-java](https://stackoverflow.com/questions/66927922/how-do-i-create-a-black-and-white-image-from-a-2d... | [
{
"body": "<p>You don't need to manually manage nested <code>for</code> loops.</p>\n<pre><code>int[][] pixels = new int[100][100];\nfor (int[] row : pixels) {\n Arrays.fill(row, 1);\n}\n\nfor (int i = 20; i < 50; i++) {\n Arrays.fill(pixels[i], 20, 50, 0);\n}\n</code></pre>\n<p>This will make better us... | {
"AcceptedAnswerId": "259052",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T04:19:36.290",
"Id": "259039",
"Score": "0",
"Tags": [
"java"
],
"Title": "generate a 2d array that could be used to create an image with Java"
} | 259039 |
<p>I'm trying to build an email verification for user signup using <a href="https://docs.djangoproject.com/en/3.1/ref/class-based-views/generic-editing/#django.views.generic.edit.CreateView" rel="nofollow noreferrer"><code>CreateView</code></a>. This view check <strong>whether the user is a new or already existing ina... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T09:32:06.603",
"Id": "259041",
"Score": "2",
"Tags": [
"python",
"django"
],
"Title": "Email verification resend implementation Django"
} | 259041 |
<p>I'm teaching myself Object Oriented Programming in JavaScript and I'm looking over <a href="https://editor.p5js.org/codingtrain/sketches/D4ty3DgZB" rel="nofollow noreferrer">this small P5 code</a> of <a href="https://thecodingtrain.com/CodingChallenges/078-simple-particle-system.html" rel="nofollow noreferrer">Codin... | [] | [
{
"body": "<p>From a short review;</p>\n<ul>\n<li>In OOP, your objects are supposed to be re-usable\n<ul>\n<li>I would take the <code>x</code>,<code>y</code> from a parameter</li>\n<li>I would take the <code>vx</code>, <code>vy</code> from a parameter</li>\n<li>I would even take the <code>alpha</code> from a pa... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T11:11:25.020",
"Id": "259044",
"Score": "2",
"Tags": [
"javascript",
"object-oriented",
"programming-challenge"
],
"Title": "OOP refactoring technique"
} | 259044 |
<p>While answering <a href="https://codereview.stackexchange.com/questions/259019/a-c-program-to-plot-an-equation/259031?noredirect=1#comment510796_259031">this code review question</a>, I came up with a way to convert an equation given at runtime to a <code>std::function<double(double)></code> that would evaluat... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T15:40:12.453",
"Id": "510836",
"Score": "9",
"body": "You have reinvented Forth, I believe! :)"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T17:47:49.727",
"Id": "510852",
"Score": "2",
... | [
{
"body": "<blockquote>\n<p>Is there a better way to do this?</p>\n</blockquote>\n<p>Well, you have dynamic dispatch and yet another scattered island of memory for <em>every single token</em>. That is massively inefficient.</p>\n<p>A simple way to more efficiency is writing your own mini-VM for executing expres... | {
"AcceptedAnswerId": "259056",
"CommentCount": "11",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T13:19:24.680",
"Id": "259045",
"Score": "25",
"Tags": [
"c++",
"performance",
"parsing",
"calculator",
"lambda"
],
"Title": "Poor man's JIT using nested lambdas"
} | 259045 |
<p>I implemented tic-tac-toe in Haskell. I'm trying to incorporate suggestions from my <a href="https://codereview.stackexchange.com/questions/258789/connect-four-winner-checking-algorithm">last question</a> (which mostly revolved around algorithmic logic) while trying something new - IO logic.</p>
<p>What kind of impr... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T18:15:50.457",
"Id": "510912",
"Score": "0",
"body": "One observation is that you are using Maybe a lot, but `do` only for IO. I wonder if the whole winner-checking can be done in one `do` without heavy handling of nested lists... (... | [
{
"body": "<p>Once again your code is very good, most of what I've got is just dotting ıs and crossing ɭ s so I'll probably end up showing off cool stuff more than providing critical feedback.</p>\n<p>I'd define <code>Winner</code> as <code>Winner Player | CatScratch</code>, you've already got a perfectly good ... | {
"AcceptedAnswerId": "259347",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T13:50:43.283",
"Id": "259047",
"Score": "1",
"Tags": [
"haskell",
"functional-programming"
],
"Title": "Tic Tac Toe (Haskell)"
} | 259047 |
<p>Solving the merge intervals problem in golang(link: <a href="https://leetcode.com/problems/merge-intervals/" rel="nofollow noreferrer">https://leetcode.com/problems/merge-intervals/</a>).</p>
<p><strong>The Problem</strong></p>
<pre><code>Given an array of intervals where intervals[i] = [starti, endi], merge all ove... | [] | [
{
"body": "<p>Your code appears to fail on:</p>\n<blockquote>\n<pre><code>Example 1:\n\nInput: intervals = [[1,3],[2,6],[8,10],[15,18]]\nOutput: [[1,6],[8,10],[15,18]]\nExplanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].\n</code></pre>\n</blockquote>\n<p>Output:</p>\n<pre><code>interva... | {
"AcceptedAnswerId": "259067",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T14:26:20.937",
"Id": "259048",
"Score": "1",
"Tags": [
"go"
],
"Title": "Merge Intervals(Golang)"
} | 259048 |
<p>I'm just here for suggestions and code optimisations, what i could've done better, are there any better coding practices...
There's github repo link if you're interested in the code with a form too <a href="https://github.com/throtz/Operators" rel="nofollow noreferrer">https://github.com/throtz/Operators</a>
You bas... | [] | [
{
"body": "<h2>Review</h2>\n<p>It seems that you are trying to make a simple calculator with number comparison in C#. There are some problems in this implementation.</p>\n<h3><code>ToInt32</code>:</h3>\n<p>Do you expect the input of calculation is always in <code>int</code> format? How\nabout floating numbers?<... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T18:58:22.607",
"Id": "259053",
"Score": "0",
"Tags": [
"c#"
],
"Title": "Statement checker c# using forms and frontend"
} | 259053 |
<p>I'm learning to code for about a year and recently I finished my Javascript project. It contains of 11 fairly simple apps involving using APIs and DOM manipulations</p>
<p><strong><a href="https://github.com/matt765/js" rel="nofollow noreferrer">https://github.com/matt765/js</a></strong></p>
<p>it's live here <a hre... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T20:27:06.843",
"Id": "259054",
"Score": "2",
"Tags": [
"javascript",
"html",
"css"
],
"Title": "Javascript portfolio with 11 small apps"
} | 259054 |
<p>I start with an hourly table that has around 40 of items (example: bread, barley, bagels, beef, chicken). The purpose of my code is to aggregate this hourly table's numbers to daily numbers but broken out by a sublocation or "type". My only way to allocate to type is to use a table that shows the % breakdo... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T08:24:48.860",
"Id": "510874",
"Score": "0",
"body": "Would you be open to suggestions about non-vba alternatives? For example, have you used pivot tables before - is there a reason you didn't use them for the aggregation? My initia... | [
{
"body": "<p>Using a class to hold the data specific to the various items will help eliminate a lot of <em>nearly</em> duplicated code in your subroutine. The approach is that you define a class to hold data and objects relevant and unique to each item (bread, barely,chicken, etc). Doing so allows you to oper... | {
"AcceptedAnswerId": "259083",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-03T23:31:14.477",
"Id": "259058",
"Score": "3",
"Tags": [
"vba",
"excel",
"hash-map"
],
"Title": "Aggregating hourly location data into daily sublocation data for many columns"
} | 259058 |
<p>The below is to parse a lisp expression (doing as much as possible in 'one go'). How does it look, and what can be improved?</p>
<pre><code># goal: capture the next token then get the rest of the line
# to be used in a while-loop/yield
tokenizer = re.compile(r"""
\s* # any amount of... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T22:09:28.840",
"Id": "510921",
"Score": "1",
"body": "Typically, a lexer will complain if given invalid inputs. Yours will tokenize anything. Perhaps it would help for you to clarify the goal(s) of this code."
},
{
"ContentL... | [
{
"body": "<p>It's difficult for me to say whether this is well-written or not since there are no tests, and that's fundamentally your biggest problem. A complex regex like this couldn't represent a better subject for unit testing. It's already well-isolated, it's important, somewhat internally complex, and wou... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T03:45:19.843",
"Id": "259062",
"Score": "3",
"Tags": [
"python",
"regex"
],
"Title": "Regex with comments"
} | 259062 |
<p>This is a question from a CS diploma question set :</p>
<blockquote>
<p>Make a program that will create an abbreviation of any given name using the initials. For example if the name if "John Doe", the program will output "J.D".</p>
</blockquote>
<p>My Code:</p>
<pre class="lang-c prettyprint-over... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T13:51:30.757",
"Id": "510883",
"Score": "1",
"body": "Is that a direct quote of the problem statement? In particular, is only one `.` required for that example input, that we'd normally write in English as `J.D.`?"
}
] | [
{
"body": "<p>I would rather start with a very simple approach. Why not just <strong>print out</strong> the <strong>capital</strong> letters?</p>\n<pre><code>#include <stdio.h>\n\nint main(void) {\n char *namestr = "Hi my Four Names";\n\n char *pos = namestr;\n char c = ' ';\n while ... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T05:23:36.120",
"Id": "259064",
"Score": "0",
"Tags": [
"c",
"strings"
],
"Title": "Abbreviating a name"
} | 259064 |
<p>From a CS Diploma course question set:</p>
<blockquote>
<p>Create a two dimensional array of ints, fill it with any random integers. Now find the minimum and maximum number, also find the index of those numbers.</p>
</blockquote>
<p>I was not sure what they meant by "fill it with any random integers". Shou... | [] | [
{
"body": "<p>The formulated task leaves a lot of room for interpretation. You chose to simplify several points.</p>\n<blockquote>\n<p>Fill [the array]...now find...</p>\n</blockquote>\n<p>I take this as "create a function that finds...". This forces you to organize the program. Combining both (2D arr... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T06:07:22.880",
"Id": "259065",
"Score": "0",
"Tags": [
"c",
"array"
],
"Title": "Create a two dimensional int array and find the smallest and biggest member along with the indexes"
} | 259065 |
<p>I wrote this simple Makefile but it ended up like a <em>spaghetti</em> code. I used <code>basename</code> multiple times. I have a special case for <code>first.spec.scala.run</code> and <code>follow.spec.scala.run</code> and maybe more antipattern code that I am not aware of. I am not happy with my code and I apprec... | [] | [
{
"body": "<p>I don't know Scala, but I do know Make, so I hope this helps.</p>\n<p>Firstly, the makefile is missing <code>.DELETE_ON_ERROR:</code>, which pretty much every makefile needs, to avoid part-written output files appearing up-to-date when a compilation command fails (e.g. is interrupted).</p>\n<p>We ... | {
"AcceptedAnswerId": "259113",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T06:12:54.603",
"Id": "259066",
"Score": "1",
"Tags": [
"makefile"
],
"Title": "Simple Makefile to build and run scala program"
} | 259066 |
<p>A common preprocessing in machine learning consists in replacing rare values in the data by a label stating "rare". So that subsequent learning algorithms will not try to generalize a value with few occurences.</p>
<p><a href="https://scikit-learn.org/stable/modules/generated/sklearn.pipeline.Pipeline.html... | [] | [
{
"body": "<ul>\n<li><p>You could use scikit-learn's <a href=\"https://scikit-learn.org/stable/modules/generated/sklearn.base.TransformerMixin.html\" rel=\"nofollow noreferrer\"><code>TransformerMixin</code></a> which provides an implementation of <code>fit_transform</code> for you (its implementation is availa... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T08:30:16.143",
"Id": "259072",
"Score": "3",
"Tags": [
"python",
"pandas",
"machine-learning"
],
"Title": "Pandas replace rare values in a pipeline"
} | 259072 |
<p>I made a Rock Paper Scissors game. It works fine but I would like to know how can I improve it further.</p>
<pre><code>#include <iostream>
#include <algorithm>
#include <string>
#include <random>
#include <array>
#include <map>
#include <limits>
namespace
{
enum Winner ... | [] | [
{
"body": "<p>Looks pretty good at first glance! I'd say your main problem is "<code>#define ONE 1</code>" — you've gone out of your way to parameterize things that can't actually be changed in real life without massive changes elsewhere in the game logic. For example, you've set</p>\n<pre><code>enum ... | {
"AcceptedAnswerId": "259086",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T10:15:03.340",
"Id": "259076",
"Score": "2",
"Tags": [
"c++",
"c++11"
],
"Title": "Simple Rock Paper Scissors"
} | 259076 |
<p>I am building a library to abstract DOM manipulation. Here's what the usage looks like:</p>
<pre><code> vsAddToSection() {
let _inChapter: c.InChapter;
let v$sections = vmap([], _ =>
vh('div.section.item', {}, {
listeners: {
click: (e, __) => {
this.ctrl.inSection... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T11:17:19.173",
"Id": "259077",
"Score": "1",
"Tags": [
"javascript",
"typescript",
"html5"
],
"Title": "How to abstract DOM manipulation in a simple intuitive way"
} | 259077 |
<p>I just learned about arraylists and I got a mission to build Mobile phone application with contact list when you can add \ remove \ modify \ search for contacts.</p>
<p>If you think I should add something to the code feel free to tell me :)</p>
<h2>MobilePhone class</h2>
<pre><code>public class MobilePhone{
pri... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-07T19:44:45.090",
"Id": "511200",
"Score": "0",
"body": "Just one small note. Do not use the implementation instead of an interface. Instead of `public ArrayList<Contact> myContacts = new ArrayList<Contact>();` use `List<Contact> myCon... | [
{
"body": "<h2>What I like</h2>\n<p>You follow the Java Naming conventions and the names you choose for your identifiers are pretty good.</p>\n<h2>What I don't like</h2>\n<h3>Unnecessary mutability</h3>\n<p>The member variable <code>phoneNumber</code> in your class <code>MobilePhone</code> does not change durin... | {
"AcceptedAnswerId": "259088",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T13:52:00.750",
"Id": "259080",
"Score": "5",
"Tags": [
"java"
],
"Title": "Contacts list manager"
} | 259080 |
<p>I successfully solved a problem on Hackerrank called <a href="https://www.hackerrank.com/challenges/contacts/problem" rel="nofollow noreferrer">Contacts</a>, but I'm curious if my code in C++ looks good to C++ developers. If not, how it should be improved.</p>
<p>Below is the short description of the problem and the... | [] | [
{
"body": "<p>The Trie approach might be overkill for this question. I think that a plain (ordered) <code>std::set</code> (or <code>std::multiset</code>) would be adequate. The set's <code>lower_bound()</code> member takes you directly to the first entry with the specified substring. From there, we can eithe... | {
"AcceptedAnswerId": "259085",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T13:57:19.423",
"Id": "259081",
"Score": "4",
"Tags": [
"c++",
"programming-challenge",
"c++14"
],
"Title": "Contacts programming challenge"
} | 259081 |
<p>I tried implementing a thread-safe ring queue in C++. I'm totally new to move semantics and C++11/14/17 in general.</p>
<pre><code>#ifndef THREAD_SAFE_RING_QUEUE_HPP_
#define THREAD_SAFE_RING_QUEUE_HPP_
#include <mutex>
#include <optional>
#include <vector>
namespace structure {
class MaximumCapa... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T15:38:51.017",
"Id": "510897",
"Score": "0",
"body": "Are you using CppUNIT or some other unit testing framework?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T15:41:03.603",
"Id": "510898",
... | [
{
"body": "<h1><code>ConsumeNext()</code> should not return a reference</h1>\n<p>The problem with <code>ConsumeNext()</code> is that it returns a reference to an object. However, that element is also marked as consumed. So the caller cannot safely access this element, since it can be overwritten by a call to <c... | {
"AcceptedAnswerId": "259098",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T14:57:35.407",
"Id": "259087",
"Score": "6",
"Tags": [
"c++",
"reinventing-the-wheel",
"c++17"
],
"Title": "Writing a thread-safe ring queue in C++17"
} | 259087 |
<p>I want to ask question about a better way for implementing single endpoint REST.</p>
<p>I want to build a rest API but I want it to only have single endpoint like: <code>graphql</code>, where you only have like: <code>host/graphql</code>.</p>
<p>I already doing this example in <code>laravel</code> where you need to ... | [] | [
{
"body": "<p>I only have a few quibbling remarks:</p>\n<ul>\n<li>Don't Repeat Yourself (D.R.Y.)\n<ul>\n<li>Declare <code>$url = $host . $request->key</code> unconditionally at the start of your method (say, after <code>$host</code>). Then append text to it if/when needed <code>$url .= '/' . $payload['id'];... | {
"AcceptedAnswerId": "259101",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T17:47:46.503",
"Id": "259092",
"Score": "4",
"Tags": [
"php",
"api",
"laravel",
"rest"
],
"Title": "Single end point REST API"
} | 259092 |
<p>For a project, I need to make use of Selenium WebDrivers, and since they're so expensive to start, I decided to write a pool to manage them.</p>
<pre><code>with driver_pool.FirefoxWebDriverPool(5) as d_pool:
# Sequentially visit a page 1000 times
for _ in range(1000):
# Don't actually run this. I acc... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T19:34:04.517",
"Id": "259093",
"Score": "1",
"Tags": [
"python",
"python-3.x",
"selenium",
"webdriver"
],
"Title": "A thread-safe WebDriver pool to submit browsing jobs to"
} | 259093 |
<p>Learning Modern C++ patterns and this ended up being the direction I went to to create an encapsulation of SDL's window management, while trying to stay with RAII practices. This is meant to be a base for a software renderer (and possibly expanding to OpenGL after that).</p>
<blockquote>
<p>window/input.h</p>
</blo... | [] | [
{
"body": "<p>Note, this is just a partial review of your code.</p>\n<h1>Use namespaces and nested classes</h1>\n<p>The way you named things in your code is a bit inconsistent. There is the namespace <code>sdl_raii</code> which contains classes like <code>SdlWindow</code>, but then there is also <code>SdlAppWin... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T21:29:41.347",
"Id": "259096",
"Score": "4",
"Tags": [
"c++"
],
"Title": "C++, SDL, and RAII"
} | 259096 |
<p>The following is my attempt to implement a <code>insert_sorted()</code> C++ function that accepts any sorted STL container and item and inserts it at the right position in the container:</p>
<pre><code>template<template<typename, typename, typename> typename C, typename T1, typename Comp, typename A, typena... | [] | [
{
"body": "<p><code>inline</code> is redundant when writing template functions.</p>\n<hr />\n<p>When we use <code>std::begin()</code> and <code>std::end()</code>, we should always consider whether we actually want to use <code>begin()</code> and <code>end()</code> of the type's namespace instead (argument-depen... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-03-15T15:07:26.753",
"Id": "259097",
"Score": "6",
"Tags": [
"c++",
"stl"
],
"Title": "Insert into any sorted container"
} | 259097 |
<p>I'm designing an algorithm that creates optimum teams based on everyone's availabilities (maximizes the amount of shared availability). To this end, I've made a function that takes in a dictionary of availabilities mapping person to an array of their availabilities throughout the week at every 15 minute point (e.g. ... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T23:59:52.873",
"Id": "510926",
"Score": "1",
"body": "It seems unusual to treat this kind of thing as a maximization problem rather than a sufficiency problem. Does it really matter whether team players have maximum schedule alignme... | [
{
"body": "<h1>Review</h1>\n<h2>Imports</h2>\n<p><code>import operator</code> is being done twice, which is unnecessary.</p>\n<p><code>from itertools import combinations, chain</code>: <code>chain</code> is never used, and can be removed.</p>\n<h2>N Choose R</h2>\n<p>As of Python 3.8, the "n choose r"... | {
"AcceptedAnswerId": "259264",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T22:40:18.603",
"Id": "259099",
"Score": "4",
"Tags": [
"python",
"performance",
"algorithm",
"search"
],
"Title": "Find optimum teams given calendar availabilities"
} | 259099 |
<p>I recently developed code that can run as a function parameter but I'm not quite sure how vulnerable it is to hacks and/or cheats.</p>
<p>Also, is there anything I could improve?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre cla... | [] | [
{
"body": "<p>Some thoughts:</p>\n<ul>\n<li><p>Writing <code>testCode(h1.textContent = world)</code> is a bit unconventional, and might not do what you expect: this is the same as writing the two lines</p>\n<pre class=\"lang-js prettyprint-override\"><code>h1.textContent = world;\ntestCode(world);\n</code></pre... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-04T23:19:14.830",
"Id": "259102",
"Score": "0",
"Tags": [
"javascript",
"html",
"security"
],
"Title": "Please check out my code incrementer"
} | 259102 |
<p>A few weeks ago, I wrote a Reverse Polish Notation program for my Ti-84+CE calculator. It was a successor to a program I wrote in TI-BASIC a while back, but since that one had too much input lag to be usable, I decided to write this one in C and compile it to native z80 assembly.</p>
<p>I wrote this program the nigh... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T02:48:53.747",
"Id": "510933",
"Score": "1",
"body": "I'm more curious about how you made that gif! Is there now a way to run and/or screencap TI-83 programs too?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "... | [
{
"body": "<p>Instead of</p>\n<pre><code>#define OVERDRAW_IS_REDRAW 0\n#if OVERDRAW_IS_REDRAW\nvoid draw_line() {\n draw_line_clear(true);\n}\n#else\nvoid draw_line() {\n draw_line_clear(false);\n}\n#endif\n</code></pre>\n<p>why not</p>\n<pre><code>#define OVERDRAW_IS_REDRAW false\n\nvoid draw_line() {\n ... | {
"AcceptedAnswerId": "259123",
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T00:45:59.097",
"Id": "259105",
"Score": "4",
"Tags": [
"c",
"embedded"
],
"Title": "Ti-84+CE Reverse Polish Notation Progam"
} | 259105 |
<p>I have looked at many topics related to this topic, but I could not find or understand for datagridview table. Finally I made the undo / redo implementation myself using datatable lists. This solution is valid for small tables, I think. I don't know if it will work efficient on tables with lots of data. I will share... | [] | [
{
"body": "<h2>Review</h2>\n<p>Welcome to Code Review. There are few suggestions as below.</p>\n<h3>Layout and formatting</h3>\n<p>Not sure why many newlines between the curly brackets and the method definition, <code>if</code> statements and <code>for</code> statements. For improving readability, those unneces... | {
"AcceptedAnswerId": "259114",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T05:17:14.390",
"Id": "259109",
"Score": "3",
"Tags": [
"c#",
"winforms",
".net-datatable"
],
"Title": "Undo/Redo Functionality in DataGridView c#"
} | 259109 |
<p>How can I avoid repeating code fragments between the mutations and types with graphene in a FastAPI app? I really want to avoid repeating any codes for obvious reasons.</p>
<p><strong>graphql\mutations.py</strong></p>
<pre><code>import graphene
from models.customers import CustomerLogin, CustomerLogin_PydanticIn
f... | [] | [] | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T05:25:58.570",
"Id": "259110",
"Score": "1",
"Tags": [
"python",
"graphql"
],
"Title": "Avoiding Duplicated Code Fragments Graphene in FastAPI"
} | 259110 |
<p>The following code is an async beginner exploration into asynchronous file downloads, to try and improve the download time of files from a specific website.</p>
<hr />
<p><strong>Tasks:</strong></p>
<p>The tasks are as follows:</p>
<ol>
<li><p>Visit <a href="https://digital.nhs.uk/data-and-information/publications/s... | [] | [
{
"body": "<p>Looks fine to me, you could potentially shave off some repetition, but it's not like it matters that much for a small script.</p>\n<p>That said, I'd reuse the session, inline a few variables, fix the naming (constants should be uppercase) and use some standard library tools like <code>os.path</cod... | {
"AcceptedAnswerId": "259131",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T06:09:20.150",
"Id": "259112",
"Score": "5",
"Tags": [
"python",
"python-3.x",
"web-scraping",
"asynchronous"
],
"Title": "Async download of files"
} | 259112 |
<p>I made a test job to the position of Junior Java Developer. I did not receive any answer from the employer, so I would like to get a review here.</p>
<h2>Task description</h2>
<p>A simple text file with IPv4 addresses is given. One line is one address, something like this:</p>
<pre><code>145.67.23.4
8.34.5.23
89.54.... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T15:43:21.767",
"Id": "510958",
"Score": "7",
"body": "I'm not a Java pedant, so I don't have a review for you. IMO, you've done a pretty good job, and if I were looking for a junior developer, I'd be happy with that code (assuming y... | [
{
"body": "<p>The maximum <code>int</code> value is <span class=\"math-container\">\\$2^{31}-1\\$</span>, so your <code>BitSet</code>s have <span class=\"math-container\">\\$2^{31}-1\\$</span> entries each, so together they only cover <span class=\"math-container\">\\$2^{32}-2\\$</span> IPs, missing two. And yo... | {
"AcceptedAnswerId": "259143",
"CommentCount": "20",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T13:45:04.760",
"Id": "259119",
"Score": "30",
"Tags": [
"java"
],
"Title": "Counting the number of unique IP addresses in a very large file"
} | 259119 |
<p>I have below bash script which i have written to check the health of different storage component and then creates an incident through service-now tool.</p>
<p>This is script is working fine for me but i think this can be improved as i written this while learning through different google sources.</p>
<p>I would appre... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T16:38:19.887",
"Id": "511065",
"Score": "0",
"body": "You can double quote all the variables except consonants as you are using bash and can use array and then call into the for loop that's more elegant thank using `$(echo $cluster... | [
{
"body": "<p>Changes:</p>\n<ul>\n<li>Quote variables unless you have a good reason not to quote them.<br />\nHow about a password <code>* $(touch /tmp/sorry) *</code> ?</li>\n<li>Use <code>${parameter:-word}</code> for turning an empty <code>vaultenv</code> into <code>prod</code>.<br />\nIf parameter is unset ... | {
"AcceptedAnswerId": "259365",
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T15:44:52.753",
"Id": "259120",
"Score": "3",
"Tags": [
"json",
"bash",
"linux",
"shell"
],
"Title": "Bash Script for healthcheck linux"
} | 259120 |
<p>I am trying to learn C++, so I started coding a custom string class (using only c-style strings) to get familiar with concepts like operator overloading etc. in the case we have a pointer attribute. I wanted to know if there is a smarter/better/neater way to implement the += operator (or the others).</p>
<p>So I am ... | [] | [
{
"body": "<p>You did a single-null-allocation correctly(ish) once:</p>\n<pre><code>if(str == nullptr){\n this->str = new char;\n *(this->str) = '\\0';\n</code></pre>\n<p>and incorrectly a second time:</p>\n<pre><code>if(str == nullptr){\n this->str = new char;\n this->str = '\\0';\n</co... | {
"AcceptedAnswerId": null,
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T17:49:29.397",
"Id": "259125",
"Score": "2",
"Tags": [
"c++",
"strings",
"reinventing-the-wheel",
"overloading"
],
"Title": "C++ overloading += operator in custom string class... | 259125 |
<p>In a <a href="https://www.ted.com/talks/linus_torvalds_the_mind_behind_linux" rel="nofollow noreferrer">TED talk</a> Linus Torvalds made a point about <em>“good taste”</em> at approximately <a href="https://www.ted.com/talks/linus_torvalds_the_mind_behind_linux#t-850000" rel="nofollow noreferrer">14:10 in the interv... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T20:38:38.917",
"Id": "510980",
"Score": "2",
"body": "It's generally not good taste to `exit()` from a minor function call."
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T21:39:48.150",
"Id": "51... | [
{
"body": "<blockquote>\n<p>I also followed [Torvalds'] coding style</p>\n</blockquote>\n<p>I'm all for coding style standards, though I decline to listen to all of his suggestions simply because he's the loudest (seriously, very very loud) voice in the room. His blind obedience to 1988's K&R with no other ... | {
"AcceptedAnswerId": "259232",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T18:35:50.870",
"Id": "259127",
"Score": "1",
"Tags": [
"c",
"linked-list"
],
"Title": "Delete last node in singly linked list"
} | 259127 |
<p>I am trying to using HttpClient for making API calls from a different domain and for that purpose I have created the following service class after doing some research. It is 4.7.2 framework and not a .NET core system. I have created library class for this with following classes. Please give me your valuable suggesti... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T22:29:25.007",
"Id": "511087",
"Score": "1",
"body": "What is `HttpClientNS`?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-07T10:42:35.100",
"Id": "511139",
"Score": "1",
"body": "Please t... | [
{
"body": "<p>Quick remarks:</p>\n<ul>\n<li><p>Don't do this:</p>\n<pre><code> public RequestService()\n {\n _hostWebApiUrl = Config.AppSettings["TestWebApiURL"];\n _apiAuthKey = Config.AppSettings["ApiKey"];\n }\n\n public RequestService(string hostWebApiUrl, string apiAuthKey)\n {\... | {
"AcceptedAnswerId": null,
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T20:46:46.890",
"Id": "259133",
"Score": "0",
"Tags": [
"c#",
"asp.net-mvc",
"asp.net-web-api"
],
"Title": "Generic Wrapper class for HTTPClient methods"
} | 259133 |
<p>I have been coding 'Pac-Man' with my 16yo. A hopefully not too boring project to help improve his Python coding. We have just moved the 'Ghosts' into a class which was a good first introduction to objects for him.</p>
<p>My coding is far from perfect, and especially not in Python. Which was only just being invented... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-07T09:05:23.543",
"Id": "511121",
"Score": "1",
"body": "Can whoever voted to close this question please leave a comment explaining why?"
},
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-12T10:57:59.487",
... | [
{
"body": "<blockquote>\n<p>I am looking for feedback on how to improve the professionalism of his code</p>\n</blockquote>\n<blockquote>\n<p>how to be more 'pythonic'</p>\n</blockquote>\n<p>The style you've used is atypical in Python as your code doesn't follow <em>all</em> of <a href=\"https://www.python.org/d... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-05T22:06:07.707",
"Id": "259135",
"Score": "9",
"Tags": [
"python",
"object-oriented",
"pygame",
"breadth-first-search"
],
"Title": "Python PacMan with son"
} | 259135 |
<p>I'm writing the C++ program that involves a twist on Rock, Paper, Scissors. How the added Lizard and Spock affect the game is very simple and you could look it up if you want, but its not needed as I'm 99% sure my issue lies with the formatting of my if-else statements.</p>
<p>In every iteration, no matter what conf... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T11:58:49.943",
"Id": "511023",
"Score": "2",
"body": "Welcome to the Code Review Community where we review code that is working as expected and provide suggestions on how to improve that code. Questions about code that is not workin... | [
{
"body": "<h1>Spacing</h1>\n<p>Before anything, I would recommend fixing your spacing and tabbing. Four spaces for each level of nesting is recommended. It makes your code <em>a lot</em> more readable.</p>\n<h1>Bug</h1>\n<p>There is a pretty obvious bug in your code I noticed on my first pass. It's how you're ... | {
"AcceptedAnswerId": null,
"CommentCount": "2",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T03:26:58.493",
"Id": "259136",
"Score": "0",
"Tags": [
"c++",
"rock-paper-scissors"
],
"Title": "Rock-Paper-Scissors-Lizard-Spock C++ Pogram"
} | 259136 |
<p>While writing simple text rendering I found a lack of utf-8 decoders. Most decoders I found required allocating enough space for decoded string. In worse case that would mean that the decoded string would be four times as large as the original string.</p>
<p>I just needed to iterate over characters in a decoded form... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T11:33:30.667",
"Id": "511017",
"Score": "0",
"body": "Looks like you're missing `#include <cstdint>` and a bunch of `using`s for those typedefs - would you care to include them in the code?"
},
{
"ContentLicense": "CC BY-SA ... | [
{
"body": "<blockquote>\n<pre><code>// unsigned integer types\ntypedef uint64_t U64;\ntypedef uint32_t U32;\ntypedef uint16_t U16;\ntypedef uint8_t U8;\n\n// signed integer types\ntypedef int64_t I64;\ntypedef int32_t I32;\ntypedef int16_t I16;\ntypedef int8_t I8;\n</code></pre>\n</blockquote>\n<p>This has inst... | {
"AcceptedAnswerId": "259165",
"CommentCount": "3",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T06:08:31.300",
"Id": "259140",
"Score": "2",
"Tags": [
"c++",
"utf-8"
],
"Title": "C++ UTF-8 decoder"
} | 259140 |
<p>I've recently started learning elixir, and the following is my attempt at fetching the local IP address of the system.</p>
<p>It can definitely be improved further, but as this would be my first ever project in a functional language; I'd be open to any criticisms.</p>
<pre><code>defmodule Systemip do
def private_i... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-05-26T11:42:30.717",
"Id": "515508",
"Score": "1",
"body": "Very interesting code! Definitely willing to take a crack at this, which I'll do as soon as I get a chance. I deleted an earlier question that was obvious when I read your questi... | [
{
"body": "<p>There is few problems there:</p>\n<ol>\n<li>There is no <code>:inet.getif/0</code> function listed in <a href=\"https://erlang.org/doc/man/inet.html\" rel=\"nofollow noreferrer\"><code>inet</code> module docs</a>, which mean that if such function exists, then it is non-public API and <strong>shoul... | {
"AcceptedAnswerId": null,
"CommentCount": "1",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T06:33:32.323",
"Id": "259142",
"Score": "1",
"Tags": [
"functional-programming",
"ip-address",
"elixir"
],
"Title": "Retrieving first non-private ip for local system in elixir"
} | 259142 |
<p>I have written a (recursive) deep clone method for ES/JS-objects. It seems <a href="https://stackblitz.com/edit/js-mv1vqt?file=ObjectClone.js" rel="nofollow noreferrer">to work fine</a>, but maybe I'm missing things. Please, feel free to comment!</p>
<p><strong>Note</strong>: the method will not clone <a href="https... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-08T12:18:57.947",
"Id": "511254",
"Score": "0",
"body": "You are missing several small functions, making this code not work without them. This is grounds to get this question closed on CodeReview. Also, this code cannot handle cyclic s... | [
{
"body": "<p>I spent a ton of time on this;</p>\n<ul>\n<li>The choice to replicate <code>Date</code> but not the other <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects\" rel=\"nofollow noreferrer\">50+ built-ins</a> is interesting</li>\n<li>I would write <code>isObject... | {
"AcceptedAnswerId": null,
"CommentCount": "7",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T08:18:00.637",
"Id": "259145",
"Score": "1",
"Tags": [
"javascript",
"ecmascript-6"
],
"Title": "A (deep) cloning method for ES-Objects"
} | 259145 |
<p>I have created this basic use case of <code>.sort()</code> for my own reference. I am asking for a review to see if there are bad practices present or areas that could be optimised.</p>
<ul>
<li>Is my use of modifying the array correct? Do I need to place the newly sorted list into a new array?</li>
<li>Using <code>... | [] | [
{
"body": "<p>Some of the things I'd point out in your code for improvements:</p>\n<ol>\n<li>Arrays can be a const since you will not modify the array itself but just push new elements to the array.</li>\n<li>In your functions <code>sortAsc, sortDesc</code>, you are iterating through <code>arr</code> just to ma... | {
"AcceptedAnswerId": "259185",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T08:22:16.880",
"Id": "259146",
"Score": "2",
"Tags": [
"javascript",
"sorting"
],
"Title": "Sorting alphabetically ascending and descending using .sort()"
} | 259146 |
<p>I've created a little GUI where the text entered in the text-fields is stored in a property of the currently selected button. If a different button is clicked, the contents stored for that button are inserted into the text-fields.</p>
<p>For storing the information I'm currently using a class where each text-field's... | [] | [
{
"body": "<p>Your implementation of <code>Storage</code> lends itself nicely to using a <code>dataclass</code>.</p>\n<pre><code>from dataclasses import dataclass\n\n@dataclass\nclass Storage:\n field1: str = ""\n field2: int = -1\n field3: str = ""\n</code></pre>\n<p>This makes you... | {
"AcceptedAnswerId": "259162",
"CommentCount": "0",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T09:55:57.540",
"Id": "259149",
"Score": "3",
"Tags": [
"python",
"pyqt"
],
"Title": "Storing the contents of text fields and inserting the stored values on button-click"
} | 259149 |
<p>I come from an OOP background, and have recently delved into C and embedded systems.</p>
<p>As an exercise I wanted to see if I could wrap some OOP concepts into a macro header.</p>
<p>It works as I intended, is fairly simple to use and get a grip on if you know OOP terminology / concepts.</p>
<p>Would love any feed... | [
{
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T11:51:31.443",
"Id": "511022",
"Score": "2",
"body": "Have you tested this beyond what you have in the main.c example? At the moment this looks very hypothetical which would make it off-topic for Code Review. Possible problems I see... | [
{
"body": "<p>The appeal of C is that it's simple, standard, and performant. Whereas your approach might (?) not impact performance all that much, it soundly destroys the first two concepts.</p>\n<p>For reference, you're of course not the first to have tried <a href=\"https://en.wikipedia.org/wiki/GObject\" rel... | {
"AcceptedAnswerId": "259171",
"CommentCount": "5",
"ContentLicense": "CC BY-SA 4.0",
"CreationDate": "2021-04-06T10:04:37.857",
"Id": "259151",
"Score": "2",
"Tags": [
"object-oriented",
"c"
],
"Title": "C Macro based OOP"
} | 259151 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.