« first day (785 days earlier)      last day (3226 days later) » 

12:02 PM
@Quill actually, the argument about the commas is wrong
in Python there's nothing wrong with trailing commas
so you can put comma at the end of all key=value params, and still easily comment out whichever if you need
and your suggestion to remove the trailing comma is wrong too, as there's nothing wrong with that comma
 
Monkin'
 
Monkin'
 
Monkin'
 
Monkin'
 
12:07 PM
Monkin'
 
12:20 PM
I had no idea there is anything like code review on stack overflow. :) I will move it if it is required. — Snehks 31 secs ago
 
Duga broke the Monkin' party
 
Everyone was waiting for someone to do it
4
 
finally we can chat again
 
I have some quick C# questions
1. how to replace the underlying list of a BindingList
2. or, how to replace the underlying BindingList of a BindingSource (created with a BindingList instance, null as constructor args)
 
12:24 PM
First, replace C# with Java .... then .... ;-)
 
tell that to the Duck and Mug (it's for their question)
 
It should be simple to swap the binding list out for a binding source, but there is no underlying list for a binding list @janos. It is an IList. I briefly looked into it yesterday.
 
I updated my answer a few minutes ago, I wonder what you think
 
There are lots of ressources (even human...) over there. — Raoul 50 secs ago
 
0
Q: Is it appropriate to reveal solutions to public challenges in comments and answers?

Petr PudlákI've seen a question that ask for a review of a piece of code that solves a public coding challenge (linked in the question). The first comment just discloses the optimal solution without actually giving a proper code review. To me it seems counterproductive as this brings no value, only ruins th...

 
12:36 PM
Hmmm..... I think maybe I should be using BindingList instead of List. Which shouldn't be a hard change. I was just avoiding having the Forms namespace in code that really doesn't have anything to do with forms...
Will think on it, but you're likely to get the checky.
 
0
A: Is it appropriate to reveal solutions to public challenges in comments and answers?

QuillOne can use the >! format for hiding spoilers to problem solutions, and in this case OP could've said something along the lines of: Warning: SPOILERS

 
@Quill You were what, 5 seconds earlier than me?
 
@RubberDuck I think you should stick to your good principles about avoiding the Forms namespace
 
@Mast Yeah, looks like it
 
@janos I could always pull in just that one class with a using directive though, right? That wouldn't be so terrible.
 
12:40 PM
Is a normal site cap affected by meta rep increases?
 
Using BindingList = System.Windows.Forms.BindingList
@Quill There is no meta rep, so no.
 
@RubberDuck doesn't sound good. And replacing the underlying list sounds like a reasonable feature
 
@RubberDuck Thanks
 
Yeah. Maybe you're right. I'm going to try a BindingSource first, then if I feel like using a BindingList simplifies the code I'll try that.
Thank you Professor Duck! You are awesome!! I am into this excel-vba for last 4-5 weeks. Thanks for valuable advices. — Abdul Shiyas 6 mins ago
 
I have one more idea, editing my answer now
 
12:43 PM
Heh... "Professor Duck"
 
What's up with the downvotes?
 
@RubberDuck nice answer there!
 
Thanks! Took too dang long to write...
 
I spent the better half of today on 2 answers
@RubberDuck my final update is just one sentence: If all else fails, you could clear the underlying list and add all elements from the incoming list.
 
That's a though too. Hmm... well, you've given me plenty to think on and it's a good answer.
I'm going to leave it unchecked a little while longer to see if anyone else has anything to add.
 
12:48 PM
+ depending on how you use the getters and setters, you might want to do some defensive copies as appropriate
no rush, really
I hope you'll find a workable solution
 
@RubberDuck Isn't it time for a new name, anyways? ;)
 
also keep in mind that in the SO discussion I linked, the guy strongly recommends always using a BindingSource instead of a BindingList (not too clear though why)
 
@janos Well, what I have works, so there's no rush. I just... idk. Something in my gut tells me it's dirty.
 
Now it's time to try to fit WebSockets into Spring, which usually works via a REST API
 
It's not just your guts: the object nesting effect is ugly
 
1:02 PM
@Vogel612 I think I fixed my answer.
@skiwi Names stick. Changing an avatar is one thing, changing a name makes it harder to recognize people.
 
2
Q: My first application in bash

545H4I am fairly new to bash (I have about 3 months of experience), and now I've written my first real application (sort of). It's a function inside of ~/.bash_profile, but it has an installer. It is called loginfo and it keeps track of when the terminal was used by the user, and allows them to view ...

 
@Mast Don't you remember @ckuhn203?
 
@skiwi that was before his time, I think...
@Mast I did +1 before that...
~back to implementing save-logic....
and after that It'll be time for a new CR question.
and some power-translating :D
 
1:20 PM
Shouldn't at least one solution be already publicly available in the question itself? If the solution is somehow revealed in the answers but not in the question, it sounds like the quest ought to be closed... — nhgrif 15 secs ago
 
@Quill I don't know why people hate spoiler tags. I find them appropriate.
 
@QPaysTaxes it's reasonable to assume that the coder using assert knows how they work, unless there is suspicion that is not the case
 
If you're not compiling with command line, is it safe to assume the IDE you're using is most likely taking care of it?
 
that's true for anything the reader doesn't understand
 
@QPaysTaxes None of your code's production logic should rely on asserts... unless Java is different than any other language I've used...
2
 
1:29 PM
@janos I have no idea.
Ooh! My first shiny gold badge!
 
by the same logic you should advise against a linked list, because a reader who doesn't know how it works might access elements randomly, and then experience unexpected slowness
 
Oh, and, monking, by the way.
 
@QPaysTaxes I think you're making that point very poorly then.
 
if the reader doesn't understand asserts, he should study them, just like everything else
it doesn't make sense to avoid using a tool in your toolbox because somebody might not know how it works without looking in the manual
 
You shouldn't use [insert any programming tool] without first understanding it. With this point, I agree. The point you seem to be making was that janos was wrong for suggesting a tool that the reader might not understand, and with that point, I cannot agree.
 
1:33 PM
assert is a tool in our toolbox called JDK, and there's nothing loose about it
 
What are you even talking about?
Where's the answer/question/etc in question?
 
-1
A: Modular arithmetic

QPaysTaxesWell, I took a good, thorough look, and there's really just two pieces of advice I can give: Comments. Use them. For example, I saw this: for (int x=base; exp>0; exp>>=1) { if ((exp&1) != 0) { result = this.mul(result, x); } x = this.square(x); } What? Maybe I'm just bein...

 
If anything, @QPaysTaxes, you shouldn't be telling janos he shouldn't have made the recommendation. Instead, you should, at best, encourage him to offer a better explanation or a warning, or something.
 
@QPaysTaxes that's a terrible mindset. Instead of avoiding things we don't understand, we should be learning about them.
 
Asserts are an excellent and recommended way to document pre-conditions, and you go against that recommendation on the grounds that some users might not understand how this works in the language
 
1:37 PM
If we have Programmer Bob who doesn't understand asserts, you'd opt to recommend he not use them at all. The rest of us would recommend that Bob take some time out of his day to make sure he fully understands them.
5
And it's probably because you've never had coworkers before, I can only assume.
 
Q, maybe you should take the opportunity to listen to what the professionals in the room are trying to tell you.
Not every 16 year old has the benefit of having access to professionals in a field they enjoy.
9
 
Right. But that's the difference. janos, RubberDuck, and I are all three working professional software developers
 
@janos Remember that it can be turned on/off with a flag though
 
Then go to bed. And dream about the advice we've just given you.
 
Sleep padwan.
 
1:40 PM
@RubberDuck This should be pinned...
 
Because the alternative is, we could have thought "Hey, @QPaysTaxes may not understand the point we're trying to make, so let's just not talk about..."
 
@skiwi when I think of the mistakes I could have avoided if I'd had that kind of resource 15 years ago... man...
 
it seems he really didn't get it :(
 
I have a quick question, regarding the site.
Is it okay to use information from other user's answers if they've been deleted?
 
and he reached that point of denial way too fast
 
1:42 PM
Sometimes I forget that one day I wrote this.
@EthanBierlein Well, @EthanBierlein, how open would you be to converting your answer to a community wiki if we felt you took too much?
 
@EthanBierlein I've done it....
 
Like if I looked at the question and decided 50% or more of the answer was borrowed from the deleted answer and recommended you turn your answer into a community wiki?
 
I wouldn't feel too bad. Although, it's only one or two things, so...
 
That was a bad situation though.
 
@EthanBierlein that would be me ;-) (see at the bottom of the page)
 
1:44 PM
Adding a point or two from a deleted answer seems fine (as long as you're actually contributing some significant points of your own)
Although, I would hope these are points you came up with yourself that are only coincidentally in the other answer.
 
and acknowledge the original author
 
Yup ^^
 
I tend not to read deleted answers to questions I intend to answer until after I've answered.
 
This deleted answer has some useful info though.
Although, the OP can't see deleted answer, so, hmm.
 
Vote to undelete it?
for (int x=base; exp>0; exp>>=1) {
    if ((exp&1) != 0) {
        result = this.mul(result, x);
    }
    x = this.square(x);
}
What is this doing big picture?
I know what every individual line is doing.
Line 2 = if exp is not 2^n
Or rather
... that's just checking if the last bit is a 1 or 0... even or odd
the loop iterates through all the bits
if the bit is 1, result = result * x
This is a confusing way of writing that...
Man, sometimes I just don't understand people's comments:
@nhgrif I was referring to the code being too complex to be worth trying to make readable, not speed. I didn't, however, pick up on mul instead of multiply. I'll add that in. — QPaysTaxes 4 mins ago
"too complex to be worth trying to make readable"
Anyone care to venture an explanation?
 
1:57 PM
This should be on code review. — pyb 38 secs ago
@pyb This question is a mess, but from my skimming, the user seems to be suggesting the code does not work? Besides, this question is 3 years old and already has an accepted answer. I doubt the asker is still looking for solutions. Please don't recommend these sorts of questions to Code Review. — nhgrif 30 secs ago
 
You can go to sleep. You don't have to reply to things immediately. Especially things that weren't even critiques but simply extra information for anyone who cares to read the answer.
If you're too tired to care, then perhaps don't post answers... You certainly shouldn't post answers that you feel aren't worthy of upvotes...
5
> Incidentally, please don't accept this answer. I'd feel really guilty getting that much rep for what amounts to nothing at all.
 
@QPaysTaxes I'm 16 and have co-worker-programmers
It doesn't really matter how old you are, rather your maturity
(Sorry for the ping)
Also, my world clock says it's 10am over there
 
0
Q: Loop through and display base64 data as a new canvas element

SeekerI want to place all the base64 data into their own respective canvas, I tried a lot of examples (on stackoverflow) but they didnt work and only managed to display one and all other image data got ignored $.when.apply(null, promises).done(function() { // when promises fulfilled for (var i = 0; i

 
2:15 PM
Heh, relevant to this morning's earlier debate:
"I don't know how to open files, read lines and add them to arrays" Then you need to learn to do that. Don't freeze like a deer in the headlights. Learn. — matt 1 hour ago
3
 
2:25 PM
0
Q: Multithreaded scoreboard for different levels

Johny19For an assignment I had to create a highly multithreaded scoreboard for a multi level game. So everytime a user adds a score if the level doesn't exist, it gets created had-oc. Important point: a user CANNOT appear twice in the 15 best score... No database or disk persistance was permitted (so ev...

 
2:39 PM
I'm voting to close this question as off-topic because questions about improving working code belong on Code Review SE — ali_m 58 secs ago
 
@skiwi Who?
 
Since you want feedback on working code you would be better off asking at Code Review. — jpw 1 min ago
 
@QPaysTaxes Bit short?
@QPaysTaxes Don't drink and SE. Don't do it when tired either.
So my point still stands.
 
2:54 PM
that's a nice number, you should keep it.
 
You can't go beyond the ultimate.
 
I'm still chuckling about the "Professor Duck" thing. I like it. Has a ring to it.
 
daffy is better
 
Tempted to boot my laptop just to star that.
Elections start tomorrow, is everyone excited?
cough @rolfl cough
=;)-
 
3:10 PM
@RubberDuck excited and still thinking about whether I should go for it or not..
 
@RubberDuck I'm thinking about nominating someone, not sure if I should.
 
@Mast If you think they'd make a good (or even great) mod, go for it
they'll not be in the election until they say the want to run anyways.
@QPaysTaxes tomorrow ...
have a little patience :)
 
Should there be some long defence statement for why a certain person would be a great mod?
 
@Mast you may want to check out the last SO election's nominations :)
 
@Vogel612 I did, and I almost concluded I shouldn't nominate but leave it to the users themselves.
 
3:38 PM
0
Q: jQuery: My code could be improved?

Uptop 14I would like to know if my current jQuery code could be improved? If Yes, can you give me an improvement? $(document).ready(function($) { $("#bannerPickerToggleIcon").click(function(e) { e.preventDefault(); $("#bannerPicker").slideToggle(); $("this").css({"display...

 
sgl_try
{
    sgl_try
    {
        sgl_throw(out_of_range);
    }
    sgl_catch (logic_error)
    {
        printf("\nCaught exception: logic error\n");
    }
    sgl_endtry
}
sgl_catch (out_of_range)
{
    printf("\nCaught exception: out of range error\n");
}
sgl_endtry
I love C.
 
inb4 large java question
 
This gives 4 rather massive interfaces to work upon: [...] Why 3? Because ....
I guess s/4/3/
 
~brb smoothing that out
 
3:51 PM
0
Q: Hash table for Coursera's Algorithms course

creationistI implemented a hash table for Coursera's Algorithms and Design class. I am looking for feedback on coding style and other improvements. I want to practice C++ coding but I see myself drifting to C and functional programming a lot. Any advice on switching would be very helpful. The problem is as...

1
Q: Translating the Rubberduck - Übersetzen der Gummiente - Part 1: Modelling

Vogel612So I have committed to making a German translation for the guys over at Rubberduck, which is localized via .resx files. Now these files are basically XML-Files with a certain, rather simple document structure: <root> <!-- Snip --> <data name="Resource_Key"> <value>Resource Value</value

 
I fixed it.
 
@QPaysTaxes I'm always up for flagging.
 
If you flag a question as "Should be closed..." does it go in the review queue?
 
@SirPython If you flag it, it goes into the close vote review queue afaik.
So people can translate your flags into VTC.
What would be an appropriate for an inventory management system?
 
4:04 PM
@skiwi thanks @CaptainObvious
 
@skiwi meh
I'm not going to create that tag.
@QPaysTaxes I'm talking CR here.
To hell with it, posted.
I should really get into automated unit testing with C++.
But it's so darn hard to set-up.
 
1
Q: Hybrid Lock Implementation

Dan AllenI have an algorithm that is painfully slow if I use 'pure' mutexes. That's because most of the critical sections are short and far shorter than the work to sleep a thread. However it is also slower to allow the occasion long critical section cause long spins in other thread(s). This class is inte...

1
Q: Inventorizing the universe

MastI recently started re-factoring a project I hadn't touched in many months. The original purpose was to be an inventory management system for a game I played, Ogame. In this game you play inside a universe filled with galaxies, with are filled with systems, which are filled with planets. Those pl...

0
Q: Is there any potential bug or error in this backup from S3 to GC script?

toyI'm working on a script to backup S3 to GC everyday. I'm not sure if my script has any potential bug or error that might have destroyed anything from both sides? The data is quite sensitive and I don't want o mess it up. Anything is welcomed. #!/bin/sh if hash aws 2>/dev/null; then echo 'a...

 
@CaptainObvious How's that for a catchy title by the way?
@QPaysTaxes You realize you're not really explaining why certain choices are 'better'?
You're well on your way with most, but it's lacking at points.
@QPaysTaxes Just trying to help you write better answers, nothing more.
 
That shouldn't be, but it could happen, yes.
@skiwi Make it a proposal: answerreview.SE
 
4:14 PM
@Mast Won't work in all seriousness though :P
Oooooh nice @Mast it's for OGame or at least related
 
Thanks a lot for replying! I'm very sorry! I have typed the code on the fly — Johny19 38 secs ago
TIDL
 
@Mast Before Main.cpp it might be helpful to add a screenshot of how the design looks :)
@rolfl "Today I didn't learn"?
Or is it console based, then screenshots don't matter :P
 
@skiwi things I don't like :(
now worse:
 
@skiwi Run it, ti's CLI
 
Thanks a lot for replying! I'm very sorry!! I have copy pasted the code from the wrong version..... I have indeed used putIfAbsent also for the outer map.. I have updated the question with the correct code. (but thank you for the java 8 tips this is very useful !) — Johny19 2 mins ago
 
4:17 PM
int Planet::getPlanet()
{
    return x, y, z, Mlvl, Clvl, Dlvl, Plvl, Mstor, Cstor, Dstor;
}
That's some C++ sorcery I don't know about :P
 
Yea, that's quite arcane. Probably not best practice, not sure.
 
Very short answer... Not the one to review C++ here
0
A: Inventorizing the universe

skiwiCommenting on the CSV format and reader, I would advice to change the following format: 1:2:12;20;18;15;0;7;6;4; to "1:2:12";20;18;15;0;7;6;4; As you can see I'm treating the planet coordinates as a String rather than how it's done now and this will eliminate the need to have both a :...

@Mast It's funny, I have a very very very old script here called planettracker that's also for OGame :P
 
Internet goes down. Chaos ensues... Go the F outside child!
 
@QPaysTaxes Probably.
 
My house
 
4:24 PM
@RubberDuck Where can I download outside?
 
Exactly.
 
Damn, this coding is the best, it's SQL, HTML and PHP mixed in one file
 
@QPaysTaxes Janos has commented on your comment to
0
A: Modular arithmetic

QPaysTaxesWell, I took a good, thorough look, and there's really just two pieces of advice I can give: Comments. Use them. For example, I saw this: for (int x=base; exp>0; exp>>=1) { if ((exp&1) != 0) { result = this.mul(result, x); } x = this.square(x); } What? Maybe I'm just bein...

but forgot to mention you.
@QPaysTaxes I forgot. Sure, you've got it.
But not to me :(
 
@QPaysTaxes Not sure if jQuery was around already back then
 
4:40 PM
@QPaysTaxes I've found it. And disagree with you. The code must be working with asserts either on or off. That's the nice thing about it. If I expect problems, I switch them on.
I see, but you can that I am careful. I'm using Preconditions.checkArgument on public methods and asserts on private ones.
OK.
 
4:57 PM
I've just wrote a test and found a bug in IntModulus.
 
Since there's been so much drama over asserts, I thought that I'd weigh in
 
This makes sense. What I mean is something like
base = mod(base);
// As now base>=0, it can be only 0 or 1 when we return here.
if (base<=1) return base;
I guess, the same code in IntModulus makes more sense, when two methods are used.
The nice thing about asserts is that the ideally never happen. So my laziness to add a message makes sense... however, I can see I was being toooooo lazy.
WTF does %w mean? An advanced obfuscation?
 
5:15 PM
If you want perl, just use perl.
3
 
:D:D
 
@words = qw/draft open closed/;
 
I see. Nice sugar.
 
@QPaysTaxes All it says is "2 days ago" but I don't see how any time at all invalidates my point.
But your original version of the answer recommended that people not upvote it.
 
5:23 PM
Who cares if you get the bounty?
If you really don't want the bounty, don't post an answer.
I am 188 upvotes away from 20k on SO.
 
Don't you mean 188 rep?
 
err, yeah, 188 rep
I can't get it today (without earning a bounty), as I already earned 85 rep today.
 
sure you can... accepts!
 
Well, I do have two questions that should be marked as accepted...
4
A: What's the best way to declare a list of scalar values in Swift

nhgrifThe enum would be preferred for multiple reasons. First, the enum actually ends up with a smaller memory footprint. This is because Swift optimizing enum values into a single byte (no matter what the raw value is), and we only get the full value out of it when we call rawValue on the enum val...

4
A: A best practice for multithreading within a function that returns a value, Swift

nhgrifThere are three easy and completely expect approaches to this problem in Swift/Objective-C development, and neither of these solutions involve the method returning the value directly. You could write code that waited for the asynchronous part to complete (blocking a thread) and then return the v...

 
I've changed my mind.
I'm writing a preprocesser for Python instead of JS.
 
5:32 PM
Oh, I forgot about this fairly good answer I wrote recently that someone just found:
5
A: NSString Address issue

nhgrifAnd why should str1, str2, str3 all reside at different memory addresses? They're all the same immutable string. See bbum's comment here: Right... one implementation detail of relevant interest (but, by no means, invalidates the answer in anyway); [[NSString alloc] initWithString:@"Hello wo...

 
@QPaysTaxes That should be
 
This stuff makes me cringe...
 
At least that one is marked accepted.
 
$q = mysql_query("SELECT *, ((4 * 30 * IFNULL(`Metal Mine`,0) * POWER(1.1,IFNULL(`Metal Mine`,0))) + (4 * 30)) AS metalproduction, ((4 * 20 * IFNULL(`Crystal Mine`,0) * POWER(1.1,IFNULL(`Crystal Mine`,0))) + (4 * 15)) AS crystalproduction, (4 * 10 * IFNULL(`Deuterium Synthesizer`,0) * POWER(1.1,IFNULL(`Deuterium Synthesizer`,0)) * 1.36) AS deuteriumproduction, (((4 * 30 * IFNULL(`Metal Mine`,0) * POWER(1.1,IFNULL(`Metal Mine`,0))) + (4 * 30)) + (1.5 * ((4 * 20 * IFNULL(`Crystal Mine`,0) * POWER(1.1,IFNULL(`Crystal Mine`,0))) + (4 * 15))) + (3 * (4 * 10 * IFNULL(`Deuterium Synthesizer`,0) * 
(That's my code :()
 
@skiwi pukes
 
5:32 PM
I started to read IFNULL('Metal Mine'.... as "FULL METAL JACKET"...
 
@skiwi That's perfectly clear!
 
@skiwi This isn't how you post Code Review questions.
 
@nhgrif It's not something I'm proud of and want to have reviewed either ;)
 
@QPaysTaxes I'm going to repost IntModulus. What else should I do, except for adding a few comments?
 
@maaartinus This needs big picture comments
        for (long x=base; exp>0; exp>>=1) {
            if ((exp&1) != 0) result = mul(result, x);
            x = square(x);
        }
Or... at a minimum, a comment in the form of a URL describing the algorithm
 
5:38 PM
@nhgrif Yes, added a link to en.wikipedia.org/wiki/…
 
(as well as the other cases you use similar things)
 
Sure, this time IntModulus only and there's nothing else complicated there, is it?
@QPaysTaxes No problem, no need to hurry.
 
5:54 PM
You are asking for recommending a language or framework, that's the same issue. SO is rather strict when it comes to the possibility of starting a debate. Because of this questions get closed or put on hold quite easily, like it happened to yours. To get recommendations or opinions you should use your favorite search engine. Then come back and present your "big picture" of how you want to solve a certain problem. Sometimes it is even a better idea to present this at codereview. But no matter where you present it: give as many details as possible. — Marged 50 secs ago
Since your code is working and you're looking for a better/cleaner implementation, it might be better to post it on (Code Review)[codereview.stackexchange.com/]Stryner 5 secs ago
 

« first day (785 days earlier)      last day (3226 days later) »