If we just want to check whether or not button1value is even, we can do that using the modulo (%) operator:
if button1value % 2 == 0 {
// button1value is even
groundspeed = 5.0
}
If we're checking for some other sort of set, we can use a switch statement:
switch button1value {
cas...
I am somewhat new to ruby (but not to programming) and I want to develop a small web-app with Sinatra. I started creating a small password utility script that hashes and secures entered password. I am not sure it is finished. I would like to know if there are any ruby tricks to make my code bette...
I thought I was going to finish my current project before moving on to my new job. That's not going to happen. My boss said he knew that wasn't going to happen (I never even suggested it). Once he said it, so much stress relieved...
But this week has been and will continue to be busy.
We had two new employees today, plus the coworker who was training last week's new employee wasn't here today.
And tomorrow, the other guy who started learning iOS several weeks ago will be in sitting next to me...
No, there should not be.
A question can only be put on hold by three means:
Five users with 3,000 reputation or more (500 on beta sites) have cast a close vote.
A user with a gold badge in one of the question's tags has marked the quesiton as a duplicate.
A site moderator has put the question ...
I'm going to start removing the 1 key from the keyboards of Swift programmers so they might stop abusing the ! operator... — nhgrif6 secs ago
Should we remove "someone else's" from "explanation of someone else's code"?
We all agree that asking for an explanation of any code or its output, regardless of who wrote the code, is a fundamentally off-topic question for Code Review, correct?
No, that specific close reason is supposed to be directed at just the first sentence, with the rest of the close reason being an explanation or examples of common 'failure modes'.
The first sentence is: 'Questions must involve real code that you own or maintain'.
Explaining your own code is sti...
I was happy with my shell script that needed to generate alphanumeric combinations of length N (in this case, 3)
for i in {a..z}{a..z}{a..z}; do ...
Now I became less happy when I needed alphanumeric combinations (specially if I choose a larger value for N)
for i in {0..9}{a..z}{a..z} \
...
I just wrote a basic DTMC algorithm focused on generating names, though it could be used to generate lots of other things. It's designed to be run from the command line, so input is taken from a file, with a couple of options specified on the command line.
I'm specifically looking for three thi...
We are allowed 5 close reasons in this menu, right? If questions from people seeking explanations of their own code becomes a common problem, we could make it a 4th close reason? — nhgrifAug 24 '14 at 12:16
So, Haskell is agreeably sorcery. The ... at the end of this script... is it an actual Haskell operator, or filler for code that should be there?
for i in $(ghc -e "
let c n l = if n == 0 then [[]] else \
[y:s | y:q <- Data.List.tails l, s <- c (n-1) q] in
sequence_. map putStrLn . c 3 $ ['a'..'z'] ++ ['0'..'9']"); do ...
> Remember, that the three standard off-topic close reasons are simply short-cuts to cover the most common cases. These off-topic reasons are not supposed to embody all the reasons questions can be off topic.
Custom close reason would have avoided all the headache.
Among the dozen-or-so comments under your post there, I've counted 5 links to meta.codereview.stackexchange.com where you should have posted this meta-question. Asking on MSE isn't really helping the community understand that you want to cooperate here.
Your question has been put on hold by user...
He's also purposely ignoring the "questions seeking explanation" part of that close reason... Notice he never once quoted that part of the close reason.
No, there should not be.
A question can only be put on hold by three means:
Five users with 3,000 reputation or more (500 on beta sites) have cast a close vote.
A user with a gold badge in one of the question's tags has marked the quesiton as a duplicate.
A site moderator has put the question ...
This one fits the best to me:
Questions must involve real code that you own or maintain. Questions seeking an explanation of code are off-topic. Pseudocode, hypothetical code, or stub code should be replaced by a concrete example.
It doesn't matter who's code it is. If it's your code then y...
This one fits the best to me:
Questions must involve real code that you own or maintain. Questions seeking an explanation of code are off-topic. Pseudocode, hypothetical code, or stub code should be replaced by a concrete example.
It doesn't matter who's code it is. If it's your code then y...
This one fits the best to me:
Questions must involve real code that you own or maintain. Questions seeking an explanation of code are off-topic. Pseudocode, hypothetical code, or stub code should be replaced by a concrete example.
It doesn't matter who's code it is. If it's your code then y...
A covering array is a N x k array in which each element is a from a set of v symbols, and for every t columns, every possible set of v^t choices of the symbols appears at least once. The covering array number (CAN) is the smallest N for which a covering array exists, given k, v, and t. A list of ...
> the idea here is that CR questions are not for explaining what the code does. It's the OP's job to explain the reviewers what the code is doing, not the other way around.
It is easy to say about code that it is written by someone else. It is fine if it is based on concrete facts by providing a link to that code of which they think that it is written by someone else. It is not fine if it is based on an idea. Here is an example:
What is the fastest way to make sure...
It is easy to say about code that it is written by someone else. It is fine if it is based on concrete facts by providing a link to that code of which they think that it is written by someone else. It is not fine if it is based on an idea. Here is an example:
What is the fastest way to make sure...
I'm the only person who VTD Lance's answer. Perhaps I stand alone (and that's fine), but I doubt I'm the only person who feels it doesn't address the question very well at all
Look, here's the way this question breaks down, along with some of my opinions, and some feedback on the flags that were raised.
Closed, or no
First up, let's talk about the merits of the actual question. Let me paraphrase the question as follows:
I have this code
it works
it runs slow the fi...
PS: this was moved to Code Review by someone else, but the question isn't "is this style fine" but "how could something like this be written in a more concise way" — darque6 mins ago
Is this sounding like it's asking for golfing help? (considering it migrated from PPCG)
FWIW, the reason they want it 'concise' is to fit in a script which requires a 1-line implementation... this is not a gaming question, it's a practical one.
my question comes down to whether or not there are better ways to to do this without excessive if/else if statements Then that is what you should ask about, specifically. Otherwise, see stackexchange's codereview. — Sotirios Delimanolis42 secs ago
When I first started learning programming, I wrote my if blocks like this:
if(i > 0)
{
System.out.println("Positive!");
}
However, on Eclipse, it always does this:
if(i > 0) {
System.out.println("Positive!");
}
Is there any reason why the second one is preferred to the first?
Write code to sum two numbers represented by a linked list. The digits
in this linked list are in reverse order. eg. (9->2->3) + (4->8->2) =
(3->1->6)
Any comments on my solution (especially on the testing part)?
public class ListNode {
private int val;
ListNode next;
ListN...
They are. They have really nice, well, tomato-ey insides, and, like I said, the skins are one of the best parts. They're really thick and just have this nice taste.
@nhgrif If it looks like changing the closure reason would increase the likelihood of redeeming the question, then I would. Otherwise, I probably wouldn't bother reopening it just to close it again.
I implemented a binary tree in the following code. Its node's copy constructor and assignment operator should copy itself and all its descendents. Similarity a node's destructor should delete itself and all nodes descended from it.The print function just prints each node in a new line. How can I ...
I'm a self taught Python programmer and I never really learned the fundamentals of programming, so I want to see how to improve upon this script and make it adhere to best practices.
The script has three functions that retrieve data from an API, cleanse the data and store it in a sqlite db. Thi...
I don't want to push the changes unless the code is reviewed . To get my code reviewed I have to do something like p4 shelve in git — Newbie51 secs ago
This would fit more in code review. Anyway: I don't know that API but taking into account your data source, I would say it is hard to shorten the code. — ikaros4544 secs ago
Github is a link to all my code and the working JAR file.
I have been learning LibGDX and attempted to make a working Pong game, I am new to this and would like some pointers on where I could improve my code, if there is anything I have done incorrectly or can do easier, better.
This is my firs...
I wanted to create a loot table mechanic for any future game projects, and came up with what I am about to show you guys. I was wondering if someone could give it a glance and see if there could be any errors, or if it could be improved in any way. Here is the class:
using System;
using System.C...
So I have the following code in my ServerRunnable class:
public class FirmwareServerRunnable implements Runnable {
private static Logger log = Logger.getLogger(FirmwareServerRunnable.class
.getName());
private LinkedTransferQueue<CommunicationState> communicationQueue;
...
"The most practical way" seems to solicit opinions. If you have working code, submit it to Code Review. If you have non-working code, show it. If you have no code and no idea, try something. — Jongware36 secs ago
If you want persons to look at your code that is working, normally codereview.stackexchange.com is a better place. This is a Question and Answer site. If you want to publish a piece of code, you can create a question that can be resolved by your piece of code, and then answer yourself with your piece of code... — xanatos40 secs ago
I've written an encryption-decryption class that is to be used in my companies commercial web application that will handle sensitive information. The encrypted data will be passed over the internet via HTTPS but even so it needs to be internally secure.
I've tried to follow best practices but I'...
I have a simple projection in my code. Taking away the majority of the fields which are not of interest, it looks like the following:
var result = employments.Select(x => new EmpListItem
{
EndDate = x.EmpRelationship.OrderByDescending(y => y.EndTime).FirstOrDefault().Cancelle...
While this topic is already asked and resolved in this question, it's time to review the solution.
In mine opinion, and sorry to say, it doesn't work.
In mine opinion, there is a possible solution.
The first down voter is obligated to leave a comment why he down voted it.
Comment can be flagged...
Well, some of us would be okay with specific critiques here... but I tried emphasizing heavily on encouraging the user to take it to the meta. One of his comments indicates English wasn't his first language.
I suspect, given the way things happened, that the OP felt "ganged up" on. Going to meta.se was possibly a way to get access to a more "friendly" crowd.
Would it, rolfl? He respects your answer because you're a mod. At the point he disagrees with it being hold and there are that many comments, isn't discussing it on the meta the right course of action?
I pointed him toward meta several times before anyone else even joined the comment thread.
Not sure about that. The OP fixated on one aspect that they felt emotionally "wronged" by. The rest of the individuals in the community fixated on different points that interested/inspired them.
But while it's not, the he focuses on the idea that he needs a pile of evidence to prove his question should be closed for that reason IS missing the point.
I need a class that holds a huge amount of data, which should be useable across multiple threads. To avoid copying the data every time, i used a std::shared_ptr. To make it thread-safe i need a mutex to secure the data. But if i'm right, this mutex must be shared too. Since boost::recursive_mutex...
Once a question is on hold, the honus is on anyone capable to turn it into an on-topic question, not simply resolve the issues related to the specifically chosen close reason.
OK, then I'm missing the point, but whatever your point is, load it up as a separate meta question, don't piggy-back it on the discussion of a specific matter.
Thanks Matthieu, for the suggestion. Actually I am aware of the git am functionality, I was thinking of more over a tool(like gerrit) which can help me to see the changes, do a code review etc. — Shashank Sharma12 secs ago
The OP asks if there should be evidence to go with the close reason to "prove" the close reason is the right reason.
My answer answers that (No) and instead explains what you should do if you feel like the close reason is incorrect.
(and explains why I say No)
And he still hasn't commented on my answer, nor has he heeded the advice in my answer and explicitly asking a meta question actually making any case for his question to be reopened. He doesn't need to now because your answer explains in more detail why his question isn't fit to be reopened.
Sure, so downvote my answer.... it was not directed at the title/wording of the question, but at what I interpreted as being needed to defuse the situation.
Even after reading your answer, the OP is still missing the point to a degree:
I think there is a misunderstanding. The code running on Azure is mine. It is not owned by Azure. It is good to know that you tell that the close reason is "only partially related to the real reason". You seem to describe the close reason and the real reason as two different things that are only partially related. I respect your opinion that is "good enough". Personally, I think the relationship should be stronger to use it. But that is just my opinion. I wrote the code myself. It is really working code and there is no "someone else's code" involved. — Daan9 hours ago
He keeps talking about the "partial relation" of the chosen close reason and the real reason. He's fixated on that and he needs to not be.
So if another question of his gets closed, we'll get to do this whole dance again as long as the auto-close reason comment doesn't 100% match his question specifically.
@nhgrif - to be clear, it is my understanding that, despite his meta question, the OP has no desire to set or influence site policy about close reasons. They have only one concern, to get their question reopened, and reviewed. This is not about site policy, it's about network latency.
The meta question was there to perhaps reopen debate, and to understand why their question was closed. It is not a meta question designed to apply to the whole site in general.
concurrency is making code capable of simultaneous access by multiple threads (or 1).
multithreading is possible without concurrency
thread-safety is more like concurrency than multi-threading.
but, threads can be safe with no concurrency.... by exclusion, rather than inclusion.
you can lock out "other threads" by using semaphores, etc. Essentially guaranteeing single-threaded execution, thus, making it thread-safe
concurrency is (can be) more.... fuzzy. Perhaps having partitioned access, so you can have multiple threads running at the same time, in the same code, but on different 'zones' of the data, or running lock-free, but employing re-try logic in the event of a collision.
So, concurrent is thread safe, but thread safe is not necessarily concurrent.
@nhgrif have you looked at his network profile? The guy doesn't seem to have been around long enough to actually understand the finer points of SE yet. Lesson learned. I won't be lazy in the future. I'll take the 30 seconds to type a custom close reason.
@TimSchmelter This code is likely to have been decompiled, which would not make it the OPs code, which would make it off-topic on Code Review — Simon André Forsberg40 secs ago
@SimonAndréForsberg: i don't know if improving decompiled code is off-topic on codereview per se. — Tim Schmelter34 secs ago
@TimSchmelter I would say that it is off-topic (I'm a CR regular). See Code Review's on-topic page"Am I an owner or maintainer of the code?" In order to improve this code, you need to understand it first (which the OP likely doesn't), and explaining code is also off-topic for CR. — Simon André Forsberg22 secs ago
Aside: This code assumes a class Option that can be Some or None to represent the presence (Some) or absence (None) of the value it contains. Haskell calls it Maybe.
Here is my first pass at wrapping Iterator in a thread-safe way:
public synchronized Option<T> nextBlocking() {
return iter....
I have a problem with my knapsack algorithm. The problem is about adding files to the storage and maximizing the computing time. Of course, there is a capacity limitation. The problem is that I can find the maximum computing time under the capacity restriction but I cannot seem to specify which i...
For working, potentially improvable codes I think a better place is codereview.stackexchange.com In case it does not work, could you explain what is the problem in your opinion? — Gábor Bakos34 secs ago
I really like Sublime Text. It's super fast and you can do crazy stuff with it. Can't recommend it enough. Also, giving it a try should not be too big of a deal.