Code Review Weekly Newsletter

Code Review newsletter

Top new questions this week:

Overlapping rectangles: Interview Question

Got the following question in a technical interview today (for a devops/SRE position): Write a function which returns true if the two rectangles passed to it as arguments would overlap if drawn on a …

python interview-questions conditions collision computational-geometry  
asked by Jim Dennis 7 votes
answered by Peter Taylor 2 votes

Improving while loop and lots of variables

How do I improve this code to remove all of the extra variables and make it easier to read. get_item_count calls to an API and gets a count and there are several pages to get this count from until …

ruby  
asked by Kieran Andrews 6 votes
answered by Kieran Andrews 2 votes

How to avoid duplication and to keep code clean

Here is my C# code that draws scanline of the image to System.Drawing.Graphics. It's quite simple and it's optimized in order to merge neigbour samples with the same color into single rectangle …

c# loop dry  
asked by Vitaliy Shibaev 6 votes
answered by Rene Saarsoo 4 votes

Toggle script trouble

I have been working on a toggle script, but I find myself repeating my code. Is there a way of combining it all? I am new to jQuery, so forgive me for my beginner question. HTML: <div …

jquery html css beginner  
asked by Jonathan 79 5 votes
answered by bjelli 3 votes

Can I get some tips for improving my tokenizer design?

I need some tips on how to improve the design of the following code. Everything works correctly in the program. It takes a string and shows each token the only tokens being numbers and operators. The …

java design parsing  
asked by Daniel 5 votes
answered by amon 1 vote

Complex logic that I'm certain can be simplified

This is code from a grappling hook implementation. This is specifically code that, after a block is detected between two way points, it tries to find a path around. This particular piece of the …

c++ computational-geometry  
asked by OmnipotentEntity 4 votes
answered by 200_success 1 vote

How can I optimize this array operation for speed in Python

I've been trying to take image pixel data and write it out into printer code and my results are rather slow. Here is a asimplified version of what I have so far (image is a PIL Image object of 1200 x …

python strings optimization  
asked by Octopus 4 votes
answered by Martijn Pieters 3 votes

Greatest hits from previous weeks:

Java function to read a CSV file

I have a java function that reads a csv and returns its content as a Vector<Vector<String>>. The function seems to work as I need it, but my gut feeling says it could be better (never …

java array csv vectors  
asked by René Nyffenegger 12 votes
answered by Óscar López 11 votes

Simple C++ function to determine the circumference and area of a circle

First off I would like to state that this is a homework assignment. However, I am not looking for you to complete anything for me. I code I am posting is the completed homework assignment. However, …

c++ homework  
asked by Brook Julias 9 votes
answered by Corbin 6 votes

Can you answer these?

Is there a better approach to implement this "day wise task management" system using Django and AngularJS?

I have a Task model in Django which looks like following, class Task(TimeStampedModel): project = models.ForeignKey(Project, related_name='tasks') date = models.DateField(_('date')) task …

django angular-js lodash.js  
asked by psjinx 1 vote

Construct a tree given pre and inorder Or post and inorder - critique request

Ok, code reviewers, I want you to pick my code apart and give me some feedback on how I could make it better or more simple. This code finds a common ancestor for binary search tree. this code …

java algorithm tree  
asked by JavaDeveloper 1 vote

"Stack exchange page visits" alike implementation

StackExchange page views works like this: Link The objective is to increment the page visits by one. User should not be able to do this by refreshing. Number of visits can be incremented only if …

javascript html5 angular-js  
asked by Muffin 3 votes
Subscribe to more Stack Exchange newsletters


Unsubscribe from this newsletter or change your email preferences by visiting your subscriptions page on stackexchange.com.

Questions? Comments? Let us know on our feedback site. If you no longer want to receive mail from Stack Exchange, unsubscribe from all stackexchange.com emails.

Stack Exchange, Inc. 110 William St, 28th Floor, NY NY 10038 <3