« first day (2231 days earlier)      last day (1791 days later) » 

12:00 AM
RELOAD! There are 6088 unanswered questions (89.8785% answered)
 
12:53 AM
-1
Q: I want to write make my code in more simplified manner in C#

AayuI want to simplify below code. That code is working but I want to simplify it more. Please forgive me if I am not allowed to ask this question then. I am happy to delete it if it needs to be then. The below code is working but I want to simplify it as much as I can. I tried this way. Can anyone p...

 
1:13 AM
0
Q: Python program to solve Puzzling problem 84854

Alex FI saw this Puzzling problem and thought I would try to write a python program to solve it. But turns out I don't know how to optimize recursion, so I'm posting here for help. I'm mostly just confused on why the code to change the past needs to be at the top of the function, but I would also like ...

 
1:26 AM
Hey @Mast, if you want a fun story about a German engineering company that happens to rhyme with 'leemans' that cost me weeks because they built one MCU in the 80's with a crap architecture that nobody bought but those who did fought, here's a fun thread: twitter.com/EBrown8534/status/1138976085708857344 (WARNING: LOTS OF FOUL LANGUAGE)
I don't miss the plastics factory.
 
1:54 AM
@altocumulus, if it's you that demoted this question, please fix that. As you can see I have provided full code, and as you can see from the accepted answer, this is not about code review but about how to use D3. — NeilG 7 secs ago
 
2:47 AM
I've never understood the reluctance. The only reader who could be puzzled by !! is one who has never seen it before. So he asks a colleague who tells him "you use it to convert an integer to 1 or 0" and now he knows the idiom forever. I constantly get dinged on this in code reviews (different companies each time) and the reviewers constantly cite an arbitrary employee-to-be-hired-in-the-future as the one who won't know about !! but can never point to anyone who actually doesn't know, or who, after having it explained, won't remember it. (Example is old though: not needed in modern C++) — davidbak 44 secs ago
 
2:59 AM
I saw if (blah == true) in a code review, I'd call the programmer on it. As bad as if (blah) return true; else return false;. — Eljay 27 secs ago
 
3:55 AM
@DerKommissar Hahahaha, yes, that's C. As many bugs and UB as features and back in the day it was much worse.
 
i've used !! myself earlier but nowadays I find it bad practice, especially after having to explain it in code reviews many times ;) — Anders 35 secs ago
 
4:22 AM
Oh well, different times.
Monking all
 
 
1 hour later…
5:32 AM
This code seems to work, so I'd say it's more suited to Code ReviewVLAZ 35 secs ago
 
 
1 hour later…
6:39 AM
0
Q: Why is my header not collapsing?

PreefixI tried to make a collapsable header with an animation where the title animates into the nav bar when the user scrolls up. It is working fine when I use a table view but unfortunately it does not work with a container view instead. I guess the problem is that my container view is not embedded in ...

 
6:59 AM
1
Q: Enumerate all members and types with specific attributes

t3chb0tI have a use-case where I need to retrieve all members with specific attributes in the class and interface hierarchy - I usually need the first match and apply its rules to child members. The built-in GetCustomAttributes are too limited becuase they work only for a single member and don't support...

 
I'm voting to close this question as off-topic because the code works, The OP just want us to review it. It should be posted over at Code Review instead since SO is for when you're having issues with your code. — Magnus Eriksson 6 secs ago
Code review questions should be submitted here: codereview.stackexchange.com. Voting to close as off-topic. — rghome 38 secs ago
 
7:19 AM
-1
Q: Assigning variable value: check if not equal necessary?

Michael BalserConsider the following code: // variant 1 if (clearPattern) { clearPattern = false; } // variant 2 if (numericValue != newValue) { numericValue = newValue; } Are the conditional checks in this case really necessary? I mean if condition is satisfied, assignment will happen. If not sati...

 
7:32 AM
While I like your solution, this isn't a code review site so it's a little too ambitious — Joakim Danielson 47 secs ago
 
0
Q: Thread-safe stack in Java

user5447339 Implement a multi-threaded stack, with freedom to use existing implementations of stack. On top of being thread-safe, it must block (not busy-wait) a pushing thread when stack is full and a popping thread when stack is empty. It must signal the threads out of sleep when stack has space...

0
Q: LeetCode: Remove Duplicates from Sorted Array

GiladPlease review for performance https://leetcode.com/explore/featured/card/top-interview-questions-easy/92/array/727/ Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another arr...

 
7:59 AM
0
Q: LeetCode: Best Time to Buy and Sell Stock II C#

Giladhttps://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ Please review for performance. Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like ...

 
8:14 AM
To me this question belongs more to Code Review SE forum, not StackOverflow. — sophros 59 secs ago
 
8:39 AM
0
Q: pivotfield.orientation = xlhidden does not work

DutchArjoI have a vba code which checks all the pivots in specified worksheets to add a range of pivotfield to the values/data section of the pivot because the pivot headers change every 4 weeks. I have 6 pivots where this code works perfectly, but 2 pivots where I keep getting an error. I have tried t...

 
8:59 AM
0
Q: Loop on dataframe takes a lot of time

Zedi10The dataframe subset feature is being used in a for loop across the dataframe rows. The result seems accurate however, the time taken to complete the loop on 2000 odd rows is more than 4 minutes. Any advice or guidance on the quality of the code? Datasets: DF1 input customer_id 31-12-2019 00:...

 
9:19 AM
0
Q: PHP LDAP credentials validation and error handling

Jh62I developed this group of scripts to validate users againts a LDAP server and presenting the appropiate message to the user after sending the information. I wonder if I'm handling everything properly according to best practices. I'll appreciate any advice on how to improve the code in order for ...

 
10:11 AM
Is the only question "are there any corner cases where this would not work"? If that is the case, consider compiling a working example with test cases and post on Code Review. — L. F. 35 secs ago
 
10:39 AM
1
Q: Improving File Handling And Status Messages in C

NickDeltaI have completed an university assignment on C. While the code is fully functional based on the specifications of the exercise, I like high-quality code and would like to ask for opinions on how can certain parts of it be improved. Be advised that I cannot change any function signature. The fir...

0
Q: OOP in PHP. Exercising on creating a blog

LetsSeoI am attempting to do object oriented programming in right way, and appreciate any review to see if my approach is correct. class_blogpost.php as below: <?php class BlogPosts { function __construct() { # code... } public function ListAllBlogPosts() { $DB = DatabaseFactory::getFactory()->

 
10:59 AM
0
Q: 100-doors puzzle

EMLHere is a very simple solution to the 100 doors challenge You are in a hotel with 100 doors. Initially every door is closed. On the first round, you change the state of every door (if it is open, close it. If it is closed, open it). On the second round, you change the state of every second do...

 
11:39 AM
0
Q: Toggling a class in JS

Emilio ConteI'm toggling the class of an element with this code but I'm pretty sure it can be written more efficiently. $('.expandable_header').click(function() { toggle_expandable_icon($(this).find('i')[0]); $(this).nextUntil('tr.expandable_header').slideToggle(100, function(){ }); }); functio...

 
possible answer invalidation by Hugo Cox on question by Hugo Cox: codereview.stackexchange.com/posts/222154/revisions
 
11:58 AM
@Mast Much, much worse....
 
0
Q: Replace values in R data frame according to values in other data frame

NathaI would like to change row names values from a first data frame if these rows names are present in another data frame, and change it to a corresponding value (defined in the second data frame). I could do it with a for loop, but I wonder what would be some other more suitable ways to do it in R. ...

 
12:20 PM
possible answer invalidation by Hugo Cox on question by Hugo Cox: codereview.stackexchange.com/posts/222154/revisions
 
12:58 PM
0
Q: Max function with variable number of arguments

Alexandru IcaI find it irritating that in standard c++ I can't do std::max(a, b) = x when it's possible and that it can't handle more than 2 arguments. For the second concern I found this: https://www.youtube.com/watch?v=z_fnMdzfWAQ&t=266s and it looks interesting but the usage of pointers confuses me because...

 
1:38 PM
-1
Q: exception : connection reset in java if the response take more than 5 min from client using httpclient get request

red foxGetting Expection connection reset when using httpclient to get response from REST API ,which takes more than 5 minutes for respose. Using java 1.7 when i tried with postman , getting response after 6 min . could you please help me to resolve the issue . //////////////////////////////////////...

 
1:58 PM
0
Q: Check if integer equals sum of its digits to the fifth power

Josh FriedlanderI can do this in one line in Python: sum([i for i in range(9,9999999) if i == sum([int(x)**5 for x in str(i)])]) Not very fast, but works nicely. I thought it might be quicker to do in Haskell, a language I'm quite new to: -- helper func toDigits :: Int -> [Int] toDigits 0 = [] toDigits x...

0
Q: Better approach of using instanceof to search for an object

Nick ParsonsCurrently, I'm performing a linear search on a list of items like so: private Item getKey(ArrayList<Item> inventory) { for(Item item : inventory) { if(item instanceof Key) { return item; } } return null; } I've heard that it is considered a "code smell" ...

 
2:14 PM
Seems to me you are looking for a code review. That would be better suited in codereview.stackexchange.comSuraj Rao 51 secs ago
 
@CaptainObvious Off-topic either too broad or lacks concrete code.
Never mind, deleted by poster
 
2:39 PM
0
Q: Haskell API for manipulating Tree/Forest

Alberto CapitaniI'm experimenting how a Relation (a cartesian product's subset) can be implemented in Haskell using different data classes. Forest and Tree allow to keeps together in a single data structure different relations each one of different n-arity. This set of functions require only the Eq constraint ...

1
Q: Console arkanoid in C

gaazkamOn an Internet forum a person came with their homework, to write Arkanoid in a console - it seemed they wanted someone to do their homework for them so I did not respond. However, I found the task interesting, especially when I broadened the scope of the assignment - so I wrote such arkanoid for ...

0
Q: Access object in an custom attribute efficiently

WebwomanIm trying to access the attribute directly in the parent component, that why Im using the ref method. here an example of why Im trying to achieve: https://stackblitz.com/edit/react-lupsr2 Im accessing it using some for in loop currently, so far it works, although I think there is probably more ...

 
2:59 PM
0
Q: Fastest path on a snakes and ladders board

EMLI am not looking for a detailed review of this code as I am aware it is very inefficient. The main reason for posting this is to see if there is a better way to achieve my goal (I am certain there must be) I have created code to find the fewest number of dice rolls that would permit someone to m...

 
3:36 PM
@Duga rolled back
 
I'm afraid that question is out of scope for SO, as it is primarily opinion based and there are many ways to design your application. If you're unsure about some implications of your choice then you might be better of asking at codereview.stackexchange.comThomas 34 secs ago
 
Hmmm... this post was marked as a duplicate of this one... while both involve toggling class names on elements the code is drastically different
I voted to reopen and see somebody else has :)
 
3:58 PM
Greetings, Programs.
 
0
Q: If Check Efficiency

David WhiteBelow is a segment of a game I am writing to stay in practice with my Java. There are two ways I am thinking of implementing a combat system, but I am not sure which path is more efficient. The code works perfectly fine; I am only inquiring about the efficiency: Option 1 public static void mana...

 
@SᴀᴍOnᴇᴌᴀ That's crazy. How can code from two different people every be "duplicate" unless one is blatant plagiarism? In which case it's off topic (not the author rule).
 
good question
 
@SᴀᴍOnᴇᴌᴀ Wat. IIRC community means the OP VTC as a duplicate too...
 
we need a fundamental theorem of code review duplicate
 
4:09 PM
Monking
 
I marked it as a duplicate
 
That's not how duplicates work on CR
 
I find conflicting information about duplicates in the meta
So a dupicate must come from the same person?
 
12
A: Harmless duplicate or are we being taken advantage of?

200_successWell, whatever it is, it is certainly not a duplicate. The follow-up question asks about the proper use of divs and spans; the original question contains no spans. I agree that it is rude to ask a follow-up question without adding mutual links, because that wastes other users' time. However, t...

That isn't the defacto but relevant
20
Q: How do we define duplicate questions?

Joe PhillipsThis QA site doesn't quite take the form that others do. Here, we have fairly specific questions. But I already see two Project Euler #1 questions that are similar. Are these duplicates?

 
Alright, I will adhere to these guidelines.
Keep a note, though, that it isn't clear from this post: codereview.stackexchange.com/help/closed-questions
 
4:19 PM
@dfhwze I'd suggest asking, on meta, to change that and the linked duplicate page to be inline with our rules.
Currently those pages look unhelpful and somewhat confusing, as it doesn't really say what duplicates are. Just some fluff about duplicates.
 
4:33 PM
0
Q: Out-dated definition duplicates in Help Center

dfhwzeWe recently had a discussion in The 2nd Monitor about a post being flagged as a duplicate. I had flagged it based on a Rule I found in the Help Center: This question has been asked before and already has an answer. If those answers do not fully address your question, please edit this ques...

 
2
Q: Out-dated definition duplicates in Help Center

dfhwzeWe recently had a discussion in The 2nd Monitor about a post being flagged as a duplicate. I had flagged it based on a Rule I found in the Help Center: This question has been asked before and already has an answer. If those answers do not fully address your question, please edit this ques...

 
@dfhwze Thanks for your honesty
 
Anytime!
 
I did the same thing a couple years ago
 
@dfhwze Hope you don't mind my edits, if you think I've messed up your post feel free to edit it back.
 
4:38 PM
Nah, looks better now ;-)
Let's wait and see if this post goes anywhere.
 
0
Q: Try Parse Multiple Types

Michael ZiluckI am trying to write a method takes in a String and returns an Object. The catch is I want to parse it to one of a few different data-types, and if that fails, return the original String. I currently have the code below. Is this the best way to handle what I want or is there something obvious tha...

 
@dfhwze If it gets another up vote it should go featured, and then it defo will.
 
 
1 hour later…
5:40 PM
0
Q: Async on Rails in F#

Henrik HansenHaving these rather useless test functions: let rand = new Random(); let collectValuesAsync = async { printfn "Collecting Values..." let count = rand.Next(10, 15) let values = List.init count ( fun i -> async { ...

 
6:00 PM
0
Q: Mixed-width operations for std::bitset

Toby SpeightWhen I was looking to use std::bitset instead of GCC's __uint128 in my RDS error-corrector, I found that it was hard to use, because there's no way to widen or truncate a bitset to one of another size. Nor is there any ability to do bitwise arithmetic (&, |, ^) or comparison (==, !=) with a bits...

 
7:34 PM
you might want to move this question to codereview.stackexchange.comsweaver2112 42 secs ago
 
@DerKommissar Yea. Honestly, I don't miss it. Currently I draw electrical schemas for big-ass machines and that has it's quirks, but it's hardly ever undefined.
@CaptainObvious Put in the final nail. Took way too long, we need more people at the review queues.
 
7:48 PM
hey guys
been a while since I reviewed some C# Code, I want to make sure I am not being a noob....
can someone tell me if these two code snippets are comparable?
foreach (var dictionary in dictionaries)
{
    for (i = 0; i < dictionary.Dictionary.Count; i++)
    {
        maxValue = dictionary.Dictionary.First();
        for (j = 1; j < dictionary.Dictionary.Count; j++)
        {
            var valuePair = dictionary.Dictionary.ElementAt(j);

            if (valuePair.Value > maxValue.Value)
                maxValue = valuePair;
        }
    }
    var valToSet = maxValue.Key.Item;
var valToSet = dictionary.Dictionary.maxValue;
 
First, I’d move the code for configuring the cells into the cell subclasses to avoid cluttering the cellForRowAt. Second, I’d transition the model retire arrays of arrays of strings for custom types for which the values would be self-evident. We can probably show how to clean this up, but your model isn’t entirely clear so it’s hard to get more specific. I might suggest posting a MCVE to codereview.stackexchange.com. — Rob 1 min ago
 
8:12 PM
@Malachi Eh, if they are, the latter is probably a major improvement. You could run some tests against it.
 
I saw that. and I was like..........
 
I don't C#, perhaps I need glasses.
 
lol
I thought you were a C# person?
 
wouldn't var valToSet = dictionary.Dictionary.maxValue; still need to be within the foreach?
 
@SᴀᴍOnᴇᴌᴀ it would still be inside the foreach
there is more code afterwards
I have an if statement I am trying to make nicer also
 
8:15 PM
@Mast Do you have something that notifies you? Or do you just look every now and then? I've tried Malachi's notifier, but it doesn't notify me... :/
 
@Mast That's a good pun-ch :D
 
<obligatory-gif-of-chandler-bing-saying-I-knew-it.gif>
 
@Peilonrayz it has been broken, and I haven't had a change to look at it lately
I think it was something in an update.....I am totally guessing (Chrome or ....)
 
@Malachi Fair enough, I was going to build my own after I've finished a couple of other projects
It'd be cool to get a nice number to show up in the top right when browsing SE
 
@Peilonrayz I have a github project set up
you won't have to start from scratch? but maybe you want to, idk?
 
8:21 PM
@Malachi Ah cheers, was starting the search for it, :D
@Malachi Probably a good idea to not start from scratch, but then again where's the fun, ;P
 
I started from something Simon started I think.
 
@Malachi Meh? No, I'm an Elecrical Engineer.
We can C# if we have to, but we don't if we don't have to.
 
lol, I am a QA Lead, I have to C# but not in the all senses of the words.
 
@Peilonrayz I live here.
I eat notifications for breakfast.
7
 
@Mast That I can believe XD
 
8:40 PM
@Mast I used to be just like you, but then I took an arrow to the knee
 
0
Q: LeetCode: Intersection of two arrays ii C#

Giladhttps://leetcode.com/problems/intersection-of-two-arrays-ii/ Please review for performance, I am having a problem with using TryGetValue, if someone can explain how this can be used in here. Given two arrays, write a function to compute their intersection. Example 1: Input: nums1 = [1,2,2,...

 
another C# question, ahhhh but I gotta get back to work.
if anyone wants to make fun of my puny answer --> codereview.stackexchange.com/a/222246/18427
 
First, I’d move the code for configuring the cells into the cell subclasses to avoid cluttering the cellForRowAt. Second, I’d transition the model from arrays of arrays of strings to custom types for which the values would be self-evident. We can probably show how to clean this up, but your model isn’t entirely clear so it’s hard to get more specific. I might suggest posting a MCVE at codereview.stackexchange.comRob 13 secs ago
@Rob This question looks like it's lacking in code already. Whatever you do don't post an MCVE at Code Review as that will only get downvoted and closed. If you do want to post a question like this at Code Review you should ensure you include everything you want reviewed, and everything is working as intended. — Peilonrayz 58 secs ago
@Peilonrayz - I agree. That’s what I was trying to say when I suggested that this was unclear and that he should instead post a “MCVE” (because this example is neither complete nor verifiable; the model structure, in particular, seems very unclear to me). But once he pulls together a better, more representative example of his code, Code Review in a more appropriate forum for that sort of question than is Stack Overflow. — Rob 6 secs ago
@Rob The "E" in MCVE 100% off topic on Code Review. The "M" leads to questions being either off-topic or barely on-topic on Code Review. In the future, please don't recommend writing MCVE's for Code Review because of this. Otherwise I agree, if they pulled together a better sample of code then it could make a good CR question. — Peilonrayz 18 secs ago
 
9:01 PM
0
Q: Crystals Collector game with four clickable buttons

njbootI'm a few weeks into javascript and had to make a simple "crystals collector" app. The app works as intended, but the code is obtuse and repetitive. I'd like to make the app work using just one on click event, rather than using four for each crystal. I can't make an array of each color crystal a...

 
9:18 PM
@Peilonrayz - I respectfully disagree. Good Code Review questions are always examples and minimal in nature (we don’t want the full project). So, it should be “real, concrete code” from actual projects, but it should also be free of unrelated cruft. The key is that it should be, using the terminology from Code Review: What topics can I ask about here?, a “working piece of code”, which this obviously is not. — Rob 54 secs ago
 
9:33 PM
@Rob Example code is not real code and the post size was increased to accommodate larger questions on Code Review. Given one of my old meta answers which answer a question that ~400 lines of code is fine for Code Review has been fairly highly upvoted, and as a regular of the site I can say minimal questions are liable to being closed as as LCC. So no, we don't want minified examples. — Peilonrayz 46 secs ago
 
2
Q: Disambiguate 'rop' tag

Toby SpeightI see rop was recently added, to refer to "Railway-oriented programming" (which I have to admit was new to me, not having come across the term when I was using functional Scheme). However, the initials ROP have other uses, notably "Return-oriented programming", so perhaps this name isn't the bes...

 
10:01 PM
1
Q: Shortest pathway across a snakes and ladders board (Update)

EMLEarlier I posted a fairly inefficient recursive solution to the problem of getting across a snakes and ladders board in the smallest number of moves. I have created a much faster solution to this using Dijkstra's algorithm and I believe it is correct. Each square on the board is linked to any ...

 
10:15 PM
possible answer invalidation by David White on question by David White: codereview.stackexchange.com/posts/222229/revisions
 
11:02 PM
0
Q: Concurrent Queue Adapter

rsjaffeThere's lots of code out there for basic adapters of std::deque to provide a thread-safe queue. I've adopted that, but wanted to provide a relatively full analog to std::queue, so I've added the whole set of constructors and operator=. The queue works fine. My questions are mainly related to the ...

 
11:58 PM
@Duga 200_success asked for the complete code and that is what the OP did
 

« first day (2231 days earlier)      last day (1791 days later) »