« first day (2407 days earlier)      last day (560 days later) » 

12:00 AM
RELOAD! There are 6303 unanswered questions (90.0508% answered)
Q: Redux pagination transducer

Aaron BeallMotivation In our web app (React, Redux, TypeScript) we have a common need to write paginated API calls, with various UI interactions (infinite scroll, prefetch pages in the background, or manual page navigation controls). Rather than re-write pagination handling in every case, I wanted to creat...

12:23 AM
Q: Coding with python software and using .py files - security re internet attacks?

johnsmiththelirdcan somebody explain to me please: 1) Can a python ".py" file just by its mere "existence" on your hard drive (if not opening it), cause any kind of malicious harm for your computer system? And when your goal is only to see the content (text) of a .py file, how could you open it to be sure it c...

Q: Get resulting rectangle from two overlapping rectangles

WDUKI have a function that creates a rectangle from two rectangles that overlap, i was wondering if there is a smarter way to do it than lots of if statements that i currently have setup. This is my function public static bool Overlaps(this Bounds a, Bounds bounds, out Bounds result) { ...

1 hour later…
1:25 AM
Q: Handling singularities in squircle parametric equations

IamNotaMathematicianIn order to plot a squircle using its parametric equations: The equations can be found in page 9 of this this article: Fong, Chamberlain. "Squircular Calculations." arXiv preprint arXiv:1604.02174 (2016). Unfortunately the following singularities are not handled by those equations: Fo...

where are my hats?
1:46 AM
Q: Print input lines longer than 80 characters in C

kibeExercise 1-17 from the book The C Programming Language: 2nd Edition, K&R Full description: Write a program to print all input lines that are longer than 80 characters. #include <stdio.h> #define MAX_ARRAYCHARACTERS 1000 #define MIN_CHARACTERS 80 int main(void){ int currchar, // current c...

Q: Random Function Bias Tester

K00lmanI wanted to create a short little piece of code so that I could see the biases in the random function. import random import statistics import time num = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] average = [] while True: randomNum = random.randint(0, 9) num[randomNum] += 1 average.append(rando...

If you've got working code that you're wanting to improve, your question should be asked on Code Review, which was created for that exact reason. This site is for questions about issues with non-working code. — Ken White 11 secs ago
I'm voting to close this question as off-topic because it belongs on Code Review instead. — Ken White 47 secs ago
2:27 AM
Q: Advent of Code #4 in Haskell - Ascending digits with double digit

Steven FontanellaThis problem is from Advent of Code day 4 (part 2). The problem is to find the number of ints in the given range satisfying: all digits are non decreasing there is at least one group of exactly two equal digits in a row The main things I want to know about are whether there's a way to improve...

1 hour later…
3:29 AM
Q: Executing Scipy Tensor Product

John DoeCan anyone advise on how to use the TensorProduct function without having to explicitly indicate the full sequence of objects to take the product of. Below you can see one of my attempts. But the tensor products are still not coinciding, hence I am still having to write out the full sequence to g...

2 hours later…
5:28 AM
5:57 AM
Q: VBA More effective way of data trimming

lalalisaMy code consists of split, Mid,Left,Right and replace functions which is used to trim my data into a more neat manner, however it's too long and inefficient, it takes too much time to go through all this because i have up to thousand of files that will go through this. Can anyone advice me on ho...

Q: Usage of JS object in HTML, while attempting to loop HTML

RedThe CSS is unnecessary, as my primary focus is the interaction between the HTML, JS, and external resources. I've implemented a carousel that would be edited to consume well over 100 lines, so I thought of using a JS object to contain the data then link it to the HTML and display there. I have ...

6:12 AM
codereview.stackexchange.com might be a better place for this. Or possibly on SO as a self-answered question, or if there's an existing ARM bubblesort question maybe it could be an answered there. — Peter Cordes 15 secs ago
6:38 AM
Q: oracle of kevin bacon (erdos number) in python and sqlite. (perfomance issue)

Rishav ThakurImplemented oracle of Kevin bacon by creating an edge table between the id of movies and actors and BFS. The run time even for an actor with bacon number 2 is vast (>10mins). The SQLite query for getting neighbors of a node is also slow def get_neighbours(id): cur.execute("SELECT to_id FROM ...

6:57 AM
I think this question is more appropriate for Code Review Stack Exchange. — Nicholas K 56 secs ago
I'm voting to close this question as off-topic because this question is more appropriate for Code Review Stack Exchange. — Nicholas K 28 secs ago
7:11 AM
7:40 AM
posted on December 06, 2019 by CoffeeCups

I want to highlight table cells on mousedown/mouseover behaviour. So whenever I have the mouse pressed and hover over a cell, it shall be highlighted. In this simple example, there is a small issue: on every second click the mouse gets stuck with the disable-symbol (see screenshot), and the mousedown will not fire until I perform another click. See code and de

Q: Implementation of Conway's Game Of Life on Android

John CaseyI ended up using 2x 2D arrays with a one element border around everything to simplify the kernel logic. import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import java.util.Random; public class WorldSimulation { long generation = 0; int[][] ...

Q: To convert all the class properties to IDictionary<string, dynamic>

iSahilSharmaI have the requirement to return the result of my ViewModel as a Dictionary of KeyValue pairs. My view model comprises of multiple classes and can have null values in properties. I need to return only values which are not null and non-zero in case of double/string types. Following is the class I ...

@pacmaninbw @Heslacher let me know if the answer should be removed or not.
Somebody changed the VTC reasons...
Remind me I have to update my meta question about the close reasons now.
UWYA no longer exists.
replaced by "needs details or clarity" by the looks of it
similarly with too broad
7:48 AM
Probably a good idea, those changes.
> This question doesn't belong here because it is needs details or clarity.
@JAD well, this is up to you. Just a remark to your answer, you have totally missed the product.Tests == null condition of the original code.
@Heslacher hmm. I thought they were checking for productTests to be null, which makes more sense. I suspect that's a symptom of it being stub code
8:19 AM
@magnus specifying a TOP that is conceptually unnecessary may be an effort to achieve differences in query planning and permit tricks like order by in subqueries. The OP isnt really asking for a code review of his methods though — Caius Jard 33 secs ago
8:30 AM
possible answer invalidation by lalalisa on question by lalalisa: codereview.stackexchange.com/posts/233512/revisions
8:42 AM
Q: Is it a good practice to make one Spring bean inherit another one?

VitaliiIn my Spring Boot web application there are two beans, one of them inherits other one and both implements an interface. Something line this: @Component public class A implements SomeInterface { // .... } @Component public class B extends A implements SomeInterface { // .... } Is ...

9:01 AM
Note that questions about code improvements might be better suited for Code Review; that site is dedicated to these kind of problems. — Adriaan 22 secs ago
@Duga Fine
9:30 AM
Use dev branches for each person or feature, use pull requests to merge to main branches, use code review to enforce code styles (including syntax, Python2.7 already used some Python3-compatible syntax, so using it would help ease the transition). — h4z3 57 secs ago
9:44 AM
Q: Feedback on reactive operator for distinct values that must change by amount

Magnus LindheI would like feedback on this DistinctUntilChangedBy operator for System.Reactive that only emit when the current value is different than the last by a specified amount. Is there a better implementation? I want to avoid multiple emits when the stream looks like this: 0.80, 0.81, 0.80, 0.81, etc....

10:08 AM
@Moshi short code constructs do not necessarily mean they are better to read and maintain. And the || operator in js is just such a thing, in many cases it seems as if it is clear what is mean, e.g. that it is used to define a default value. But using it for a default value does not work for every case, so you always need to think about if it is valid to use it in that case, and in a code review you will always need to double-check if the || is valid. — t.niese 46 secs ago
10:46 AM
Q: Advent of Code 2019 Day 6 - Beginner Rust solution

saidaspenI am doing Advent of Code 2019 in order to learn Rust (it's been fun, but challenging!). I am looking for help and feedback from more experiences Rustaceans on my solution to Day 6: Universal Orbit Map in Rust. Specifically I am looking to see where I am not doing it the idiomatic Rust way, w...

11:07 AM
Q: Deconstruct tuple and store each element into a List of their respective element type

ExOfDeI encountered a use case where it was needed to store each element of a tuple into a list of their respective type of the tuple element. To streamline this feature I wrote a method extension that I overloaded for different sized tuples. The code is quite basic and does not do a lot but I thought ...

Q: Getting equals function working for a C# calculator

KyleSo I was tasked with making a GUI calculator in C# (without using any data structures like a stack) that allows the user to enter in an expression but I am having trouble getting the equals function to work. Whenever I press equals, it will not process the last number in the expression. Also, c...

possible answer invalidation by Mast on question by lalalisa: codereview.stackexchange.com/posts/233512/revisions
@CaptainObvious broken
11:30 AM
@Duga Shaddap
11:45 AM
@Heslacher also looks like homework given the namespace
Q: Find number of horizontal brush strokes to paint a skyline

David RefaeliAsked in interview today: You want to paint a skyline on your wall using only horizontal brush strokes. You are given an array of numbers, each representing the size of the column/building in that position. E.g. [1,2,1] - you can use two (horizontal) brush strokes. The first will paint the entir...

Q: Insert a digit to maximize the given number

David RefaeliWas asked in an interview today - You are given an integer (in finite range [-N, N]) and you wish to maximize the number by inserting somewhere the digit '5'. My solution - the idea here is going from left to right and checking if the digit is bigger than 5 or not. The first time you reach on...

Q: Chess Game: Part 1- Creating the Layout

TinManAfter working on the project for 15 hours of I had my layout set 1 row and 1 column per square, no problem. Then I decided that I needed each square to have multiple rows. I would have never guessed that it would take almost 6 hours to work this out. The Reason That I Changed the Layout I h...

12:00 PM
@CaptainObvious That could be interesting.
Q: Setting colormap for matrix in Matlab

amirI visualized the matrix eta2. eta2 is obtained by etas according to the below code. I'd like to set different colors for each of grains which are shown by imagesc. I tried colormap in Matlab, but it generates same colors for all of grains. I am looking for visualizing like the image sample attac...

12:20 PM
Playing solitaire with AutoCAD:
user image
@Mast I think something went wrong
@Mast PCB design or layout?
1:04 PM
It seems you don't have a specific issue here, you're asking for improvements to working code. If that's the case, Code Review would best be suited for this. — Çöđěxěŕ 27 secs ago
Q: Program in JAVA to calculate absolute age in years, months and days

Riley JonesThis code will accept from the user the current date, month, and year; and their birth date, birth month, birth year. It outputs the age of the person in years, months and days. I want to know: --How do I implement the Date class in Java to get the current Date, Month and Year? --How do I make it...

1:22 PM
@Mast Is it a beta version? That's definitely a bad error message to report to a user.
Almost as bad as "An Unknown error occurred. (yes I've put this one into code and it bit me in the behind).
I think this question is better suited for codereview.stackexchange.comRahul Bharadwaj 52 secs ago
@pacmaninbw No.
@pacmaninbw Mounting plate layouts.
@skiwi O RLY?
I hope your day improves!
Q: how do I make this code better in performance C#

Teun van den BroekI want to change this code. In this code you are supposed to copy twice a date, for example '06 - 12-2019 'and '06 - 12-2020' for example. After you have done that you will receive a notification with the days between those 2 dates. Now I noticed that if you have done that it costs 1.5mb ram whic...

Q: es6 mapKeys and mapValues

ThomasReggiconst mapKeys = (object: any, callback) => { return Object.assign({}, ...Object.keys(object).map(i => { return { [callback(i, object[i])]: object[i] } })) } const mapValues = (object: any, callback) => { return Object.assign({}, ...Object.keys(object).map(i => { retur...

@pacmaninbw It will, I'm about to head out. Weekend.
Hopefully the update will arrive within 2 weeks, we'll be going from 2016 to 2019.
Should have a couple of bugfixes.
And probably new bugs...
1:37 PM
@Mast I think you can count on those.
1:50 PM
possible answer invalidation by Zack E on question by Zack E: codereview.stackexchange.com/posts/233488/revisions
If you want help improving working code you should post this on CodeReview.SE. If you do decide to do so please delete the question here. — NathanOliver- Reinstate Monica 27 secs ago
2:13 PM
Q: Allocating 2d array (type char) to prepare memory for float calculation

equusFirst I have to input size of 2d array (n and m), and position of professor and strictness of prof. Then I have to scanf matrix. My problem is that i have type char matrix but I need to cast matrix into float because I need float numbers. for(i=0;i<n;i++) { for(j=0;j<m;j++) ...

Q: Advent of Code 2019, Day 2 [Haskell]

Børge André JensenThis is my solution for Day 2 of Advent of Code 2019 It's the eval function I want to get reviewed. Is this acceptable Haskell-code? Is it even close to being idiomatic? Also, is it OK to leverage laziness this way? Any tips on how to improve it would be very helpful in my path to Haskell-enli...

It seems to me that some changed the reasons for closing.
2:54 PM
Q: Optimizing Hash Table

Данила МишинI try to write my own implementation of hash table (hash map) on C++. It turns out that my code is unoptimized as I cant pass performance tests. Can you please give some advice for optimization of the program I am using open adressing for resolving collisions with quadratic probing. Hash functio...

3:20 PM
possible answer invalidation by Steven Fontanella on question by Steven Fontanella: codereview.stackexchange.com/posts/233504/revisions
Maybe more suitable for codereview.stackexchange.com :) — CDJB 32 secs ago
3:46 PM
Ryan Donovan on December 06, 2019

Stack Overflow and our Exchange sites get some great questions and answers. We think the folks from our community who share knowledge should be celebrated. So we’re introducing this bi-weekly roundup of questions that tickled our fancy. Want to give attention to a great question and/or answer? Tweet it with the tag #StackOverflowKnows and we’ll consider them for future installments of this series. 


How is it possible for an autonomous differential equation to hit infinity in a finite number of steps? What sort of mathematical wizardry is this? Is the math wrong, or  …

4:06 PM
Without a specific question, this may be more appropriate for codereview.stackexchange.com — chepner 9 secs ago
4:30 PM
@Duga that is okay - it appears to be sample input added
actually there was a slight change to the code
OP changes from source from "Advent of Code day 4 (part 2)" to "Advent of Code Day 4 (part 1)"
I'm not sure how to proceed
should the change be rolled back?
Hi. If I understand correctly, your code works fine and you're looking for feedback? codereview.stackexchange.com might be more appropriate. — Eric Duminil 27 secs ago
4:58 PM
Q: Dynamically create array with nested objects/array

CoffeeCupsI need help to dynamically create an array with nested objects holding again an array of objects each. The structure is as follows: tiles=[ { "row": [{isChecked: true, src: ''}, {isChecked: true, src: ''}, {isChecked: true, src: ''}] }, { "row": [{isChecked: true, src: ''}, {isChecked:...

5:19 PM
Q: Thread Pool in C for web server

Anmol GautamPlease review the following code for thread pool in C (I wrote it to implement a threaded web server for my personal project). I have been programming in C++ and Java but never did any serious programming in C. threadpool.h #ifndef THREAD_POOL_H #define THREAD_POOL_H #include <pthread.h> #def...

possible answer invalidation by Linny on question by Данила Мишин: codereview.stackexchange.com/posts/233545/revisions
5:58 PM
@Duga looks to be okay - code fence format fix
Q: Correcting order and fixing duplication for my C++ solution to 3sum

Permianclass Solution { public: vector<vector<int>> threeSum(vector<int>& nums) { vector<vector<int>> results; for (int i=0; i<nums.size()-1; i++){ set<int> s; for (int j=i+1; j<nums.size(); j++){ int x = -(nums[i] + nums[j]); ...

1 hour later…
7:03 PM
What is your question? If you just want your code reviewed, go to codereview.stackexchange.comNotZack 30 secs ago
As interesting as the question is, questions about improving working code are better on Code Review rather than Stack Overflow. — halfer 12 secs ago
7:43 PM
Q: Do I have to type math.sqrt() every time rather than just sqrt() etc?

thewonderfulwizardofozPossibly a bit of a silly question; I did some basic Python stuff a few years ago and I remember having to type import math, import random etc. at the start to use the functions etc. from these packages. This time round it seems like I have to type math.sqrt(3) rather than just sqrt(3) each time...

The candidate needs a fix in his code. It is not really a code review. — Sunil Chakravarthy 41 secs ago
8:17 PM
Sidenote: You can eliminate those gotos by putting in an extra function that returns on error. goto is hard to get right. It's harder to prove that you got it right, and it's next to impossible to prove to other people that you got it right and that it's justified. It's such a waste of time trying to get goto through a code review that I avoid it even when I know that it makes the code better unless I have an iron-clad argument. That hasn't happened in decades. — user4581301 1 min ago
"This code works as expected. But is it a good practice to use this method?". Please note that such questions are better suited to [codereviews.se]. You may want to split out your question so that the first one goes to Codereviews with the second one retained here. — kaylum 14 secs ago
If you want help improving working code you should post this on CodeReview.SE. If you do decide to do so please delete the question here. — NathanOliver- Reinstate Monica 14 secs ago
8:45 PM
Q: Clean way to couple elements C++

PhastasmI am currently in development of graph visualization tool. I have implemented classes Node and Edge, which are responsible for drawing said objects on plane, given coordinates. Now as I want to implement Graph class I will need to tie nodes with corresponding edges. I have a lot of ideas how it ...

9:27 PM
Q: Reading in Json file data, better way to declare all these structs?

user214533struct TranslateFrame { float duration = 0.0f; float tweenEasing = 0.0f; float x = 0.0f; float y = 0.0f; }; struct RotateFrame { float duration = 0.0f; float tweenEasing = 0.0f; float rotate = 0.0f; }; struct AnimationBone { std::string name = ""; std::vector<...

9:47 PM
Q: Calculate an offset between base and derived classes

Kaneboost::serialization contains this code: reinterpret_cast<std::ptrdiff_t>( static_cast<Derived *>( reinterpret_cast<Base *>(1 << 20) ) ) - (1 << 20) Its purpose is to calculate an offset between base and derived classes. Apparently, this code contains an undefined behaviour or ...

10:08 PM
Q: Printing text based on divisibility of number

user_xtech007The below piece of code will print a text based on the divisibility of number. Here if the number is not divisible by 3,5 and 7. Then it gets printed out. Does making use of f string make the type caste of integers to string implicit ? def convert(number): result = "" if (number % 3 == 0): r...

I'm cool, thanks. Note that if your code works this is better posted on codereview.stackexchange.comRaySteam just now
possible answer invalidation by ExOfDe on question by ExOfDe: codereview.stackexchange.com/posts/233528/revisions
10:26 PM
An off-by-one error in Excel, fun.
@Duga Yes, thank you.
O22 should link to Aardappels in D9, but it's clearly not.
Note the formulae in M, N, O are really array formulae { }.
And yes, this would be easier in VBA. But I'm positive this can be done without.
10:45 PM
I'm basically flattening a 2D array to a 1D array.
you mean a list?
I'm not up-to-date with Excel terminology, but sure, probably.
And I thought the following would fix it. In text, M, N O
{=IFERROR(INDEX(C$9:C$17; MATCH(0; IF(COUNTIF(M$21:M21; C$9:C$17&"")<COUNT($8:$8); 0; 1); 0)); "")}
I was joking without getting context
very dangerous
{=IF(LEN(M22); INDEX($D$8:INDEX($8:$8; MATCH(1E+99;$8:$8 )); ; COUNTIF(M$22:M22; M22)); "")}
{=INDEX(C:P; MATCH(M22;C:C;0); MATCH(N22;$8:$8; 0))}
@Malachi Excel is also very dangerous :-)
Index Match combinations are bloody opaque in the best of times, try combining a crapload together in array formulae and it's somewhat tricky to keep track.
11:03 PM
is it still September?
@RMunroe If only
I'm probably doing something very stupid wrong. This is going to take a while.
Always the same thing with array formulae and Excel.
11:37 PM

« first day (2407 days earlier)      last day (560 days later) »