As 2015 comes to an end, let's kick off Best of Code Review 2015!
All Code Review users will be invited to nominate (link to) the best questions and answers from this year, and showcase them as examples of what great CR questions and answers should look like. Prizes in the form of bounties will...
@200_success / others. I really like the Newcomer answer, so I will start with that one. There are some other posts that came up, (but not winners) that I will also award bounties to at some point. But, in for the immediate process, I will start with codereview.stackexchange.com/a/107067/31503 and we can go from there?
I'm trying to create a simple calculator using Python, and I want to include a Hitchhiker's Guide to the Galaxy easter egg in it. When the user tries to multiply "6" and "7", I want to have the program display a special message.
elif user_input == "multiply":
num1 = float(input("Enter a numb...
I am practicing a problem in "Cracking the Coding Interview". The problem is to remove duplicates in a linked list without the use of a buffer. I interpreted this as not using a list or any large data structure such as a hash to store unique nodes.
My algorithm is inefficient I think. It iterat...
In order to better understand functional programming in Javascript, I thought I'd try to recreate (as well as extend) some of the higher order functions on the Array object. These methods don't intend to be identical but to have the basic functionality. Any tips/suggestions/feedback would be grea...
Array.prototype.newMapMulti = function(fn) {
var mainArray = [];
for (var i = 0; i < this.length; i ++) {
var result = this[i].newMap(fn);
mainArray.push(result);
}
return mainArray;
};
who wants to play, guess the fundamental mistakes made here?
Holy smokes. Someone tried to kill an armadillo and the bullet ricocheted, went about 100 yards, went into his mother-in-law's house, and gave her a slight wound.
Judging from other comments, if you want some overall feedback on your code (and better start early with it), you could try Code Review. StackOverflow is for practical errors, Code Review can help you improve coding practice. — Evert51 secs ago
I have 2 more semesters of classwork and an internship before I can graduate.
I wish I could go out west immediately, but my family won't let me take my dog with, so I'm stuck here for another 5-10 years. I think she is 4-5 now, I don't keep track.
Oh well, I guess I can use that time to save up so I have to take on less debt later.
I created a program that will convert a 3 character combo into a 3 string combo. I used a lot of If statements to accomplish the conversion. I'm wondering if there is any way to reduce the lines of code and possibly make it more efficient?
using System;
using System.Windows.Forms;
namespace Ado...
I'm not even sure if this is how you're supposed to do it, but this is what I have so far:
$.getJSON("/api/get_categories", function(data){
var items = [];
$.each(data["categories"], function(key, value){
items.push('<div class="card"><div class="card waves-effect waves-block waves-l...
I have this list of results which I display with the jQuery Datatable plugin.
This is the Result class and list of results being returned in the JSON format:
public class Result
{
public int articleid { get; set; }
public string Name { get; set; }
public stri...
Following code:
function personInfo($person)
{
$zipCode="12345";
if($zipCode!=54321)
{
$zipCode="12345";
$postal="World";
if($zipCode AND $postal < 1)
{
return "Wrong";
}
//Test stops here and do not continue testing the rest...
Stack Overflow is for help in solving specific problems in your code. For the broader sense of review and criticism, you may consider asking in codereview.stackexchange.com — Mureinik54 secs ago
Context:
I am reading text files that contain data from observations. The format is not Fixed Width or Delimited, so I built a generator that gets Key, Values pairs and yields a dictionary when it has read a full observation record (~75 pairs in my case).
The main loop builds a list from these di...
Great... I just spent and hour downloading a texture pack for Skyrim, and now I'm going to wait another 45 minutes for the stupid thing to extract itself.
I was always wondering how is it possible to bring the OS down. Luckily enough, this is easy in Linux:
panic.c:
int init_module(void)
{
int* p = 0;
*p = 0;
return 0;
}
Makefile (be careful with the tab characters):
obj-m += panic.o
all:
make -C /lib/modules/$(shell uname...
I have the following code I am working on, but I think it can be optimised further probably by improving the min/max variable selection, (see below).
The idea is to not use actual division, ('/'), to get the quotient and remainder.
I think there could be a way to improve performance by further ...
Good morning all,
I am writing an application for work. This application will sit on a closed network but I still have to be concerned about security. There will be a maximum of three types of user for this application: User (read only), admin (data edits only) and super admin (access all areas)...
Type erasure is giving me nuts recently. I'm designing a class that performs symbolic differentiation on a math expression represented as a binary expression tree. The question is more on the design part than on the actual code part so I'm only giving out the method that looks awful to me.
publi...
Meganeura is a genus of extinct insects from the Carboniferous period (approximately 300 million years ago), which resembled and are related to the present-day dragonflies. With wingspans of up to 65 cm (25.6 in), M. monyi is one of the largest known flying insect species; the Permian Meganeuropsis permiana is another. Meganeura were predatory, and fed on other insects.
Fossils were discovered in the French Stephanian Coal Measures of Commentry in 1880. In 1885, French paleontologist Charles Brongniart described and named the fossil "Meganeura" (large-nerved), which refers to the network of veins...
I have been working for a long time now on modelling an open quantum system using the Lindblad Equation. The Hamiltonian is the following:
However, two other matrices are added to the Hamiltonian. One of them has all the diagonal terms equal to -33.3333i and everything else zero. Another is a ...
i have question regards to singleton pattern. In our application we have jsf bean with session scope, in this bean i'm using (we don't have any DI mechanism) object some kind of service. Just calling methods and receive data. And my question is should i use here singleton pattern as the class/service does not have any state of application
This morning I received a text from my colleague telling me that he went on SO last night and looked at my account and sa wthat I had been answering some questions on work time.
As a result, he appears to think that I am procrastinating in work (which isn't always far from the truth, frankly) and intends to go to my boss with that information (or already has, I'm not sure).
So I'm going to be stepping down as RO so I can focus on my work. I love CR but I'd rather not get fired over it
Never mind the fact nearly every answer I post is in lunch time
3
@Zak I wouldn't say he is an asshole for having concerns
Though I'm not very happy that he went directly to my boss with his concerns instead of approaching me first
And from the wording of his text, I feel that is the case.
So, as I will be not be on 2nd or the exchange in general during most of work I don't think I'll be a suitable fit for RO - I'll still be here after work hours and such.
I imagine he is referring to this answer, which I posted while him (and all of my colleagues) were out on lunch.. and it only took me 15 minutes. But I disgress :s
@DanPantry I guess at this point, best thing to do is work out how you're going to convince your boss that your activity here on CR has a direct, measurable improvement on your work.
I do use 2nd monitor + CR in particular as an avenue of procrastination. While I do learn a lot about good code here, the main reason I'm here is to be able to socialise with like-minded individuals who have a personality and aren't forced to interact with me by way of being physically co-located.
@DanPantry It probably does if you're not too active here, clearing your mind can be helpfult o productivity... I at least honestly have problems to concentrate 4 hours straight on some days
Though, no one really procrastinates for no reason. The reason I do is because the experience of developing with the tools I have (or don't have) is very frustrating, which I have aired as grievances before.
I think the ultimate implication is that my colleague doesn't like the fact that I do anything other than work at any point of the day other than lunch.
Which is a perfectly fine viewpoint, but like you said @skiwi.. it can hard to focus for 4 hours straight unless you're in 'the zone'.
@Zak As far as I know we don't use any formal metrics.
We use an agile-based task list that is weighted per hour of effort and that sort of thing
But, really, that's it.
I've always asked at every 1-1 in the past if there have been any concerns about my performance or anywhere I can improve and the response has always been "No, everything's fine"
But still, if you find yourself having to convince your boss that he shouldn't fire you. Just point out that *whatever* you're doing with your time, it's getting results.
My boss may not see it that way - nor might my colleague - but my way of looking at it is that if I get stuff done there shouldn't be an issue on the in between.
@DanPantry Sometimes I do too, especially when I'm asking things about stuff I need help with at work. And then there's mod duties of course... but that's another story and probably not something that my company wants to pay me for.
If it gets to the point where it's impacting my work (and obviously it is), then I'm stepping over the line, which is why I appreciate the mention from my colleague
Again, not annoyed at the mention.. just at the way he went about it.
There's a lot of productive stuff to be doing outside of work. (I specially like to see some videos on youtube about physics i.e) You can also learn a lot from that. It would be nice having some kind of a global organization that would deliver projets to most tech people (scientist, physicists, mathematicians, electronic engineers) on off time while even paying them a small about to their contribution on those projects.
But I understand it could be hard to manage to pay according to the effort delivered.
I dislike the fact that there are way to many open-source projects to deliver the same contents for instance. Although one could argue that those also may result on the discovery of finding the best tool for the job
I would like to feel compelled to participate on some kind of open source project but up until now that didn't happen. Maybe because I didn't try too hard to find a project to begin with :|
It's 2016 now, and we've made some changes to the sidebar size. As such, we can now restart the Community Promotion Ads for 2016!
Keep in mind, we have updated some of the guidelines compared to previously - the changes are marked in bold in the Image Requirements section.
What are Community Pr...
@SimonForsberg Sorry but esoteric languages are not for me :p. I helped Mat on some reviews for his code to the vba plugin though. Ill be looking up to his repo and also the card shifter. But now it's time for a walk cya.
On Stack Overflow please post the minimal code necessary to reproduce the problem, or a simulation of the problem. Adding a demo is also helpful (e.g., jsfiddle.net). For a full review of your code, consider posting your question at Stack Exchange's Code Review site. — Michael_B52 secs ago
If anyone has time to review my code on CodeReview, please do so here. Also, this includes a bounty of 50 reputation points. Hurry up, just 5 days left to grab it! :]
I'd appreciate if someone could cast an eye over my dodgey coding and give me some feedback.
The use / purpose of the sheet/script is to quality grade calls, emails and chats with customers. A form is filled out and then the script takes over.
We feed in a persons name, it grabs the last 9 for...
I have implemented a "infix-to-postfix" function that takes as input a list representing the parsed expression, resulted from applying a certain regular expression to an expression, and I would like to have your opinion regarding its correctness and efficiency. Good suggestions are of course more...
I would like to improve my code. I am not a python expert, so I am glad for any help.
#!/usr/bin/env python3
import skilstak.colors as c
import random as r
def computerPlay():
cscore = sum(chand)
while cscore < 17:
chand.append(deck[position])
del deck[position]
c...
Actually (how all answers on Q&A sites should start), the red car will be faster. Or appear to be. In order to understand this we will have to cover the following formula:
f = d (xy + Pi)
Where f equals the amount of frozen yogurt you ate.
d equals how many pages you wrote in your diary.
xy is...
beautiful
Oh, I'm doing tag cleanup on old JavaScript questions, so don't mind me
I'm writing a checkout form for purchasing online tests. You can buy a certification or a recertification, as well as a pdf or book study manual.
I'm using Jinja2 templates to provide test data into the Javascript. The test object is a dictionary with the following structure. All prices are i...
I'm not entirely sure what you are trying to ask here...
If your intention is to improve yourself as a coder I would highly recommend learning to code to a unified standard such as PEP 0008
There was a question in Quora about an interview question that asks to write a function for computing integer square roots, so I rolled two of them for fun:
Main.java:
import java.util.Random;
import java.util.function.Function;
public class Main {
public static long intSqrt1(long number)...
I have saved the class holding the position of the i element in the a tag that is clicked by the user. When the a tag is clicked, I want to get the value of its title and add it as a class to the i element tag. I have tried doing it as illustrated below but I feel like this to much code. How can ...
Can you review my code of hierarchies/trees on Epoxy.js. Maybe there's a better way to solve this problem?
From the beginning:
Item View:
this is to display the element li
var ItemView = Backbone.Epoxy.View.extend({
tagName: "li",
template: new EJS({url: "templates/nodetpl.ejs"}),
...
I'm trying to solve the following task: http://pastebin.com/eq174ba0, with restraints: 1<= B,L,S <= 100 000. And for this I use a BFS from every edge at the bottom of the graph, and run a BFS till we reach y=0. However when running the code in the compiler I get a timeout error. What should I do ...
In JavaScript, any function is basically an object on which you can call (function(){}).toString() to get it's underlying code as a string.
I'm working on a function aimed to do the job in PHP. The intended goal is to convert code from PHP into other languages, such as JavaScript.
It looks li...