« first day (367 days earlier)      last day (3652 days later) » 

11:04 AM
0
Q: FizzBuzz single line LINQ

Overly ExcessiveNow FizzBuzz itself isn't a big challenge but I agree that it can be a good tool to see if someone can code or not, I wanted to practice my LINQ a little bit so here's my single line FizzBuzz solution. Enumerable.Range(1,100).Select( n => (n % 15 ...

 
Wanna improve your rank on the voters page? Start with this answer:
3
0
A: Feedback on python parser

amonYou cannot get rid of those if-else checks, but you can get rid of the nesting. For example: if foo: if bar: return foo + bar could be flattened to if not foo: return None if not bar: return None return foo + bar While this is is in fact longer, such code tends to be eas...

 
@amon Subtle ;-)
I'm #2 , so I don't need to ;-)
 
@amon Want to improve your rank on the users page? Start with this question:
8
Q: We'll be counting stars

Simon André ForsbergLately, I've been, I've been losing sleep Dreaming about the things that we could be But baby, I've been, I've been praying hard, Said, no more counting dollars We'll be counting stars, yeah we'll be counting stars (One Republic - Counting Stars) The 2nd Monitor is known to be a quite star-happy...

 
@rolfl why settle with #2 if you could be #1? >:D Anyway, I'm just trying to correct that recent vote activity graph.
 
@amon let me gues your at place 1?
 
11:11 AM
@chillworld - using finalize() .... I have only ever used it for debugging.
I cannot see a reason for using it in a regular code-path.
 
@rolfl so the second option is the best?
 
If you really need to trap the GC process, then use a weak reference, and trap it on a referenceQueue
 
Want to improve your rank, anyone? Start with my unaccepted questions!
 
@skiwi The only thing I want to improve is mine knownledge :)
 
Want to improve your knowledge, anyone? Start with answering my questions correctly!
Like that?
 
11:20 AM
Right, @chillworld - Gone through the question, and the review.
finalize is not a great use here, and this is why:
The JDBC Connection: By the time Finalize runs, the resources are being cleaned up anyway.
Nothing is Leaking at that point anyway.
The problem is if the class is not GC'd, then it sits around consuming resources.
 
and its not a sigleton so there could be a lot of them
 
0
Q: Better performance in calculating E

DidiCan you give me some performance advice how to optimize the time of execution of the following calculation of E package calculatee; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; public class CalculateE { static long start1 = System.nanoTime(); pub...

 
The only reason/purpose of a finalize method on that class would be to log bad practice: "This connection was not closed".
 
@rolfl The calculator I made is even thread-safe ;)
 
so actually what he did wasn't that bad
 
11:23 AM
@skiwi Already made a calculator?
 
As for the major resources, in the public class Conector .... there is nothing you can do in the finalze method that is not already done in the normal GC process.
At least in terms of clean-up.
 
Once again it has happened, planned to only mention one thing in my review. Ended up mentioning six things...
 
Now, about the ReferenceQueue.
 
@SimonAndréForsberg Yeah
 
This is a system in place in Java where you can track the life-cycle of an instance.
 
11:25 AM
I only need a long postfix expression to evaluate to ensure correctness
 
You can identify when a class is GC'd.
There are different types of References, but, a WeakReference would be the one you want.
What you do, is create a class that extends WeakReference.... and inside it looks something like:
 
@SimonAndréForsberg A very small issue right now is that it gives the wrong output
 
@skiwi Enough of an issue to make a potential question be on topic on SO rather than CR :)
 
private final String keydata;
public ConnectorWeakReference(String keydata, Connector con, ReferenceQueue q) {
    super(con, q);
    this.keydata = keydata;
}
 
@SimonAndréForsberg It was a stupid mistake, fixed now
 
11:30 AM
Then, you can have a thread that polls the ReferenceQueue.... when the GC runs, it will put the ConnectorWeakReference on to the queue. The con will be null, but the keydata will be in place.
So, you can use the key data to do things like: System.out.println("Connection " + keydata + " was GC'd");
 
0
Q: Simple Postfix Calculator using Java 8

skiwiInspired by some older questions, I decided to create my own postfix calculator using Java 8. I'd like to have all aspects reviewed. public enum Operator implements DoubleBinaryOperator { PLUS ("+", (l, r) -> l + r), MINUS ("-", (l, r) -> l - r), MULTIPLY("*", (l, r) -> l * r), ...

 
@rolfl thx for the explication.
So if I understand the GC cleans the connection, and the extension of the weakReference is just for knowing that it was created
 
The extension of the WeakReference is because you need to know what the reference was pointing to.
By the time the WeakReference is put in the queue, the connection is already cleaned up, and 'gone'.
So, in order to track what was cleaned up, you need some other mechanism to identify things
 
..... and.... that thing that tracks it, cannot be a link to the connection ;-) ... because then there will be a strong-reference to the connection, and the connection will never be collected ;-)
 
11:38 AM
indeed and now it is an weak reference
 
Weak references, and the Java Memory model, and other things, are complciated, and, fundamentally, have no real relevance to the question on the main site. By the time any of these things 'run', it's too late.
 
so actually I was going now to deep then I supposed to do
but hey, I'm learning and I like it ^^
 
Also, the places where the finalize method actually matters, is inside the low-levels of the JDBC connection, where it has sockets, etc. Those low level things (if it is Type4 JDBC driver) will automatically be cleaned up..... and if not (it is Type 2 JDBC - with JNI calls to external libraries) then the classes normally do their own finalization, and clean themselves up (and if they don't then it;s a JDBC driver bug).
 
1
Q: Simple Postfix Calculator using Java 8

skiwiInspired by some older questions, I decided to create my own postfix calculator using Java 8. I'd like to have all aspects reviewed. public enum Operator implements DoubleBinaryOperator { PLUS ("+", (l, r) -> l + r), MINUS ("-", (l, r) -> l - r), MULTIPLY("*", (l, r) -> l * r), ...

0
Q: Is this use of ConcurrentDictionary truly thread safe?

KitI'm working on some teaching examples showing the perils of accessing the Dictionary class concurrently. In the code below each function is designed to do a word count across a number of files. (This isn't the best way of doing the count but it's there to make a point about Dictionary.) The fi...

 
Which, is a good point.... if you use JNI, then finalize matters,.
 
11:43 AM
I feel a little bit evil now with 1,666 reputation...
 
Better ?
 
yes @rolfl thank you very much
Now I have the feeling that I should refactor mine answer ^^
 
Actually, the 'better' was directed at @skiwi - I downvoted his question so he had 1664
 
lols
I wanted to say quickly vote that question up :p
 
@rolfl I still feel as evil as before
Not anymore now :(
Need 990 more rep to become evil once again
 
11:54 AM
Keep overusing Java8 constructs, and you will keep being evil ;-)
 
Nice that you say use as many processors as you have. Pitty you don't make it generic by asking the pc his available processors by using : Runtime.getRuntime().availableProcessors(); and using one AtomicInteger what you use in the 4 threads for counting to the end, so if one thread crash, the other ones shall continue to do the whole work. — chillworld 3 mins ago
in place or not?
 
"Deciding that True is true is not very helpful."
 
brb smoking
back
 
That was fast
 
5 steps to get outside ;)
0
Q: FizzBuzz single line LINQ

Overly ExcessiveNow FizzBuzz itself isn't a big challenge but I agree that it can be a good tool to see if someone can code or not, I wanted to practice my LINQ a little bit so here's my single line FizzBuzz solution. Enumerable.Range(1,100).Select( n => (n % 15 ...

now I don't know linq but I have problems with his single line solution. We are not PCG :D
 
12:06 PM
Most seems okay there, except the use of nested ternary operators look confusing at first sight
 
hello
@chillworld I was going to post a link to that question.
@rolfl would "unclear what you're asking" be a good fit?
 
@Mat'sMug hi there
 
what puzzles me is that the OP has been around for a while
downvoted
 
Hey, catching up
Seems legit to me?
 
what's there to review?
Would you care to ask a question? :) — Kieren Johnstone 12 secs ago
 
12:15 PM
I'd say it is a sketchy post, not neccessarily wrong
 
VTC "unclear what you're asking" in spite of @Kieren's comment that just confirmed my thoughts.
 
just upvotes his comment.
was thinking of adding a comment (including we do not stand after one liners, but we stand for self documenting code)
 
I think the question is perfectly on-topic. Perhaps not a very good one. But I assume he wants to hear thoughts about his implementation
 
Console.WriteLine(2 + 2); - please review.
 
@SimonAndréForsberg I agree that it is on topic, maybe we could just do the review to an better self documented style?
 
12:23 PM
@Mat'sMug Looks perfectly fine if 2 + 2 enhances readability over 4, since the compiler will optimize it anyway. Like this?
 
Now you're exaggerating, mug :)
 
I'll retract my close vote if it's still the only one in after my 8:30 meeting.
But I don't like this. And it's perfectly unclear what he's asking.
 
@Mat'sMug I get your point, he is in a gray zone according me
thats why he don't get up or downvote by me
 
Well, if no-one else will review it ... ;-)
 
@rolfl saw that. nice Golf Review.
 
12:30 PM
De-golfed.
 
you have already upvote @rolfl
 
Good mornin!
Question for JS buffs, is there a JS library that allows you to query data structures ?
 
@konijn morning, where do you live? cause konijn is dutch word and here it is already noon :)
 
I live in NYC, but I used to live Belgium ( Bruges )
 
so you are a belgian?
 
12:34 PM
Yes indeed
 
awel welkom dan hier mede landgenoot ^^
and now back to english before @rolfl kick mine ass
 
;)
 
Ek kan you eintlik verstaan want ek kan Afrikaans praat.
@konijn - Bruges or Brugge ?
Bruges is a special place for me.
 
@rolfl Your solution on that question leads to the question of whether there is a concept (in Java 8 or LINQ) as conditional mappings
 
I don't like the toList/forEach of the linq.
If @Mat'sMug wanted to, he could find a lot more linqedness to review.
 
12:38 PM
True, storing it in memory seems absolutely pointless when you only want to print
I could give a Java 8 answer there... However I have a feeling it won't be appreciated for obvious reasons
 
Technically, for me, Bruhhe, West Flemish pronounce gg as hh
 
@konijn and a keun is a hot woman ^^
or a rabbit :D
 
@konijn Bruh-huh?
 
Yeah ... it was odd, sitting in a bar, in Bruges, and being able to read the lable of a cleaning-product.
 
Bruhhu
 
12:39 PM
And then realizing it was not in English.
 
@rolfl still a lot of difference in writing as I can see
 
Whis has inspired me for a Brugge picture today ... let me dig it up.
 
I hope you had a better time than just reading cleaning product labels ;)
 
I went one year to school in bruges
 
First trip .... i was a guy, on my own, in a hostel, with the whole edinburgh university choir on tour ;-)
It was .... a party
 
12:41 PM
I didn't know where a computer science teacher was talking about in a Dutch class once... Because I only knew the English terms.
 
Second time, My girlfriend and I decided 'we were seriously serious about things.....' now we have two kids....
We had been dating a month
I like the place;-)
 
if you have a SU account and haven't voted now is the time
 
@rolfl I hope you didn't try the "kwak" beer
 
Leffe
 
12:44 PM
Kwak - weak?
 
look for the special glass
 
 
Lot of toerist get a "kwak" beer in there face
 
@kleinfreund - Brugge ^^^^
scanned, from negative.
 
I remember the Kwak jokes from here about the Belgiums ;)
 
12:49 PM
I saw once when I saw it in real that one guy was getting hit by the beer. The whole bar was laughing
 
Are you sure it was beer? ;)
 
;] In Leuven, you have to give your left shoe to get a Kwak, too many people dont return the glass ;)
3
 
@konijn normally, special glass ;)
@skiwi and for your devil trip of last hour :
 
Yeah, a Duvel is good, two Duvels is even better ;)
 
@konijn to strong for me :) I prefer leffe radius
 
12:56 PM
My favourite Belgian beer is Grimbergen, my favourite US beer is Third Coast
 
Third coast, never heard of that
 
seems a trouble beer
 
It is simply amazing, I was having it here with some Belgian beer snobs and our jaws dropped, frankly I find it better than anything Belgian has to offer
 
like a hoegaarden but little darker
 
12:58 PM
the (after)taste is super rich
 
What... There is a snake that mimics a spider with this tail.
 
nice streaming media blocking here pffft
already asked to get in the group begin january
now you know why we still work at java 6 ^^
 
^^ We work with 1.4, our new Java Dev could not believe it, that tech was out of date when he finished school ;)
5
 
@konijn Java 1.4? What...?
 
Yeah... Plus, it's a critical component, plus, all the original developers are gone
The poor guy considered the project archeology ;)
 
1:09 PM
@konijn oke, we are not so hopeless then :)
 
@konijn Well, he is doing archeology now.
 
yeah, there is always worse
 
Whoo hooo .... I am catching up to my SU rep.
(I feel like I am 'cheating' on CR ... I have more rep on SU recently....)
2
 
@rolfl now we know why you are so silent here in the chat ^^
 
Hey everyone.
 
1:12 PM
Hey there!
 
@Malachi oh, I'm right here
 
@rolfl Nice picture again. Do you know the movie In Bruges?
 
No, ( ... looks it up .... )
Looks entertaining/
 
^^^ Jardins de Alfàbia, Mallorca
(loosely translated to Arabic Gardens)
 
Seriously challenging light there.
 
1:15 PM
Well, not translated.
 
Have you heard of HDR?
 
Yeah, can't really help about it.. It was bright sunlight and the background was quite a distance away.
I heard of it.
 
Do you guys ever monitor SO for questions that obviously belong here instead?
You would know better than they would whether it does or not.
 
@Rusher Well, some sites have overlapping fields of interest, so it is generally the responsibility of the original site to decide that the question is clearly off topic on that site, and then decide where to put it.
 
@Donald.McLean So what you meant was "No."
 
1:24 PM
Usually, the mods talk in a secret mod place to decide the fate of the universe.
2
 
^^^^ that ... ;-)
But, for the most part, very few SO questions are suitable for migration to CR.
 
@Rusher I thought you might appreciate the reasoning behind the policy. Since I actually know it. :-)
 
I am not a regular here, which is why I didn't link to the question that prompted me to ask and embarrass myself when it's obviously not a good fit
 
You can tell who is a mod from the fact that their user name is shown in blue in chat.
 
Oh, there is actually a policy against reviewing questions on other sites for "fitness"?
 
1:27 PM
@Rusher No. Anyone with enough privileges can vote to close a question. Only mods can move a question, though.
 
Link to the question ... ?
 
Well since you asked, here you go
 
And even people who can't vote to close can make comments like "This is off topic." or "Perhaps this question should be moved to X."
 
Did you do some HDR photos?
 
I have messed with HDR before .... but not very successfully
@Rusher Interesting ... it would be on topic here.... yes.... but it is also on-topic there.
 
1:31 PM
@Rusher your question is good enough to put here, but your tags seems a little bit off. Your code doesn't show the multithreating.
 
I presume it is not actually rusher's question ;-)
 
@BenVlodgi I tried to one line a bunch of stuff in @Mat'sMug code, but I used something in a way that didn't work the way I anticipated, I should have read the MSDN some more.
 
@rolfl your right
 
@kleinfreund you should look at this whole post and let us all know what you think, there is a Fiddle in the comments to my answer
3
Q: CSS3 animations of a turntable

CharlieI have the following code, which acts like a turntable and plays Sgt. Pepper when you load the page. This works only in Safari (I suppose I can delete the FF parts then), so I'm wondering how I can make the code better. The reason for there being a first, last, and main class on most div's is bec...

 
I'll have a look when I'm at home.
 
1:34 PM
0
Q: Which syntax is preferred to create a Hash in Ruby?

Sahil kalraI am writing some code in Ruby on Rails to Create an object. Basically I am passing a hash to the create Method. I could follow below 2 syntax: MyModel.create( :field1 => value1, :field2 => value2 ) Or MyModel.create( field1: value1, field2: value ) Basically since this is related to crea...

 
@kleinfreund cool, thanks. I haven't had a chance to look at this code in the fiddle. sounds like the user wants someone to fix their code with what I suggested
@kleinfreund if you have a profile on Superuser go vote for me, there is only like 6 hours left in the election
 
@charlie, changing tags isn't that hard to try out yourself. This is a legit review and you can upvote/accept after you tried to change your code. It is not the responsability of the reviewer to change all your code. — chillworld 9 secs ago
3
lazy people pffft
2
 
0
Q: Optimising my collision detection setup

KyranstarI'm creating a 2D tile based platformer with AABB (Axis aligned bounding boxes), and it works, I just want to optimize my setup. Here are methods in my player class and entity class that are relevant to the collision. How could I organize and/or optimize this better? I'm harshly looking at that p...

 
1:51 PM
Can we flag blogs? This blog appears to be off-topic because it is not about linked-lists.jliv902 31 secs ago
 
@Mat'sMug - check out this:
I'm not sure that helps much. At first glance it looks like the block runs if n is divisible by 15. (And shouldn't those be parens, not braces?) — cHao 22 mins ago
^^^ Have I put my foot in it?
 
braces define a scope - I'd think what you've done is legit, but not conventional (who defines a scope in a ternary operator, just to improve the readability of a one-liner?)
Parentheses do make more sense, as they don't have the implications of curly braces.
 
@all I'm off to home. See you later
 
@chillworld later!
 
cheers
 
2:08 PM
0
Q: Using reflection in an Attendance Entering Algorithm

ChathurangaI'm using a form similar to the following screen shot for entering employee attendance. Text boxes in the first row have been named as txtName1, txtInTime1 etc. and then text boxes in the second row as txtName2,txtInTime2 etc. and so on. Also I'm using MVP pattern in the development and I would ...

 
Is there a way to sell our tag, so another site eager to go in public beta, can get into it?
2
 
@chillworld Not my question.
 
THIS ANSWER DESERVES YOUR VOTES:
1
A: We'll be counting stars

amonThat's a beautiful excuse for writing code, and the final product is quite nice as well. ★ First of all, congrats to your Java-ridden mind for not forcing classes into Python where they aren't needed. ★ You import but do not use OrderedDict and operator. Remove unused imports. ★ It is customar...

and it's not even mine!
Many thanks, @amon!
 
@SimonAndréForsberg they're not bullets, they're stars!
 
Yes, I noticed. It deserves a +1 just because of that itself :)
You've earned the "Nice Question" badge for We'll be counting stars. - Thanks, Santa!
 
2:29 PM
@Mat'sMug - edited, and updated:
3
A: FizzBuzz single line LINQ

rolflOverall, I like this. It is concise, and neat, and all. My only beef is the nested ternaries. In general, ternary operator precedence is complicated by the lack of blocks.... The need for the parenthesis on the modulo precedence makes the conditions clear ( (n % 15 == 0) ) and the actual indenti...

 
@rolfl ok you win. 2nd answer posted, I'm retracting my close vote.
I'm keeping the downvote on the question though
 
I don't necessarily like the short-code questions. ... but, as far as I can tell, they are on topic, and, answering them, meaningfully, is possible.... and quick, etc.
 
@rolfl and +1 on your answer, too. Well done.
 
Thanks ;-)
 
now stop cheating on CR ;)
 
2:34 PM
0
Q: Dynamic array in C

2013AskerIt's a dynamic array, the elements can be accessed normally and it supports any type. I believe I'm relying on undefined behavior when I treat every pointer to pointer as void ** and I would like to know if it will work on the main platforms. Every call to da_reserve() and da_push_back() might c...

 
^^^^ No longer cheating.
 
:)
not close-voting (for now), but this one is fundamentally flawed:
0
Q: Using reflection in an Attendance Entering Algorithm

ChathurangaI'm using a form similar to the following screen shot for entering employee attendance. Text boxes in the first row have been named as txtName1, txtInTime1 etc. and then text boxes in the second row as txtName2,txtInTime2 etc. and so on. Also I'm using MVP pattern in the development and I would ...

 
Now, is this an answer?
0
A: Which syntax is preferred to create a Hash in Ruby?

mohamagdyDepends on the Ruby version you're using. If you're using Ruby 1.9.2+ then the second syntax is cleaner. If you're using Ruby 1.8 then you can't use the second syntax anyway and you have not choice.

 
@rolfl IMO this isn't even a question - you know where I stand with A vs B questions...
 
Yeah ... I do.
 
2:38 PM
it does answer the OP's question... but doesn't say why.
 
@200_success - ^^^^ You're the AvsB expert ;-)
 
Please expand this answer a bit, to explain why a syntax is cleaner with such or such version of Ruby. — Mat's Mug 5 secs ago
 
@Mat'sMug - and, BTW, the 1-liner LINQ FizzBuzz is Hot.
 
so much for sending the right message... well.. if it's on-topic, it's on-topic!
 
hot question, can my answer be hot as well?
7
Q: Can you burn a CD using a DVD-R?

user320592Is it possible to burn a CD using a DVD-R and have it play the music on a CD player?

 
2:46 PM
0
Q: Hide element when clicking anywhere but some elements using JQuery

mitomedI had a jquery code that displays some hover-over messages when touching an icon, in order to make it disappear the user needs to click again in the icon. am.homepage.Index.prototype.touchableTitleBinding = function () { var that = this; $('.' + this.bindingClassForTouchableTitle).on('to...

 
you guys do love me! I wonder how many questions I am mentioned in, indirectly or directly. 17 by this measure, codereview.stackexchange.com/search?q=malachi
 
Hey again.
That star question is nice. I'm on the list!!!
How're you guys doing?
I always feel bad when I ask only for guys, but there aren't really any girls here, right?
 
No girls that I am aware of.....
 
(removed)
 
Hi all!
 
2:52 PM
(replaced)
 
Hello @Marc-Andre
 
(reviewed)
 
0
Q: Extension method to return a default value for any null value

Daniel ShawI'm creating an extension method that can be used on any type. The idea is that if this method is called, it checks if value is null. If null, it needs to return a default instance of the specified type. public static dynamic CreateDefaultIfNull<T>(this object item) { if(item == nu...

 
@kleinfreund been worse ;)
 
(refactored)
 
2:52 PM
hey @Marc-Andre
 
(revealed)
 
#MalachiIsCrazy
4
 
(repeated)
 
Hi @Marc
 
ok BTW.Work
@TheDoctor has just been Malachi'd
 
2:54 PM
lol
2
 
Oh, the poor unicorns
 
That's not how you spell unicorn
 
uicorn - Rare animal doing user interface work.
10
 
Ohhhh
 
@kleinfreund As opposed to the corni-u?
 
2:55 PM
Ba dumm tsss
 
I thought you meant unicoin
 
Who's cornying me?
 
vyorp vyorp vyorp
c4n w3 ta1k h4x0rz n0w?
 
17 more upvotes on the badge before I get a silver badge.
 
hey @syb0rg! thanks for backing me up on the one-liner fizz-buzz... I ended up retracting my close vote. ;)
 
2:58 PM
1337-5p34k?
 
@TheDoctor No when there is
Currently, there's no , so go for it.
 
y35, 7h47'5 whh47 1 m3an7
 

« first day (367 days earlier)      last day (3652 days later) »