« first day (2457 days earlier)      last day (1546 days later) » 

12:00 AM
RELOAD! There are 6373 unanswered questions (90.0817% answered)
 
0
Q: What is good practise, more readable?

userI was wondering what is the better way of writing? Having several variables to show the steps or rather do method chaining? function count(string) { const array = string.split(""); return array.filter(element => element === "a").length } function count(string) { return string ...

 
 
1 hour later…
1:02 AM
0
Q: template literal code for RGBA value to be used in a game

Ryan Stoneis there a shorter way to write this code block? i tried it with arrow functions but it spat back errors and didn't want to work. function r(){ rx = Math.floor(Math.random()*255) return rx; }; function g(){ gy = Math.floor(Math.random()*255) return gy;...

 
1:22 AM
0
Q: Optimising code to calculate scores for a set of templates Python

user6916458I have a set of code that calculates how well a templates fits a users details. It's kind of long, so I've cut out all the code that does it's job well and only included the bottle neck and surrounding code. My target here is speed! A couple of notes on the variables: Calculated at run time (ch...

 
 
3 hours later…
4:28 AM
0
Q: Inversionless lenstra ECM running way slower than it should be

J. DoeSo I was coding Inversionless ECM using Prime Numbers: A computational perspective and when I finished and tried running my program it ran way, way slower than it is supposed to. I have no idea what I am doing wrong. The algorithm im coding is here and is algorithm 7.4.4(Ctrl-f it) Here is my cod...

 
 
2 hours later…
6:05 AM
I guess the question belongs to the code review portal of Stack exchange — Prashant 51 secs ago
 
0
Q: Allowing call lambda function through operator usage

Arthur Henrique Della Fraga I was thinking about a decorator which enable a lambda function to be called through a operation statement, in this example the @ one. How about this: def at(l): class At: def __rmatmul__(self, arg): return l(arg) return At() Here there is an executable exampl...

 
 
1 hour later…
7:31 AM
0
Q: React - Use default prop when prop is required

DDAMy code reviewer tells me to use a default prop when prop is required. I don't follow. If you use a default property on a required property then your property is in a way simply no longer required because it will have a value set that you pass a value to it or not. What do you think ? Progress...

 
 
2 hours later…
9:13 AM
0
Q: User Management Program

Dexter ThornMain Goal My goal is to create a chat app for my company (they are all software developers). I first make a console version and if it is working fine, I will make a GUI version. The program will run on an exchange drive, so using networking features is not neccessary. Project description The s...

 
9:34 AM
-1
Q: Move a let assignment to the top of a function

DDAMy code reviewer tells me to move the let assignment above the guard clause in the following code. That would force a variable declaration and an assignment even in the scenario of the code being stopped by the guard clause. Why would he think that way ? export const formatPhoneNumber = phoneNu...

 
 
1 hour later…
10:35 AM
0
Q: Is this a good way to process SQLAlchemy's uniqueness constraint violation in Flask?

art-solopovI'm using Flask along with Flask-SQLAlchemy and Flask-WTF. I have a model: class Trip(db.Model): id = db.Column(db.BigInteger, primary_key=True) author_id = db.Column(db.Integer, db.ForeignKey('users.id'), index=True, nullable=False) name = db.Column(db.Str...

0
Q: Python dnd dice generator

Carolusgot quick question. Did my small generator few month ago, now it seems to stopped working. can someone give me some advice how to repair it? Using Pycharm (newest version), python 3.7 as interpreter. The clues was to make it work in as little code as possible. import random Dice = input("Ch...

 
10:56 AM
-1
Q: Automatically run a function in google script when a new row is added to google sheet

Mahmoud BayoumiFrom my spreadsheet script editor I am using a script to submit data (emails) to the sheet. In the sheet I have two tabs: Sheet1: receives the new submitted emails Sheet2: sorts the emails in Sheet1 in a reverse order based on the Timestamp column so all the time in Sheet2 I have the last subm...

 
11:52 AM
If this is working code, and you just want tips on cleaning it up/making it more concise, please head on over to codereview.stackexchange.comMike 'Pomax' Kamermans 35 secs ago
 
12:05 PM
0
Q: How to correct typos?

cevingWhen I try to correct a typo, I get the following error: Edits must be at least 6 characters; is there something else to improve in this post? Are typos not worth to correct?

 
12:21 PM
You can use functional component instead. Also as Mike said it’s better to use codereview — Hamid Shoja 10 secs ago
 
12:34 PM
Monking
 
12:58 PM
0
Q: Is it a good practice to call another function inside a python function?

MehrabanSuppose I have functions a and b in my python program in which a calls b. If I want to test a, I should mock b or test them together (which is not a good idea for a unit test). But the dependency between a and b is not explicit. In OOP, if an instance of class A depends on an instance of class B,...

 
1:57 PM
If you have a working solution and are looking for improvements then Code Review is also a good place to ask (where you would post your code in the question). I would suggest to further clarify the constraints, such as if the number can be negative or not, and what @vacawama asked. — Martin R 38 secs ago
 
2:09 PM
I second MartinR's call to move this to CodeReview. My first thought is that it would be more efficient to search for subsets of 1 item, and then subsets of 2 items, etc. instead of finding all subsets and then finding the smallest. — vacawama 42 secs ago
 
2:20 PM
0
Q: Find minimum count of items where sum of them is X from an array

Mojtaba HosseiniI recently faced an interview question where you have to find minimum needed items from an array that can added together to generate X value. For example giving: [1, 9, 2, 5, 3, 10] and the goal is: 13, => it should be [10, 3] You can't use any number out side of array. I have tried to sort...

 
2:35 PM
Is this a common way to do this? I'm not sure if this worked completly. I do not have compiler errors, well, I had some but these are connected to the search function I guess. Is there a way to print out class values like all zipcodes or all citynames or stuff? So I guess it's more like a codereview atm — Stuckz 17 secs ago
 
1
Q: Python aiohttp extension

InyutinI made my first open-source project and wonder if I could do it better. I'll give briefly description, ask some questions and then post whole code. Open to any opinons and suggestions, thank you. So, Aiohttp is asynchronous HTTP Client for Python. You can find it's documentation here. However a...

 
BTW, the StackExchange code review site is here: https://codereview.stackexchange.com/drescherjm 14 secs ago
 
 
1 hour later…
4:02 PM
1
Q: C++ Linked list implementation using smart pointers. Advice on move semantics

Richard MaceAs an exercise to familiarise myself with smart pointers, I implemented a template linked list class in C++, closely following the very good tutorial at: https://solarianprogrammer.com/2019/02/22/cpp-17-implementing-singly-linked-list-smart-pointers/, which I duly acknowledge and from which I bor...

 
4:42 PM
0
Q: hi i'm learning php oop i was wondering if my isset to store user address and shipping addres could be shorter

jwdevso on my checkout page when i push final checkout i want to store my users, addresses, shipping addresses into Db iwas just wondering if this could be shorter users have multiple options 1 logged in where they use same or other shipping address 2 not logged in and they want to create account wit...

 
4:52 PM
@SᴀᴍOnᴇᴌᴀ Yes, I tried to make suggestions for making it self-contained, reviewable code, which OP did.
 
5:03 PM
0
Q: Sequences of given addenda whose sum is equal to a given number

Alberto CapitaniUtility to generate sequences of predetermined addenda that add up to a given number. There is also a function for orderly printing and one for converting list of lists in sequence of sequences. import Prelude hiding (null) import Data.Sequence (Seq) import Data.Sequence import Data.Foldable (fo...

 
5:23 PM
0
Q: Python: Working 2sum solver, but can it all be written in one line of code?

Travis WellsThis is my first working 2sum solver. It works by finding the difference for our target in s to determine if that 2sum exists. Suppose our target is -5. I start with the first index in s and use subtraction. (-5-(-8) = 3) And the result is 3. The code will check the difference in s. If the dif...

 
 
2 hours later…
7:15 PM
possible answer invalidation by Linny on question by Teodoro Bertolozzi Mendes: codereview.stackexchange.com/posts/236088/revisions
 
7:26 PM
1
Q: Chat Viewer working with files

Dexter ThornI am writing a textual chat app for exercise purposes. All Chatters using my program have access to a network directory, and there my program is stored. This chat app consists of three programs. The user management program allows you to create and delete users. The messaging program allows you to...

 
7:36 PM
Monking²
 
I'm voting to close this question as off-topic because open-ended questions about refactoring your code are off-topic for Stack Overflow, however they may be appropriate for Code ReviewSimple Lime 28 secs ago
 
8:05 PM
possible answer invalidation by DDA on question by DDA: codereview.stackexchange.com/posts/236142/revisions
 
8:27 PM
0
Q: PHPUnit tests for Symfony service

user217208I'm learning to write PHPUnit tests for my Symfony app. Currently, I'm writing tests for one of my service JokeService. I'm trying to test all it's public methods. This is the test file: public function testThatWeCanGetARandomJokeFromService() { $jokeService = new JokeService(); $joke =...

 
8:47 PM
0
Q: Graph coloring project in C++

Varad MahashabdeI recently had to submit my 12th grade final project in C++, so I decided to make a game engine! That panned out just as you would expect (I am not touching OpenGL until they touch OOP), so I switched and ended up making a project on graph coloring instead! For context, in the actual project thi...

 
9:04 PM
"I consider it as a good practice" -- why? If you cannot explain how this extra complexity and fragility benefits users, why would it be accepted in a code review? In general, the framework and libraries offers view recycling where such recycling is almost sure to be a benefit (AdapterView, RecyclerView, ViewPager, etc.). Everything else requires some amount of evidence that it would be worth the complexity. — CommonsWare 23 secs ago
 
-1
Q: Project Euler #44 - skipping differences

Jay P.Project Euler 044 The Python3 solution below returns the answer in less than 1 second. It relies on: $$P_{(k+n)} - P_k = 3kn + \frac{2n^2}{2} - \frac{n}{2}$$ and: $$P_{(k+n)} + P_k = 3k^2 + 3kn + \frac{3}{2}n^2 -k - \frac{n}{2}$$ Looking at the first line in the solution() definition, I am ...

 
9:25 PM
possible answer invalidation by Martin R on question by Mojtaba Hosseini: codereview.stackexchange.com/posts/236154/revisions
 
@Duga I have only fixed an obvious syntax error, and added a tag.
 
this sort of question is much better suited to codereview.stackexchange.comSam Mason 36 secs ago
 
 
1 hour later…
11:10 PM
0
Q: Struct data masking

P.S.i have a interface under development using an object-based approach. Objects should be statically allocated by the application writer (Dynamic memory allocation are not allowed). I want to obfuscate the object data so the application writer can only access the struct members using the provided me...

 
11:37 PM
"I worry there are cases where the function would result in undefined behavior that I am not seeing". A good way to handle that is to write unit tests to cover as many test cases as you can think of. If you want someone to review your working code then Code Review would be more appropriate than Stack Overflow. — kaylum 26 secs ago
 

« first day (2457 days earlier)      last day (1546 days later) »