12:00 AM

0

Motivation 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
0

can 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...

0

I 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
0

In 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
1

Exercise 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...

1

I 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
0

This 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
0

Can 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
Monking

5:57 AM
0

My 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...

0

The 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
0

Implemented 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
Monking

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

0

I 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[][] ...

0

I 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.

Monking

UWYA no longer exists.

replaced by "needs details or clarity" by the looks of it
similarly with too broad

7:48 AM
Yup.
Probably a good idea, those changes.

> This question doesn't belong here because it is needs details or clarity.
perfect

@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

exactly

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
0

In 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
0

I 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
0

I 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
0

I 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 ...

0

So 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

11:45 AM
@Heslacher also looks like homework given the namespace

1

Asked 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...

0

Was 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...

0

After 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.

-1

I 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:
3

@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

0

This 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!

0

I 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...

0

const 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...
5

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
0

First 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++) ...

0

This 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
0

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.

(math.stackexchange.com)

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
0

I 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
0

Please 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

-1

class 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
-2

Possibly 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 `goto`s 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
-1

I 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
-1

struct 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
0

boost::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
0

The 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
Heh

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 :-)
4
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

ROLFMBO

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