« first day (1388 days earlier)      last day (2633 days later) » 

12:00 AM
RELOAD! There are 3463 unanswered questions (91.7250% answered)
 
12:24 AM
I already tried use ADODB, but it was slower. I'll put the code in the code review — Fernando 8 secs ago
 
@CaptainObvious Looks broken
 
12:43 AM
If your code is working, and you're looking to improve it, you should ask the question on Code Review. Here on Stack Overflow, we help you out with code problems. Asking which approach is better, could be considdered as Primarily Opinion Based and simply lead to closure of your question. — icecub 28 secs ago
 
1:10 AM
0
Q: A simple PyPI crawler

René GI had to make a program to crawl through a bunch of PyPI packages and see how many of them implement custom compare operators (i.e. grep for def __le__ etc). After downloading an HTML file with links to all Python 3.4 packages on PyPI (i.e. the directory page), I wrote this simple crawler to go t...

0
Q: Text Based RPG (WIP) C++

Adyn_Gwanted to see how this code looks, what can be improved and how those improvements can be implemented, still new to C++ so I hope it isn't too sloppy. #include <iostream> #include <string> #include <time.h> #include <stdio.h> #include <stdlib.h> int main() { int warrior, mage, rogue, ...

0
Q: Template for Python Package Index (PyPi) submission

Chris BI'm writing a couple of packages that I'd like to release on PyPi for other people to use. I've not released to PyPi before so I have been mocking up a submission template: https://github.com/chris-brown-nz/pypi-package-template Here's a tree of the project template: | MANIFEST.in | README...

0
Q: Computer Science assignment

dmikey098I had to write a program that would complete an arithmetic progression based on the users input. The user would provide the third term in the series, the third from the last term, and the sum of all the terms in the series. The program would display the total number of terms are in the series and...

 
1:23 AM
0
Q: efficient way to count number of elements in a sorted array

Lin MaSuppose I have a sorted array, and each element may appear multiple time. To make it simple, here is an example, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3] The expected output is the number of each elements, in this example, results are, ...

 
 
1 hour later…
2:30 AM
0
Q: How to remove the duplicated param

Li Xinyangdef index if params[:next_cards] # check nil render json: current_user.next_cards(params[:next_cards].to_i), status: :ok else render json: current_user.cards, status: :ok end end How to remove the duplicated params[:next_cards] from the code above?

 
3:05 AM
0
Q: Basic Matrix Class in C++

AnjouI've made a simple Matrix class to learn C++. It doesn't use Templates so it only works with int. I made it this way to really understand how to work with objects and memory; I'll probably move to the next level once I get feedback on this one. I used these two blog posts as reference: C++ Mat...

 
3:17 AM
0
Q: Path Finder Maze (Ruby)

kobetasticMy question is how to make my code more readable and better formatted? I'm currently reading through Practical Object Orient Design in Ruby, but am unsure how to apply certain principles from the book. IE should I have created another class or are there other methods I should breakdown to have le...

 
3:50 AM
0
Q: More groovifed way of sublist with varying ragne

RaoStudent list of 50 students and a teacher list of 3 teachers. Section XML as the output where each teacher is assigned to a section, and upto 20 students are assigned in that section. Need to loop on each teacher element, and for each teacher element, loop on the student name from 1-20, than f...

 
First 8-mile walk ever today. I have blisters under my callouses. :/ At least I proved I could do it, and took the family record back.
 
I'm voting to close this question as off-topic because this belongs to another Stack Exchange network codereview.stackexchange.comN J 53 secs ago
 
4:10 AM
0
Q: How to name a clickable layout in android with good smell

WhiteBananaIf I take a Linearlayout as a button, and then how to name this layout with good smell? For example: <LinearLayout android:id="@+id/playBtn" <= this is bad style? or playLayoutBtn? android:clickable="true" ...... </LinearLayout>

 
4:23 AM
0
Q: Setting Pokemon stats

Cody PaceI set the stats (.ie. name, attack, defense, HP) in the __init__ method. However, I have chosen to build the self.attacks dictionary with a separate method. class Pokemon(object): def __init__(self, name, attack, defense, HP): self.name = name self.attack = attack self.defense = def...

 
4:45 AM
0
Q: BST implementation

Ilyas KussainovMy implementation of BST. Critique will be appreciated! #include <iostream> template <class T> class Node { template <class X> friend class BST; template <class X> friend void clear(Node<X> *root); template <class X> friend bool search(const Node<X> *root, const X x); ...

-1
Q: I am not sure how to solve this in python

ChrisA binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 10...

 
4:57 AM
Shouldn't you have posted this question on CodeReview? :) stackoverflow.com/questions/42334719/…hpaulj 35 secs ago
 
5:53 AM
Looks like your talent belongs to codereview@SE, not Stack Overflow, where it does more harm than good — Your Common Sense 58 secs ago
 
6:10 AM
 
possible answer invalidation by Li Xinyang on question by Li Xinyang: codereview.stackexchange.com/posts/155810/revisions
 
6:55 AM
if (efforts.Required > codeFromScratch.Costs) DoNoReverseEngineer();
 
possible answer invalidation by Li Xinyang on question by Li Xinyang: codereview.stackexchange.com/posts/155810/revisions
@ajb, well, I have edited the answer with one small code review. — AxelH 16 secs ago
 
7:23 AM
Monking
 
Monking
 
Monking
 
8:20 AM
Monking
 
8:49 AM
0
Q: How do I add a period after a list of numbers?

Kimimport java.util.Scanner; public class FactorsofIntegers { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter an Integer:"); int number1; //User must enter an integer number1 = input.nextInt(); ...

 
I'm voting to close this question as off-topic because this belongs to Code ReviewAxelH 18 secs ago
 
Kaz
9:07 AM
Monking
 
Just for the avoidance of doubt: There's no real limit on the number of if/else if/else if you can use. More than three is fine. If you want to use the structure above, use the powerful debugger built into your browser to go through the code step-by-step watching it run, to see where it's going wrong. It's easy (for instance) to leave out an else. If you want suggestions on how to improve the structure, that's probably a good fit over at codereview.stackexchange.com. — T.J. Crowder 7 secs ago
 
9:48 AM
Monking
 
I think this would make a better fit on code Review SETidB 30 secs ago
@TidB Code Review doesn't deal in examples, so I have my doubts about that. — Mast 20 secs ago
 
Monking
 
possible answer invalidation by Timothy Truckle on question by Kim: codereview.stackexchange.com/posts/155829/revisions
 
10:06 AM
If this code is working, Code Review may be more appropriate. Be sure to read the help pages on that site to see if your question fits their requirements, and follow their guidelines. For StackOverflow, it's too broad. — RealSkeptic 28 secs ago
 
0
Q: Finding all the divisors of a given number, that are even

Rockstar5645import java.math.*; import java.io.*; import java.util.*; public class DivisorPrint { public static final Scanner sc = new Scanner(System.in); public static List<Integer> primes = new ArrayList<>(); public static Map<Integer, Integer> factorsOccur = new HashMap<>(); public stati...

 
10:32 AM
@Duga No, approved it myself.
Both answers should probably be nuked with the question though.
It was kind of polishing a turd.
 
11:17 AM
0
Q: Wrapping IndexDB with RxJs

Jason GoemaatI find IndexedDB cumbersome and want to wrap the functionality with rxjs observables. I've come up with an angular2 service that seems to fit the bill, but I'm wondering if I'm using the observables correctly or if there might be any subscriptions I'm missing (plnkr): Usage: this.localDbServic...

 
11:30 AM
0
Q: How shall I make my code more optimize and efficient? I have to make use of maximum number of OOPS concepts here.

Puja MishraPatient.java package com.cerner.hospital; public class Patient { private String patientName; private int patientId; private String patientProblem; private String doctorName; private String departmentName; private String patientPrescription; public String getPatientPrescription() { return ...

 
11:50 AM
@CaptainObvious wtf???
 
OOPS concepts indeed.
 
-1
Q: Common code between children which inherit from a parent class

SomarI have a code with the same structure as bellow: class parent(Object): def method1(self,name): raise NotImplementedError("Subclasses should implement this") class child1(parent) def method1(self, name, company) print(name + ' ' + company) print(name + '!!!') na...

 
@CaptainObvious user does not get how Code Review works ...
 
12:18 PM
Hi there :) I'm wondering if anyone here has some suggestions for a task that I can work with to learn some Python... There are a bunch of tutorials, but I'm not a big fan of the step by step approach, I like trial and error... For the record, I know some basics and I'm fluent in MATLAB...
I'd like if there are some numbers involved, since I'm an electrical engineer, and I'll always be working with number processing in some form or another...
An example: A task I recently did was read data from an Excel workbook, did some more or less random operations (calculate the running mean) on it and write some of it back to a new Excel workbook.
 
@StewieGriffin Have you tried Project Euler?
Not exactly application project work but it's heavy in mathematics
 
12:33 PM
@DanPantry I've looked at some of it, but as far as I can tell it's not very useful for learning coding practice... I could include some aspects of it though...
I think it's more directed at figuring out solutions to a "puzzle" than the coding bit...
I'm looking for something where I typically need a few functions that must be called from a main function... This was the first task I did this way. I'm looking for something along those lines...
 
@StewieGriffin How about the n-queens problem?
2
 
Even if the answer solves the problem, IMHO, the code is much suitable in codereview SE and not here. — Inian 35 secs ago
 
@Zeta that's a very good idea! :)
 
Kaz
@StewieGriffin you could look through CR questions until you find a project that sounds interesting to implement.
 
Bonus points if you render a nice chess board.
 
12:44 PM
@Zeta My first reaction was: Great, this gives me something slightly strange (not just an array or a string) I can write to a text / csv file too :)
 
+-+-+-+-+
| | |Q| |
+-+-+-+-+
|Q| | | |
+-+-+-+-+
| | | |Q|
+-+-+-+-+
| |Q| | |
+-+-+-+-+
 
@Zeta Exactly! :)
I can only work on this when my daughter is sleeping and I'm not cleaning the house, and I'm a complete beginner... I'll post my code for review in a few months time :P
 
1:12 PM
2
Q: Rock, Paper, Whatever - A small comandline game

PeilonrayzMy rational for this program, was to learn more of Python's standard library, I didn't actually know cmd was even in it until I started this program. It's also the first community challenge, and I have some catching up to do. This is an overly engineered version of the famous Rock Paper Scissors...

 
Greetings, Programs.
 
0
Q: Safe (and restricted) version of eval

FredI have built a shell function aimed to perform the following : Given a string as first argument, perform safe expansions (i.e. those that cannot cause arbitrary code execution and only produce string output) Save the output to a variable the name of which is provided as second argument, and ca...

 
1:45 PM
0
Q: How to close WS connection on EndOfMessage [C#]

RapsoulhsI've used the code from this question Code review Q and I want to combine it with the answer that Sean (Sep 13 '16 at 16:42) has give underneath. I can't wrap my head around on how to implement his answer in the given code. I only want to receive the content via WS once and then close the conne...

 
1:55 PM
possible answer invalidation by Traubenfuchs on question by Traubenfuchs: codereview.stackexchange.com/posts/110440/revisions
 
2:10 PM
 
2:27 PM
codereview would be the best place to review your code once you've fixed the clear error as Carcigenicate pointed out... — AJefferiss 33 secs ago
You'll get more helpful answers over at the Code Review SE. — Andrew Jenkins 9 secs ago
To expand on the previous comments, Stack Overflow is meant for helping to fix code that does not work, or behaves in an unexpected fashion. Code Review SE is for asking if it was coded in the best way. Even then, asking "if it can be done another way" will generally be answered with a flat "yes", as without any context as to what you want your code to do beyond what it already does, that is the correct answer. — Brandon McKenzie 16 secs ago
Maybe post on Code Review instead. — Peter Wood just now
 
3:03 PM
I'm voting to close this question as off-topic because you are asking for a code review and suggestions for improvement. Your question might be on topic on codereview.stackexchange.com (but check their rules first!) — Mark Rotteveel 39 secs ago
 
0
Q: SAS Proc SQL Where ... In ... statement

MRRI am working in SAS Enterprise guide and have a one column SAS table that contains unique identifiers (id_list). I want to filter another SAS table to contain only observations that can be found in id_list. My code so far is: proc sql noprint; CREATE TABLE test AS SELECT * FROM...

 
3:15 PM
0
Q: USB Finder with autorun action

narzanI finished a small program in vb.net that send External IP address "WAN IP" when someone open the program, it's suppose to work as USB flash finder. The Idea came from a question from a user on SuperUser When someone use your USB stick the program will run automatically and send the IP to a spec...

 
3:29 PM
Maybe better placed on Code Review? It's working code, there's no programming issue there. You just want to improve the design. — Baldrick 41 secs ago
If your code works as intended, just slower than it needs to be, you should probably be putting it up (all of it, not just "what's relevant" - you'd be surprised with how much "irrelevant" stuff actually matters) on Code Review... including as much additional context as needed for external eyes to assess the situation. =) — Mat's Mug 41 secs ago
 
3:51 PM
I'd just dump the whole module on a fresh Code Review post, and take the time to present that code to the reviewers, describe its purpose, what it does, how it does it and why it does it that way; "how can I optimize my code" is really too broad for Stack Overflow, but exactly in-scope for Code Review. Check it out!Mat's Mug 52 secs ago
 
4:10 PM
0
Q: General static value required by multiple classes

AlaanorI have a general value called Seed which is required to multiple class. But those class aren't dependant of the classe which declare it. class Game { class Settings { public static float Seed = 1337; } } And some class need a Seed value to work. I take the class Noise as example...

 
4:40 PM
I disagree here with @YacoubMassad. It is actually much harder to do this kind of automated analysis when you build up the object graph by hand. However, I don't know whether it is possible to do this with Unity. I know you can do this kind of Object Graph analysis in Simple Injector though. Besides this, I find your restriction quite suspicious. Seems you are forcing a strict layered approach, while you don't apply simple code reviews. — Steven 32 secs ago
 
Kaz
4:52 PM
Pro: Our new system has a handy "Export the search results to Excel" button.
Con: It arbitrarily cuts off anything more than the first 250 results.
 
@OleV.V. you may hand him over to code review... — Androbin 41 secs ago
@Yacoub what I think the OP wants is to do NDepend like analysis to verify the architectural constraints. He wants to verify whether the developers play by the rules. What I'm saying is that it's actually quete hard to verify this when doing Pyre DI, except of course when applying good old code reviews. — Steven 18 secs ago
 
5:10 PM
Monking
 
how to use the new github topics
 
lol?
@DanPantry "Chaotically" would be one way to answer that question :P
 
ah, no, it wasn't a question, more of a statement
although maybe it would be better to say 'how NOT to use the new github topics'
 
0
Q: Is this the simplest command to show all programs' man pages?

l0b0I'm trying to discover useful command line tools in Arch Linux, and it seems one good way of going about that is to look through all of the man pages related to programs (that is, section 1, as in man 1 bash) in local alphabetic order (that is, not overriding the sorting locale with LC_COLLATE=C ...

 
The F# Software Foundation is organizing something like CR's Community Challenges, if anyone wants to provide a suggestion and/or implement something in F# for the winning proposal. Because we are only doing one language, we are making more generic proposals, like any turn-based game played on a checkerboard.
That will make things a little more interesting than getting a dozen Chess games implemented in F#.
 
5:29 PM
0
Q: Collatz Sequence: Which number is the biggest?

jackmasterlooterSo I have written code for the Collatz Sequence, but I want to be able to identify and print out the largest number that appears in the sequence. Here is my code: import java.util.Scanner; public class CollatzSequence { public static void main(String[]args) { Scanne...

0
Q: Nesting Multiple Functions in Haskell

Chinmaya Bimport Data.List xyz :: [Int] -> [Int] xyz (x:xs) = delete (secondmax(x:xs)) (x:xs) where secondmax :: [Int] -> Int secondmax [x] = x secondmax (x:y:xs) | max(x:y:xs) > y && y > max(xs) = y | where | max :: [Int] -

0
Q: JavaScript Image Slider

MikeI wrote simple slider in vanilla JS and my question is what is bad and what can I change. Thanks for any helpful answer Github: https://github.com/kristoff090/campslider-alpha

 
6:05 PM
0
Q: C++ generic double-dispatcher/visitor

Peter LenkefiI'm trying to reduce the boilerplate code for the visitor/double dispatcher pattern. First I've created a way to enforce the dispatcher to declare the dispatch(T) function for every type supported and also a dispatch_gen(T) for the generic case which I don't need to implement. This is not too har...

 
@CaptainObvious Off topic. Broken code.
 
Ripe zombie; open question with answers, at least one answer having score 0, no answer having score > 0: Raw filter with ternary operator for html class attribute
 
6:25 PM
 
Monkernoon
user image
4
Perfect.
2
 
Nice
 
6:42 PM
-1
Q: which approach is good to dealy a function call for one 30 second?

cppcodeI am too confuse which is the best approach to consider for waiting for 30sec before making a function call? FIRST APPROACH I have heard from my colleague not to use sleep. Not sure why though i feel its good because it reduce cpu load and execute important task below approach I am trying to j...

 
@Inian I have added a question on codereview : codereview.stackexchange.com/questions/155842/…. Thanks for the tip. — Fred 35 secs ago
possible answer invalidation by EPICI on question by EPICI: codereview.stackexchange.com/posts/155781/revisions
 
7:03 PM
odd... I wonder why this wasn't already linked
 
@DanLyons lol :p
Does anyone know popular admin/password combinations of 20-30 years ago?
 
posted on February 20, 2017 by CommitStrip

 
7:21 PM
@CommitStrip LOL perfect metaphor
 
@CaptainObvious Whoops. Accidentally ninja-answered that question o.O
 
static T* Deserialize(std::ifstream& in, size_t length)
{
    static_assert(std::is_trivially_copyable_v<T>, "standard template is only defined for trivially copyable values");
    auto elements = std::make_unique<T[]>(length);
    T* raw = elements.get();
    in.read(reinterpret_cast<char*>(&raw), sizeof(T) * length);
    return raw;
}
Whyyyy stack corruption
2
In return raw;, or well to be more precise, directly after it
 
7:36 PM
@skiwi I think that you and those stacks should consult a psychologist. Resolve your problems !
 
@skiwi Still corrupting your stacks?
 
@Mast Yeah... writing works, reading doesn't for some reason
The problem is that a stack corruption can be anything
 
unique_ptr::~unique_ptr will... Ah, read the documentation ^^".
Or rather, use release() instead of get().
 
StackOverflow is mainly for fixing errors. Maybe you are looking for Code Review instead? Also, genetic algorithms seem like an overkill for this particular problem since you can just find the largest value in a single pass, pop it, and do one more pass to find the next largest. — Maksim Kneller 50 secs ago
 
I think my next review starts too philosophically o.O
 
7:44 PM
It does work if I don't write into the T* raw...
@Zeta That's.... a very good point
T* raw = new T[length];
in.read(reinterpret_cast<char*>(&raw), sizeof(T) * length);
return raw;
Even that gives stack corruption though
Wait... it works with &*raw of course!
 
Why do you take the address of the pointer?
I didn't notice that before.
Just get rid of & in &raw.
 
@skiwi &*raw? What the heck are you trying to do?
 
0
Q: Preprocessing iterator

IncomputableAfter tweaking semantics a lot, it ended up being a very poor object version of std::transform<>() that can be used with other std algorithms. Basically the iterator wraps a provided iterator, creating an output iterator and applies supplied functor when dereferenced and assigned to. The caveat...

 
@Mast I tried to pass a reference... might not be needed in hindsight
@Zeta But then there's no point of using std::unique_ptr<T[]>? So the only correct way would be to return it from the method?
 
I have no idea what you're going to do with that pointer, so I'm just going to smile and nod :).
 
7:50 PM
auto elements = std::make_unique<T[]>(length);
T* raw = elements.get();
in.read(reinterpret_cast<char*>(&*raw), sizeof(T) * length);
elements.release();
return raw;
This might work
Alright, I'm going to put this up for review soon tm
Hopefully today
 
@skiwi Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah! Why?
 
@Zeta You told me about preventing failing to release memory in case in.write / in.read would fail
 
@skiwi Might take some time till I have a look at it, still stuck on this one.
@skiwi Huh? I did? I only remember telling you about the memory leak you had in your std::string deserialization.
 
in.read(reinterpret_cast<char*>(&*raw), sizeof(T) * length); <- oops
&* doesn't make much sense
 
That's why I said "Aaaaaa...." :D
 
7:55 PM
Turns out that knowing what you're doing is important
 
@Zeta Yeah. Turns out, I don't know how to start that review.
 
@Zeta Good luck...
 
So... I have a source of randomness that was baked into a class that did business logic for some reason
 
Where's the code?
 
So I extracted that source of randomness into it's own class, PRNG
and now 6 to 9 tests randomly fail. The tests that fail change each time.
I don't know what I expected.
 
8:07 PM
And you can still see some gotos
 
@skiwi Yeah, my review now starts like this:
> When you write a program, you try to express your ideas in a way that the compiler understands it and builds you an executable, that works as you intended. However, the compiler is a second-hand consumer. They will gladly take any code that is valid C++ and create a binary. The human, however, might not.
>
> As humans, it comes naturally that we organize the material we work with. Clockmakers will have their screws and drivers sorted, plumbers their wrenches and helpers. Mechanics have their bolts, nuts and gears ready in bins and cans, just a handful away.
 
Me, to git reset right now: youtube.com/watch?v=1Isjgc0oX0s
 
Travel.SE election just started.
 
@t3chb0t @Mat'sMug How is this closed question
-1
Q: Delaying a function call for 30 seconds using sleep() or checking the time in a loop

cppcodeWhich is the best approach to consider for waiting 30 seconds before making a function call? FIRST APPROACH I have heard from my colleague not to use sleep. Not sure why though I feel it's good because it reduces CPU load and executes important tasks; in the below approach I am trying to just ...

… much different from this old open question?
19
Q: Using a for-loop instead of sleeping?

MhmdI need to wait for short intervals of time in my program, but I really don't want to include unistd.h just to use sleep, so I'm doing it this way: int main() { for(int i=0; i<=100000000000; i++); // <----- note that the loop doesn't do anything return 0; } I do this when I don't really have a...

 
@200_success Isn't that asking for a theoretical approach? If there was only the first approach with some additional text, I think it would be on-topic.
 
8:21 PM
@200_success Mat's left a comment.
 
But I still fail to see the difference, even with Mat's comment.
 
@200_success funny, that one has my downvote
 
I don't see what is theoretical about it.
 
-1
Q: Flask WTForm updating sqlite db

user2865435I have a form that I want to use to add, delete and update my database. The add and delete work just fine but I am missing something on the update part. def admin(): form = forms.PartsUpdateForm() if request.method == 'POST': choice = request.form.get('admin_choice') if form...

 
8:26 PM
@200_success I VTR'd. It's an A vs. B which is on topic here.
 
And the timeline on that old question is rather interesting, too.
IMO it's quite literally asking "what's the best practice regarding sleep". Until "what's the best practice regarding X?" is edited out of our help center under the "then your question is off-topic" section, I'll consider it off-topic.
The code is merely illustrating a point, OP doesn't care to have it peer reviewed
They have a very specific concern that's very specifically answered elsewhere already.
 
Except there's still a lot to be said about the first method and how it is the one to violate SRP
 
It's not "I have this code that does XYZ" and happens to have a sleep-wait
Then VTR and prepare to protect a shitty HNQ
 
Evidently, I was convinced by others to retract my close vote on that old question. I'd prefer to see some consistency in our standards. Stare decisis.
And if it's borderline, it should probably stay open.
 
Why can't it be 'I have a sleep / wait how can it be better?'
 
8:32 PM
Because that's literally all there is to it
 
Is the issue that there is not enough code to review?
 
@Mat'sMug 'I have code that calls sleep vs a loop that waits which I wrote on my own.'
 
I find it's asking, pretty much word-for-word, exactly what our help center explicitly mentions is off-topic
"What's the best practice regarding X?"
 
Literally every Code Review question boils down to 'What is the best practice regarding X?'
The difference is how plain that is.
Whether we're asking 'What is the best practice regarding writing a Brainfuck interpreter?' or 'What is the best practice regarding writing a Console argument parser?', in the end we want to know what the best practice is for our code.
 
8:40 PM
No. CR questions boil down to "does this code follow best practices?" ...quite a difference.
At least that's how is phrased
 
You can take practically every ontopic CR question and rewrite it as 'What is the best practice regarding _______?' and it would be the same question.
I personally think that reason only applies if the question doesn't provide any code/structure.
 
Then the help/on-topic page needs to be clarified
 
If OP asks 'What is the best practice regarding waiting for an operation to complete?' with absolutely no idea what they want to do then it's probably offtopic.
 
I VTC for the old question too. Both are clearly SO.
 
> However, if your question is not about a particular piece of code and instead is a generally applicable question about…

Best practices in general (that is, it's okay to ask "Does this code follow common best practices?", but not "What is the best practice regarding X?")
> then your question is off-topic for this site
 
8:44 PM
I think that the rule is primarily meant to prohibit foo/bar kinds of examples. This isn't a foobar.
 
I've always read it as aiming to avoid questions boiled down to one specific aspect
e.g. sleep-waiting, or using namespace std, or how to reduce huge if statements
also both snippets provided by the OP are clearly unrelated. first approach is parameterized, second hard-codes the delay. and the comments clearly aren't in any real production code - to me everything in that question is pointing to the code being a pretext for asking whether they should be looping or sleeping.
 
He's asking for a review of his reinventing-the-wheel sleep function. Does the wording matter that much?
 
Kaitlin Pike on February 20, 2017
Welcome to the Stack Overflow Podcast #101. Fact: We now have as many episodes as we have adorable Disney dalmatians. Today's podcast is brought to you by the WordPress Development Stack Exchange.
 
may I edit it into an on-topic reinventing-the-wheel sleep function review?
 
Go for it.
 
8:55 PM
@Mat'sMug Shouldn't we be doing that for the first step anyway? Or at least asking OP to do the edit?
I think we close things too quickly/aggressively.
 
In this case, the OP has two new accounts that should be merged. A bit of a mess.
 
done
and napalm'd votes for everyone
 
possible answer invalidation by Mat's Mug on question by cppcode: codereview.stackexchange.com/posts/155864/revisions
 
1
Q: JavaScript Recursive Filtering With AND and OR

mhodgesI am doing the #JavaScript30 challenge and challenge 06 is to write a "type ahead" application for searching for cities/states. The basic challenge of filtering based on a simple string was rather trivial, so I wanted to add AND and OR functionality using + and ,. I came up with a recursive solu...

 
Ugh. Too tired for a proper review.
 
9:11 PM
hmm, looking at that diff, it appears that my actual problem was with the A vs B phrasing. I'll just stick to downvoting them in the future, sorry for the disruption. I simply cannot get it into my head that one-liner A vs two-liner B is fine to ask here.
 
Thanks for editing.
 
np
 
Tonight has made me realise how why encapsulation is important
 
how, or why?
 
@DanPantry That sounds like you've edited a COBOL program.
 
9:14 PM
lol
 
@ARedHerring_ WHY WOULD YOU DO THIS?! Use a constructor parameter, don't modify the field in a COMPLETELY different… https://twitter.com/i/web/status/833779224834109441
The image is a code snippet from OSS I am --breaking-- refactoring
That snippet in particular hard-coded the seed and starting seed of all pseudo random sources to a specific value during tests
So you can imagine once I moved the pseudo random number generator out of the god class that is Battle but left that in, many, many tests broke and it was extremely hard to work out why
Because every single test was looking directly at the startingSeed and seed fields of Battle and changing them to ensure random number generation was the same
Instead of, you know, encapsulating the pseudo random generation inside of a class and passing that around instead
(Also, that hard-coded snippet was on the other side of the project, and unreferenced by the files that actually do the random number stuff. Hooray for action at a distance)
The irony being that removing that line actually made tests more deterministic than they were otherwise
:(
And that's how I've spent my past hour; swearing at a Pokemon simulator. I am the life of the party
 
@DanPantry So we will see another addition to soon?
 
@DanPantry What are you looking at and why is it crap?
 
@Zeta God, no. Unless you'd like to review a 6000 long god class which has a field that can be a boolean, object or array of objects depending on what state it is in.
(this will take a long time to load)
 
I also just now realized that you pinged me two days ago about something C++ or Rust, but I forgot
 
9:19 PM
@DanPantry A god class with Schrödinger types?
 
It's taken me a while to mine the information at the above Code Review post, and I realize now that I didn't really need to ask this question. Most answers are already there. Feel free to delete it, or use it for further educational purposes if you have anything to add. But thanks for the time, effort, and clarifications. — davypough 22 secs ago
 
@Zeta Sounds like JavaScript, no?
They even indent using tabs, the heathens
5
@skiwi I believe there was a conversation going on about C++, you were confused that you couldn't use a std::optional in C++ with reference types because you could in Rust
And then I explained that I had never actually seen Option<&Type> in Rust. ever.
 
@DanPantry Right
What about returning an Option<&Type>?
I can see your argument about taking an Option<&Type> being nonsense
 
@DanPantry That's... That's...
 
Remember that it's.. hard to return borrows in Rust, @skiwi
 
9:22 PM
0
Q: Simple Sinatra app that acts as a webhook for an api.ai chatbot

m90I'm in the process of learning Ruby which I never used. I've built quite a few web applications in different languages, but this is my first time using Ruby. Things work, I enjoy writing Ruby, but I feel I might be missing some of its idioms. This is a simple Sinatra app that acts as a webhook f...

0
Q: Javascript based War card game

RobertI'm working on a game of War for a potential employer and I was hoping someone could review my code and provide feedback on my code. HTML/CSS <!doctype html> <html lang="en"> <head> <title></title> <style> .card{ position: relative; ...

0
Q: Simple Graph in Python

Tomasz MadryJust the beginning of graphs API in Python: # Simple graph API in Python, implementation uses adjacent lists. # Classes: Graph, Depth_first_search, Depth_first_paths # Usage: # Creating new graph: gr1 = Graph(v) - creates new graph with no edges and v vertices; # Search object: gr2 = Depth_firs...

 
You'd have to return Option<Box<T>>
 
Right, so you need to use the heap
 
And that makes sense, but there's almost never a scenario where you would do that (in my experience)
 
Wow. I know feel a lot better about my own old god-class. Only 8% of that monster.
 
In C++ you can also return an std::optional<T*> or std::optional<std::unique_ptr<T>> but I don't know
 
9:23 PM
@skiwi The point was that in Rust (as well as C++) you'd have to wrap a reference type in SOMETHING to get it to be returnable in an option type
 
@DanPantry And that's not trivial :P
 
Well, in Rust it is, but that's because Rust is the best language in the world.
/s
 
Is this still about GetDatabaseByName?
 
IDK
ask skiwi :P
I missed the first half of that discussion. I just heard rust and my ears pricked up
 
@skiwi std::reference_wrapper would help there. It is easy to use
 
9:41 PM
@Incomputable your post-increment should return copy.
 
@Zeta I believe it actually does.
it might be hard to see because my IDE messes up T& with T &, haven't had desire to deal with it yet
 
I might be too tired, but I think it doesn't at the moment:
    preprocessing_iterator operator++(int)
    {
        auto copy = *this;
        ++iterator; //might exhibit different behavior sometimes
        return *this;
    }
 
lol, I knew it
 
@Zeta I'm still not getting it. Tired as well, but CR is too great place to be away from.
3
 
9:45 PM
Hehe.
 
from what I know C++14 doesn't allow bypassing copy constructor, and there is no reference sign there, so it should make a copy of *this
 
@Incomputable But you're defining a post-increment here.
preprocessing_iterator before = foo;
preprocessing_iterator current = foo++;
assert(before == current); // well, apart from internal shenengians
 
0
Q: MVC: A manager for a changeable controller

Sas LucaIn my program I have a Controller that is sometimes changed and Views should react to that changed. I created a simple manager in order to accomplish this. It works by holding a list of all views interested in the current controller. Before anyone asks I am using Lombok, that is why I have the "v...

 
@Zeta great example, thanks. Gonna nuke that bug right now
 
To be honest, my brain -Wall just set -Wunused-variable on copy. Otherwise I wouldn't have seen that either.
 
9:50 PM
@Zeta, I can't turn that mode on on my code, for some reason things slip through. CLion doesn't have great support for C++ now, and I wield build tools pretty poorly. Great to see you around. I'm working on some upgrade for the iterator, so if you don't want to double review, you can wait until the end of the week, it should be done by then.
 
The brain part was just a joke. ^^".
 
Please post this over on codereview.stackexchange.com instead. This is not a programming problem but a request for collaboration. — Mike 'Pomax' Kamermans 48 secs ago
 
@Incomputable Yeah sure. I won't be able to review the iterator in the next 9 hours either way.
 
on another note, today I saw something roughly like the following: for (...) {return a[i].toString();}. That girl was asking why her function was returning toString of only first element.
 
@Incomputable True, I'm using that
 
9:56 PM
@Incomputable That should at lest give a warning, or even an error, since collection<std::string> doesn't have an implicit constructor.
 
@Zeta it's Java class, and people here don't understand how to fix NullPointerException. Some people can't traverse a linked list. Listening to mere warnings is a skill yet to acquire for them
 
@Incomputable lol
@Incomputable I'm not saying you're being mean to them, but it comes across that way, in case that wasn't your intention
 
@DanPantry I didn't show any emotions there. I just told them the code is not doing what you think. Try to think about it and come back. I usually give advice on other side of the screen, so they can't see or hear me laughing. Though I agree with you, sometimes I'm very mean
 
@Incomputable Nah, it was just your wording, DW :)
 
0
Q: Writing my own DBMS: Storing databases

skiwiI've been interested in writing something meaningful in C++ for a long time, yet I had a hard not picking Java or C# for a new project... Now I've found something for which C++ seems to be the right tool: Writing a Database Management System. I'm going to show you the code for the first step: St...

TTLO
(Time To Log Off)
If I've posted code that cannot compile, I'm screwed as I cannot fix it before tomorrow evening
 
10:05 PM
@skiwi you know what is a good thing to do when your code doesn't work and you're logging off? push to prod. /s
 
@DanPantry At work we don't even need to do that :D We're working in a live shared development system and every night that code gets pushed to our internal production servers :D
 
oh god lol
 
It's frowned upon to make big changes by 5pm
 
TTGTB
 
0
Q: Writing my own DBMS: Storing databases

skiwiI've been interested in writing something meaningful in C++ for a long time, yet I had a hard not picking Java or C# for a new project... Now I've found something for which C++ seems to be the right tool: Writing a Database Management System. I'm going to show you the code for the first step: St...

 
10:17 PM
(╯°□°)╯︵ ┻━┻)
2
I do not need your floating point error crap right now, JavaScript
 
10:33 PM
user image
3
 
@Mike'Pomax'Kamermans Requests to explain code are off-topic on Code Review. Furthermore, code must already work correctly as intended to qualify for a review. — 200_success 28 secs ago
 
11:23 PM
Shouldn't question be in CodeReview? — Abhijith 56 secs ago
You have a point there @Abhijith I wasn't aware of the "Code Review Stack Overflow" until you mentioned it. Thanks for that! — Ree 26 secs ago
 
11:43 PM
@davidrook Yep. just delete the tests. if there's no failures there's nothing wrong with your code
@DanPantry got any advice or resources WRT un-jQuerying some JS code? (i.e. making it regular JS)
 
@Phrancis Are you very very sure you don't need the compatibility given by jQuery? If not, don't
I'd answer in more detail but bed is calling, I'll answer any questnios you leave me in about 11 hours
 
0
Q: R lme4 package random effect difficulty

HendrikI am having some difficulties with a linear mixed model implementation. The situation: 17 subjects get tested on both sides of their body (L vs R) at 5 different time points (i1-i5) with 2 tests (A vs B) I want to test whether there is a difference in the values obtained by the 2 tests, correc...

 

« first day (1388 days earlier)      last day (2633 days later) »