« first day (609 days earlier)      last day (3401 days later) » 

12:00 AM
41 more updates and another reboot and then I can resume rubberducking
 
0
Q: Haskell in-place quicksort, Ord a => [a] -> IO [a]

YawarAs noted below, this is more or less a direct translation from http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#C. I'm fairly satisfied with its readability right now compared to the C code; but still wondering how to make it more succinct and clear. Any ideas/opinions? {- In-place quick...

 
12:20 AM
@DanLyons MS releases security and other updates for Windows and Office on Update Tuesday - the second Tuesday of each month.
They are released at 12:00 US central time.
Just install them once a month, and it isn't bad.
 
@rolfl that was a phone post... feel free to downvote if it's all bull - I'm not really addressing any of your concerns there..
Is it common in Java to make types static and use them as objects anyway?
 
@Mat'sMug yes
 
Oh well, bump'd! ;)
 
@Hosch250 I know. The problem is that the updates can get pretty large even for a single month, especially when you have Office installed
 
I have Office 2013. Those updates come through the apps, not through Windows Update.
I have Office 2010 too, not installed at the moment.
Those came through Windows Update.
 
12:34 AM
HashMap, for example, has static inner classes.
 
bottom line, !=
 
Your answer is not completely wrong.
 
the public final array smells
 
what's the difference between the two? I thought at least at a high-level, both languages treated static the same way
 
there's a public final?
Yes, that Stinks....
how did that sneak in.... hmmm
 
12:41 AM
public static class Solution {
    public final Position[] solution
 
That is not supposed to be there.
 
there, undeleted. I don't know the differences between C# and Java
but IDK how relevant it is to Java
I'd expect it to be the same though
public final Position[] solution is a public readonly array field at the end of the day
 
Interested in understanding the difference?
 
sure!
(looks like C# is more "pure" than Java's ;)
 
Except for 'visibility', there's almost no differencec between a static inner class, and a 'default' class in the same package
default visibility is no private, and no public.
Now, a normal 'nested' class (not sstatic), has an internale reference to the instance that contains it.
 
12:47 AM
wait wait wait... what do you mean "no private, no public"?
 
Consider my code, I have public class NQueens { ....
That is a class that is visible everywhere.
 
yeah, and the rest is nested
uh-huh
 
If I had it just class NQueens { then only clases that are in the same package, can see it.
 
isn't NQueens.Solution just as visible?
 
Yes, because I made it public.
 
12:48 AM
ok we're on the same page
 
But, don't got here yet.
Now, the Solutions class is nested (declared inside the NQueens class).
It is also static.
the difference between static and non static, is that non-static instances of Solution can do:
hmmm... this is a poor example....
If i had said....
NQueens myInstance = new NQueens():
then, a non-static nested Solution instance.....
would be able to, in it's methods, say:
NQueens.this.toString()
 
Is this Java or C#?
 
Java makes it harder than it needs to be then. in C# static would simply mean "this class cannot be instantiated"
@SirPython Java
 
because non-static nested instances have a built-in reference to the outer instance that they were created by
 
I'm the C# guy trying to understand why Java static classes aren't "static classes per the C# definition"
 
12:51 AM
A really good example of non-static nested instances, is......
Iterator.
 
I only know static as being accessible from classes without having to create an instance of the class - is this accurate, or is there more to it?
 
It is common to declare a non-static nested class for an iterator, and that iterator is a class that has access to the details of the containing List, or Collection, whatever.
 
@SirPython sounds like it to me
 
@SirPython Mostly close enough.
 
@rolfl wait so you're saying "this" is not the NQueens instance in your example?
2 mins ago, by rolfl
NQueens.this.toString()
^^ I'd expect that to call NQueens.toString... no?
 
12:54 AM
There's some things technically wrong with that, can't say yes/no.
Give me 5 minutes, I will put together an example.
 
ok
 
c# statics have some bizarre behavior around pulling up static members from base types :|
 
mixing static with inheritance sounds like asking for trouble
 
How come in Java you can't access non-static variables from a static context?
 
for example, because Object has a static Equals method, it is perfectly valid to say Foo.Equals - it just executes Object.Equals unless you've defined a Foo.Equals static method with a similar signature
 
12:56 AM
an ambiguous overload wouldn't compile
 
there was some legacy code which had something like that I had to mess with
the class was called Keys, and it had an Equals method which took in two Key objects
 
and the client code was mixing static and instance Equals calls? ugh..
 
someone deleted the Key.Equals method because they didn't think it was used anywhere (but couldn't be bothered to check)
 
wow
 
the code base still compiled because the compiler simply used Object.Equals(object, object) in its stead
but it was buggy because it was now doing a reference comparison instead of a proper equality check for Key objects
even though all references were explicitly Keys.Equals(k1, k2)
I would have expected it to fail compilation because Keys no longer had Equals
 
12:59 AM
everything has Equals ..and GetHashCode
 
@Mat'sMug - ideone.com/kfJRye
 
I'm talking about a static method, though
 
@Mat's, note line 19.
 
You can declare classes inside classes?!
 
Of course.
 
1:01 AM
I need to safe this code for future reference.
 
nested types are allowed in .net too
 
@rolfl Don't you need to "@Override" the "toString" methods?
 
@SirPython - one person at a time... let me get what I want to get over to Mat's first.
 
Sorry, I didn't realize.
 
	return "I am normal " + this.getClass() + " " + Ideone.this.getClass();
Line 19
 
1:03 AM
default toString implementation prints "class NameOfClass"?
 
the toString() method of the class prints it's name, yes.
 
with the word "class"
 
No.....
Yes?
huh.
 
> I am class Ideone
threw me off a bit - sorry
 
Yes.....
    System.out.println(new Integer(0).getClass());
prints
 
1:05 AM
getClass gets the most derived type, right?
 
class java.lang.Integer
Yes.
 
== GetType()
 
The actual class of the immediate instance.
 
and the dollar signs are ... would-be-dots?
 
Java uses the $ to separate multiple classes declared in the same file.
'Anonymous' classes get numbers.....
It is common, for example, to see things like my.package.ClassName$3
That would be the 3rd anonymous class in the class/file ClassName.java
 
1:08 AM
ugh.. so Ideone in Ideone$InnerStatic is the file's name??
no.. yes?
 
@Mat'sMug Yes, and it is 'jarred' up in that format.
If you were to compile that code, you would have the files:
Ideone.class
Ideone$InnerNormal.class
Ideone$InnerStatic.class
Those files are then typically zipped up in to a jar file.
 
God I love .net namespaces
 
If there was a 'package' for the file, like "my.package", then those files would all be in the sub directory: my/package/Ideone*
 
so back at the ranch..
> return "I am normal " + this.getClass() + " " + Ideone.this.getClass();
 
Regardless, we are way off....
Correct, the part that is interesting is:
 + " " + Ideone.this.getClass();
 
1:11 AM
yes. define "this" in this context
 
That only can work in the Normal version, and not the Static version.
In the InnerNormal inner class, a bare this refers to the current InnerNormal instance
 
that I get
Ideone.this would refer to the containing instance
 
But, the Ideone.this refers to the Ideone instance that 'owns' the InnerNormal
 
instance, right?
right
 
That is the difference between the static and non-static.
non-static contain an embedded (and often forotten) reference to the outer isntance.
 
1:13 AM
and.. the static one can't access its "parent" object
 
(people somtimes have bugs where they have a long-standing variable pointing to an inner instance, and the outer instance cannot be GC'd as a result.
@Mat'sMug Not that it can't access it's parent, but it does not even have a parent,.
So, for example, let me change the code slightly......
 
0
Q: MVVM, Navigation, and More

Hosch250Continuation of Correct MVVM format. This is what I have done so far, and of course it works: To start with, this is my MainPage.xaml: <Grid Background="White"> <Grid.RowDefinitions> <RowDefinition Height="100" x:Name="TitleRow"/> <RowDefinition Height="*" x:Name="DataRow"/>...

 
because it's a static class, right
 
@Mat'sMug - to illustrate what I was talking about with the static methods: ideone.com/3u4bCs
 
@Mat'sMug Right....
now, see:
I have added a 'name' to the Ideone class.
Also a method getName().
Notice how the inner class can call that method without any special tricks....
(in the toString of InnerNormal)
Now, if you are an ArrayList, and you have an (or many) Iterator (an inner non-static instance), it can access all the private content of the ArrayList with 'impunity' and without having to have a 'declared' instance to work from.
it is all 'just there'.
But, it works the other way around too, and this is the reason I use it for my NQueens solution....
the outer class has access to all the private content on the inner class too.
 
1:20 AM
yeah
 
which is not possible with any other mechanism for classes in Java.
So, my NQueens instance can see and do things to the privates in the Solution, for example.
But noone else can.
If I declared the Solution to be in a different file (not nested), then I would have to create infrastructure for the NQueens class to manipulate the content.
Also, for the purpose of Code Review, it is convenient that you can copy/paste just one block and it all just works.
You will notice that I made the constructors private for the two nested classes.... only NQueens can create instances, even though anyone can see them.
And, apart from the private/public messup, (I even do a defensive copy), the solutions are completely encapsulated.
 
@rolfl true that
 
Sorry, slow to +1
@SirPython About @Override - no, you don't have to... its nice-to-have, but nowdays normally the IDE puts that in for you. I was not using an IDE, but typing by hand, and forgot.
 
@rolfl huh, they changed the notifications, it says "code edited on answer"
the @Override annotation has no actual meaning?
 
1:36 AM
It helps with documentation, and that's about it, for the moment
33
Q: What does @Override mean?

Woong-Sup Jungpublic class NaiveAlien extends Alien { @Override public void harvest(){} } I was trying to understand my friend's code, and I do not get the syntax, @Override in the code. What does that do and why do we need in coding? Thanks.

Also, it helps when you change your code, so that if you change the signature of the 'parent' method, the child method is no longer overriding anything, and will not compile.
(until you change the child signature, or remove the @Override.
Dinner time
 
Oh - so putting the "@Override" could just cause more problems?
 
^^ gives you compiler warnings, per that SO answer
the more I learn on Java, the more I love .net and C#
 
Yes, but then @rolfl mentioned that if you change the parent signature, @Override causes an error.
 
I wish compiler warnings and errors addressed me as "dude". — CSJ Dec 3 '13 at 14:59
 
That would be nice. Kind of like a compiler Siri.
 
1:41 AM
error CS0001: dude, wtf
 
Reeeaall helpful.
 
Hello, @Hosch250
 
Hi.
 
@RubberDuck we need a "WTF" code inspection. Seriously.
 
I got your message about the Python Chess.
 
1:46 AM
OK.
What did you think?
I think I'm going to post that for review too.
 
There's been a lot of work done to it already, and it's kind of hard for me to understand what is happening and where. My apologies, but I'm not that good with already written code in big lengths.
 
@SirPython Me either.
I don't blame you.
Really, though, it is quite simple.
If you read it a couple times, it should start falling together.
 
I'm looking for the code right now
 
You don't need to do it if you don't want, though.
I'll post a link
 
I foudn it
I'd be happy to work with you on it, I just need some time to get prepared.
And where did you get that "Enum" library?
 
1:50 AM
Python 3.4.
 
Ah.
 
Actually, I have 2 weeks before classes start, and I need to finish what I am doing in my app before then.
 
Is it part of an assignment?
 
So you are welcome to work on it, but I probably won't be able to do much.
No, I just have everything in my head, and I don't want to lose it.
 
Alright. I'll probably work on it, considering this will be my first collaboration on GitHub.
 
1:54 AM
Have fun!
I need to do chores now, and I want to get to bed early.
 
Alright. See you later then.
 
I might pop back in in about 10 minutes.
@SirPython The only method that isn't essentially done is GetBestMoves().
You may need to improve EvalGameState(), but that is basically done.
If you need to return an immutable array, use a tuple; otherwise, use an array.
You might also need to do the Mate() method. I don't remember if that has bugs.
I think Checkmate might.
 
2:25 AM
0
Q: Validate Move Pattern Chess

Hosch250A while ago, I was working on a chess project with a couple other people. In the end, I wrote all but a couple of the lines of code, including these: class Piece(list): def IsValidMovePattern(self, FromCoord, ToCoord): print(self, "Validation not done") return False cla...

 
@rolfl I just edited the tag wiki for .
I don't know if we really need it - I just posted question #13.
Oh, I see you asked #12.
OK.
Time to do dishes. See you later.
 
What makes you say that @Mat'sMug?
 
in VBA, 43 mins ago, by Phrancis
@Mat'sMug I dare you to name a method or class (or even variable) wtfIsThisShit in Rubberduck
WtfIsThisShitInspection : IInspection
I have yet to find what Easter egg will trigger it though
priority level is in the negative though ;)
 
3:03 AM
1
Q: Binary heap with O(1) lookup and O(lgn) change key

LemonPiI needed a priority queue that allowed efficient searching and changing of keys. I tried std::priority_queue, but the interface was extremely limiting. Not being able to search for existence wasn't a big deal since I could separately keep a std::unordered_set<key_type> around, but not being able ...

 
Another great answer by ChrisWue: codereview.stackexchange.com/a/75540/34073
 
4:05 AM
Since when was this place active?
 
What place?
 
Here.
 
zzz...
 
Lmao. That's priceless @Mat'sMug! I'm sure there's something in the transcript. GoTo line number perhaps...
 
 
1 hour later…
5:40 AM
It's a little sad how I've got such a big problem with such simple things...
stares at my CSS
What are you people up to?
 
@Gemtastic I'm pretty good with CSS.
 
@Hosch250 That's nice. Can I bother you with really simple stuff?
 
Sure.
 
Like; I'm trying to get three divs in line inside a wrapping div
 
I'm awful tired, so I may not be able to solve your problem.
 
5:44 AM
I'll show you a fiddle, one sec
 
Put it in a JSFiddle, and I'll take a look.
 
And you want them to all line up?
 
@Hosch250 You should have seen me yesterday. I just couldn't get the a text to be overridden when you hovered the parent li
 
OK, anyway?
 
5:47 AM
@Hosch250 I want the top of each div to align next to one another
 
So they are vertically aligned?
OK.
 
As it is now, it looks (I can't say I'm sure what's happening but) theya re aligned to the last item on the menu
No I want them horizontally aligned
 
That is what I meant.
 
Ok :)
As it is now, it seems content in the two sibling divs are aligning to the content of the first sibling div
 
5:50 AM
I think you sent me the wrong fiddle
 
Waits for applause
Hmm?
OK.
 
You forgot to save your changes
So you just sent my original right back at me
:P
 
OK, I had to hit Update.
That good?
 
Yep
 
See what I did?
 
5:51 AM
Could you also fix it with ading attributes for top margin?
 
I think I can actually do better too.
 
Yes, I saw it. Only a small change with the vertical align attribute :)
 
One-liner there.
Waits for more applause
For simple questions like these, just do a quick search or look through W3Schools.
They are not the official W3C, and some devs hate them, but they are really handy for checking stuff like this.
Just be sure to validate your code with the validators at W3C too.
 
@Hosch250 I know that. I tried following a tutorial on horisontal CSS menu. All hell broke lose
@Hosch250 I don't see the change
 
Don't you see the gray line at the top?
 
5:55 AM
Ah, the padding top
 
I set the padding-top in the body element id.
 
On the parent div
 
Yeah.
That sets all at once.
If you consider each element as a block, margin pushes the edge in, while padding leaves a space protecting stacked blocks from getting too close to the edge.
Questions answered?
I need to go now, so...
I guess they'd better be.
Bye.
 
@Hosch250 Yeah, pretty much.
I thought the divs would automatically align to the top
But obviously they aren't
 
 
1 hour later…
7:07 AM
0
Q: Is my model taking on the responsibility of the view?

Matt GI'm a freshman in college going for a computer science degree and I'm taking some time on my own to learn design patterns in Java. To do this, I'm writing a small platforming game, and so far I've written the basic "game loop" (what I'm considering to be the controller), the "game panel" (the vie...

 
 
4 hours later…
10:46 AM
Monking
 
0
Q: Get line from string function

EdeniaI have asked a previous question but at the last moment I realized that the code does not work as intended as it has some small bugs. I got some ideas for improvement though, but they didn't seem to work as well, so I decided to re-write it. This time, I was following the logic all the time. Wh...

 
11:02 AM
0
Q: Why would thread sleep cause more time for format and file write

Naveen SharmaI was trying to measure times taken to format a log string and time taken to write it to file. When I do it in a continuous loop, it take about 1.5 micro seconds to format and same to write with flush on each iteration. However, I tried introducing some delay of 1 microsecond to get more close to...

 
@CaptainObvious Is your question taking the responsibility of having a good title?
 
11:20 AM
My latest answer was edited twice because of mistakes. I should really learn to type properly ^^"
 
Thanks santa@rolfl for the checkmark!
Monking @SimonAndréForsberg and @Morwenn
 
@skiwi Monking Skiwy My Dear.
 
So how exactly did this trippin happen? gfycat.com/FatFlakyDartfrog
 
11:53 AM
0
Q: Basic 30 TPS server loop

CroccyI've created a console server which is supposed to update 30 times per second, I'd like you to review it and also I'm curious about the accuracy of the server's loop. using System; using System.Diagnostics; using System.Threading; namespace ZGServer { class Program { //---------...

 
12:10 PM
Hey together
@skiwi I am starting to degenerate mentally while looking at this image. My reviews will be worse, worse, worse .....
 
hehe
 
12:38 PM
lol
6
Q: Grammatically correct sentence where "you're" and "your" can be interchanged?

Trevor HickeyMost grammar checkers are capable of detecting the the misuse of "your" and "you're"; providing the necessary correction. I'm curious though, is there any sentence that can be constructed where replacing "your" with "you're" keeps the sentence grammatically correct, but changes the meaning? ...

and, oops
27
Q: Were the Space Shuttle's computers incapable of handling end-of-year roll-overs?

CalmariusThere is a claim circulating on the Facebook that space shuttles couldn't fly near the end of the year because its onboard computers cannot handle year turnover. Searching for the claim I found Y2K-like fears create shuttle scheduling crunch, which says, The space shuttle's computer software...

 
0
Q: Project Euler #13 in Swift - Large sum

Mehdi.SqalliI just finished Project Euler #13 in Swift, and since there is not any version yet on Code Review, I would like to have some comments on what I did to try to improve it. Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 3710728753390210279879799822...

 
This is also the basis for the "grammar" meme (which is really about spelling): Grammar: the difference between knowing your shit and knowing you're shit.Alan Munn 11 hours ago
4
 
1:23 PM
@rolfl I don't want to read your N-Queens question yet, but I just have a question. Does your code find all solutions, or just one (random?) solution?
 
All
 
I have validated the 8-queens, there's 92.
 
OK, great. Then I know what to write in my test ;)
I have an approach in mind.
 
Technically that consists of 12 'fundamental' solutions, where some are mirror image, or rotations of tothers.
 
1:25 PM
I don't think it will be easy for me to detect those mirrors and rotations.
 
I felt the same, so I didn't ;-)
Do you want to know a ballpark of how mine performed?
 
a ballpark?
I don't want to know your approach just yet
 
Not my approach, but my times
oops...
 
aND YOUR CAPS-LOCK
sure, your times would be interesting
 
Solved 1 size with 1 solutions
Ran task: Size 1 in 0.376ms
Solved 2 size with 0 solutions
Ran task: Size 2 in 0.246ms
Solved 3 size with 0 solutions
Ran task: Size 3 in 0.244ms
Solved 4 size with 2 solutions
Ran task: Size 4 in 0.241ms
Solved 5 size with 10 solutions
Ran task: Size 5 in 0.171ms
Solved 6 size with 4 solutions
Ran task: Size 6 in 0.135ms
Solved 7 size with 40 solutions
Ran task: Size 7 in 0.156ms
Solved 8 size with 92 solutions
Ran task: Size 8 in 0.230ms
Solved 9 size with 352 solutions
15 took > 60 seconds for me.
 
1:28 PM
interesting that size 6 is the fastest.... JVM warm-up?
 
the size < 8 times are all pretty much the same, and very fast.
I did some warmups before that, but, it could be.
Ran task: WarmUp 100x5 in 4.989ms
Ran task: WarmUp 100x8 in 12.117ms
 
I don't think I will beat your speed, but I hope I won't be too slow.
 
I was a little disappointed with my big-O ....
 
N-Queens is at least NP-hard, isn't it?
looks like you have exponential time, which is what I would expect.
 
It's not formally declared NP that I can find, but, yes
 
1:56 PM
0
Q: Quicksort - follow-up

morbidCodeThis is a follow-up to Quicksort function . Like the previous code, this does not optimize for containers with extreme amounts of duplicate elements. How to improve this code, particularly iterators? template<typename C> void insertion_sort(C low, C high) { for (auto i = low; i < high; ...

 
2:11 PM
0
Q: generate a number plate and generate a random speed and see if it's speeding

user2635139import random, string, time class Car: def init(self): self.plate = self.genPlate() self.limit = 60 self.checkSpeeding() def checkSpeeding(self): self.speeding = random.randint(0, 1) if self.speeding: self.speed = random.randint(self.limit+3, self.li...

 
2:27 PM
@rolfl On your N-Queens, I'm not sure yet how exactly it's applicable, but couldn't a BitSet be useful?
 
BiSet may be useful if I get to solving where N > 64, but, there's 22,317,699,616,364,044 solutions to N=26, so I don't think I will ever make it to N=32... and as a result, a simple int will be fine ;-)
 
Welp, ok, makes sense :)
My C drive was getting at a critical point of < 1 GB remaining free space...
Now I discovered I've never cleaned up my Recycle Bin (it's not done with disk cleanup) and there's 20GB in there!
 

« first day (609 days earlier)      last day (3401 days later) »