« first day (472 days earlier)      last day (3561 days later) » 

12:00 AM
8
Q: What is the advantages of using javascript sizzle library?

IcecreamsandwichI am a newbie to sizzlejs (javascript selctor library) and i would like to know what are the advantages of using sizzlejs instead of jquery core library , Or why they started sizzlejs as a separate project ? IS there fetures that can apply to selectors that cant do with the jquery core library ? ...

according to it sizzle is a component of jquery
@ckuhn203 is the jquery tag necessary for that question ?
 
I don't know
 
i thought i'd seen "stringly typed" code, and then i saw this code.google.com/p/lr-detect/source/browse/trunk/LRDetect/…
 
I'm posting an answer to that PHP question by the way.
The one with so many downvotes.
 
output.Append("         " + String.Join("    ", parts.ToArray()).Replace("\n1", Html.br).Replace("\n", "  "));
 
what is that ?
 
12:07 AM
garbage from the link in my previous comment
 
bad C# to generate bad HTML
2
 
Ts^
 
0
A: How could I optimize this script?

nhgrifThis script is a total of 99 lines. Of that, 49 lines are insulting, annoying, and ironic self-congratulating comments. In general, comments are good. They help any future maintainer (including yourself when it's been 6 months since the last time you looked at the script) to understand what ...

Many upvotes seem appropriate. ;)
 
Well, code comments are up for review. ;-) Just as long as the review is appropriate (which it is).
 
Half serious, half satire. Hopefully everyone will get a small bit of a laugh out of the review.
 
12:17 AM
in Tavern on the Meta on Meta Stack Exchange Chat, 43 secs ago, by hichris123
Wait, Shakespeare wasn't a programmer?!
 
Unfortunately, that question will not see the light of day (the front page), so pimping would be necessary.
 
Haha. ;)
Well, I won't feel bad about regularly linking to this answer.
 
Gah, I like your site but I never have time to contribute. :(
 
Although... the fact that it is a legitimate review but focuses purely on comments may make it a good reference answer for some Meta discussion at some point.
 
@ckuhn203 RSA
 
12:20 AM
TTGTB
 
@nhgrif kudos on correct spelling, "misspellings"
 
Yep.
There are no misspellings in my answer. I use Chrome.
 
Chrome hates me. I use words it doesn't know.
 
Though, if there are any grammar mistakes, please help me spot them and fix them. There's nothing worse than criticizing someone else's grammar and misspellings than to have some of the same problems.
 
12:23 AM
@nhgrif I'm going to save that question. and perhaps even take a print of your answer
 
I just added a line to the end:
> The fact that it's called a ternary operator is something you could learn by reading the documentation.
 
@nhgrif "than those whom you learn from." i would say, "than those from whom you learn."
 
@nhgrif no grammatical errors spotted, and I'm a bitch when it comes to grammar ;)
@mjolka I think both are proper mostly matter of preference
 
Hey Code Reviewers :D
 
Hey @AlexL - You should scroll up a few screens for some entertainment!
 
12:25 AM
8
A: How could I optimize this script?

nhgrifThis script is a total of 99 lines. Of that, 49 lines are insulting, annoying, and ironic self-congratulating comments. In general, comments are good. They help any future maintainer (including yourself when it's been 6 months since the last time you looked at the script) to understand what ...

 
lol, still not deleted?
 
YES! I was just looking at that post!\
 
-1
Q: How to shorten Python Code

sarath josephHow to shorten the following line of code in Python if((post["datatype"][index]=="VARCHAR2" or post["datatype"][index]=="NUMBER")):

 
If you want to get picky to an incredibly insane extent, the following has an extra comma:
>They help any future maintainer (including yourself when it's been 6 months since the last time you looked at the script) to understand what the code does, because programmer time is extraordinarily valuable.
There is no need for a comma before because there
but that's likely way too picky :p
 
For this, I do want to be extraordinarily picky.
 
12:28 AM
@Phrancis what's with the human tag?
 
I'm going to print that answer.
 
Well, if we're being super picky, the sentence out of context also isn't logical. It implies that comments help the future maintainer because programmer time is valuable.
But once again, I'm just being a pedantic dick :p
 
Thanks @santa :)
 
This is incorrect: "This is PHP, you didn't create it, so you're going to fall into one of the other two categories."
There's a comma splice in there. Easiest fix: "This is PHP. You didn't create it, so you're going to fall into one of the other two categories."
 
@nhgrif - greetings... ;-)
 
12:32 AM
Oh, if anyone hasn't already, please go upvote this answer
8
A: How is my CMS design? Any security, design, or other issues?

shudderDevelopement oop & design-patterns tags you've used are already saying what needs to be done here. At this moment it's a structural code (with some class syntax) and it will be very difficult to expand. Even though it doesn't look like a big project yet and you don't need deep object structures/...

 
@AlexL downvotes
 
@hichris123 Eeek!
 
Crap, I don't have enough rep to downvote. Guess I'll have to upvote. :P
5
 
@mjolka Because... the language is.. Human!
 
Hi
 
12:36 AM
@AlexL Are you sure you linked to the correct answer? ;)
 
I did :) when that answer hits 10 votes, I will get a badge for doubling the accepted answer's amount of votes ;)
 
Oh. :P
 
@AlexL - close, but not quite.
The accepted answer has to have more than 10 score.
and you have to more than double the score.
 
Oh gosh @rolfl, what a way to burst my bubble ;)
 
so, the accepted answer needs X where X >= 11, and you need at least 2X + 1
the minimum is 11, and 23
the wording on populist could be better.
 
12:39 AM
Oh well, still closer with a couple more votes
 
> Highest scoring answer that outscored an accepted answer with score of more than 10 by more than 2x. This badge can be awarded multiple times.
 
Yep yep
 
looks at the populist badges... sighs codereview.stackexchange.com/a/13223/33144
 
@rolfl yeah, "outscored ... by more than 2x" sounds like you would need 3x + 1
 
well, 2.0000001X is more than 2X too ;-)
 
12:41 AM
right, but if post A has 10 points and post B has 20 points, then i would say post B has outscored post A by 10 points, or 1x
 
true, really bad terminology.
 
I'm drawing a blank again... there's a shortcut for generating a number sequence, e.g., {1,2,3... n } in a column but Google always brings me back to create sequence which is totally not the same thing :(
 
So, @mjolka - I'll bring that to the attention of the devs .... ;-)
 
Is it in your FizzBuzz question?
 
@Phrancis int4range? numrange?
 
12:43 AM
Hmm. Maybe it is... looks
 
Did I just set a "Nice Answer" badge record?
10
A: How could I optimize this script?

nhgrifThis script is a total of 99 lines. Of that, 49 lines are insulting, annoying, and ironic self-congratulating comments. In general, comments are good. They help any future maintainer (including yourself when it's been 6 months since the last time you looked at the script) to understand what ...

 
SELECT * FROM GENERATE_SERIES(1,  prmMaxNumber);
 
Took about 20 minutes.
 
There it is
 
@nhgrif Tell @rolfl to make an SEDE query for that.
 
12:45 AM
Very nice @nhgrif
I find it funny that, even though your answer reviews none of the functionality, it feels perfectly relevant to this particular question.
 
Comments are an extraordinarily important part of the source code.
4
 
0
Q: 2D Tilemap Collision Method JavaScript

Oliver BarnwellI was wondering, is this the optimal method to check for collisions in a 2d-based game? I put together a working demo of 2D collisions here: http://jsbin.com/qipezajiwevo/1/ (wsad to move, orange blocks collide). Currently I use the following code to check for collisions: function checkmove(x, ...

 
God, that question
Those comments make me want to bitchslap him
 
And it may never beat this:
-73
Q: Single layer neural network

user414981For the implementation of single layer neural network, I have two data files. In: 0.832 64.643 0.818 78.843 Out: 0 0 1 0 0 1 The above is the format of 2 data files. The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remainin...

 
unless we all mass upvote it to narrow the gap!
 
12:58 AM
Be my guest. And if either answer reaches 20, Reversal will be awarded.
17
A: How could I optimize this script?

Paulsed 's/\(\/\/\|#\).*$//g' YOUR_FILENAME | sed '/^$/N;/^\s*$/D' To clarify, that strips comments and multiple blank lines. Generally comments are a good idea. I would not remove them or create shorter names for functions and variables for performance. Any benefit there is minuscule beyond bel...

 
I want a Reversal badge!
I have zero gold badges.
 
You may have to pimp that answer every day until it reaches +20. I have already posted it in the Tavern, too.
 
@Jamal I'm going to convince everyone to downvote it now... :P
 
And you're gonna have two new enemies. ;-)
 
1:19 AM
This one's for @Phrancis.
SELECT * FROM GHOSTS
3
 
@hichris123 There is no time-component to votes.... all votes on a given day are recorded as if at midnight. Query not possible.
 
@ckuhn203 LMFAO
2
 
@rolfl Couldn't you compare the timestamp of the badge given out vs. the timestamp of the post being created?
 
Good point, but even though there is a record of the badge, the record of the question on which the badge was awarded, is not available.
 
lots of answers popping up to this question codereview.stackexchange.com/questions/60439/…
 
1:25 AM
@rolfl oh.
 
and, the badge is recorded for a Date, not a DateTime.
go figure.
 
@nhgrif I just generated about 4 million rows of data in pg to benchmark a few different methods of doing what I asked you about earlier
I'll post a question shortly
 
when I close vote a question do I need to flag it too ?
 
No, just vote to close.
 
1:40 AM
ok, thanks
are there any scenarios I have to flag but not close vote ?
 
Good question.
 
found the answer
5
Q: Flag converted into close vote

RubensAfter reaching 3000 reputation points, I've been alerted of the fact that I may vote to close posts with low level quality -- and other possible reasons. Since that, every time I flag a post, the flag seems to be converted into a vote to close, with the respective reason -- the same used to flag...

^^ for spam and VLQ
 
If you flag as spam or offensive, then a close vote won't even be needed. Those posts should skip closure and go straight to deletion.
 
WOW, query been running close to 3 minutes and still going...
Still going, 5+ mins :(
 
-1
A: Vector-to-direction method in Java

kajacxYou can always go for branchless code: // 1 = negative // 0 = positive public static int isNegative(float val) { return (Float.floatToIntBits(val)) >>> 31; } public enum Direction { NORTH_EAST, NORTH_WEST, SOUTH_EAST, SOUTH_WEST; //I had to reorder the directions (or use index mappi...

 
1:54 AM
(hint: look at the very far bottom-right)
 
2:09 AM
It's still running... -- this query sucks
 
@Phrancis is the idea to get the count of Status = 'one', 'two', 'three' per Contract_Number?
 
Yes
It's still running, about 20 minutes into it. This is a horrible query design....
 
@Phrancis i know it's not the same, but maybe good enough for the job? SELECT contract_number, status, Count(status) FROM seeded
GROUP BY contract_number, status
 
CREATE TABLE `menu_item` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `foodmenu_id` varchar(8) NOT NULL,
  `parent_id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `foodmenu_id` (`foodmenu_id`),
  CONSTRAINT `ala_foodmenu_item_ibfk_1` FOREIGN KEY (`foodmenu_id`) REFERENCES `ala_foodmenu` (`foodmenu_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
 
2:24 AM
@Bhathiya-JaDogg-Perera ? D:
 
yes, I'm storing some hierarchical data
 
The code looks alright, other than being MySQL...
I might suggest a few indentation changes for readability...
 
CONSTRAINT `ala_foodmenu_item_ibfk_1`
    FOREIGN KEY (`foodmenu_id`) REFERENCES `ala_foodmenu` (`foodmenu_id`)
      ON DELETE CASCADE
      ON UPDATE CASCADE
 
ah nice.
The way we are handling mysql, is to use workbench, create tables, dump the sql, add it to git. yuck
 
2:31 AM
That does sound terrible
OH, that query is still running...
Only been 29,999,901 ms now
 
How do you revision control a DB ? it will end tomorrow I guess, joins+count for 4 million
How do you revision control a DB ?
 
Not sure. Good thing I'm only doing benchmark testing, otherwise I may have to answer that ;)
 
Good article
IT'S DONE
Total query runtime: 3096218 ms.
10 rows retrieved.
And... it's wrong.
 
### Copy/Paste below code when adding in a new preference ###
arghsfkfjksdf...bad people who came before me, bad!
how did your interview go @Phrancis?
 
2:41 AM
@Yuushi quite well, thank you for asking. I heard the word report several dozen times, I guess it has to do with reports ;)
 
17
Q: Put MySQL database under version control?

user479911I'm currently using SVN for my PHP projects. I was thinking I should get my database under version control too, but what's the best way to do that? Do I just make a db-folder in my project in SVN, paste SQL changes into a file called from_1.0_to_2.0.sql and commit?

 
@Phrancis excellent, good to hear :)
 
@Phrancis lol at the report thing.
 
@Phrancis all columns are the same in a given row?
 
6;4000000;4000000;4000000
8;4000000;4000000;4000000
1;4000000;4000000;4000000
2;4000000;4000000;4000000
3;4000000;4000000;4000000
10;4000000;4000000;4000000
4;4000000;4000000;4000000
5;4000000;4000000;4000000
9;4000000;4000000;4000000
7;4000000;4000000;4000000
^^ output
 
2:43 AM
yeppp
 
Maybe it is right. I did use cross join to just make a bunch of data
 
Not quite random() in fact, specifically not random() I should expect that to be the result set
 
@Phrancis try a sanity check like SELECT contract_number, status, Count(status) FROM seeded
GROUP BY contract_number, status
HAVING status = 'three'
 
@mjolka running now
Total query runtime: 6397 ms.
100000 rows retrieved.
That was quick
 
2:47 AM
http://i.stack.imgur.com/Y1XHl.png
@Jamal ^^
 
set search_path = test;
SELECT contract_number, status, Count(status) FROM seeded
GROUP BY contract_number, status
HAVING status = 'three'
 
eh
oh last updated on jan 8
 
OK - so; I've tested this query model to suck really suck. Now to try a case when ... then model.
 
bye, going to sleep
 
Seeya @Bhathiya-JaDogg-Perera
 
3:21 AM
syntax error is so much fun
 
ah, there we go, nice and generic. 9 functions collapsed into 3.
 
I made a newbie mistake
 
3:38 AM
Is it off-topic if you post a question where your first implementation didn't quite deliver as expected (though it worked) but the later implementation was better (and still asking for review?)
(posting 2nd implementation for review, but leaving the first for reference)
 
unless its not much code I would just post the second one and omit the first one?
 
That makes sense @bazola
 
or post it as two questions if you think that both are worth a review and the code is long enough to warrant it
 
3:53 AM
I think I found a decent way to balance it... @CaptainObvious will post soon
 
@Phrancis i get an error when testing this codereview.stackexchange.com/questions/60446/…
ERROR: column "seeded.status" must appear in the GROUP BY clause or be used in an aggregate function
LINE 4: when seeded.Status = 'one' then 1
 
Hmm
@mjolka what RDBMS are you pasting this in?
 
postgres
 
Monking @all
 
that was for the case...when query, i should have said
 
4:01 AM
^^ not sure what it is, but seems to work OK on my machine
 
@Phrancis you've left off seeded.Status in your question
last line
 
Oh. Shit.
 
quick fix it so i can post an answer :)
 
Fixed
 
ta :) also, just to be sure, the columns are supposed to be the counts of the number of 'one', 'two', 'three' statuses, right?
 
4:03 AM
Ja Oui Yes
... cow sounds from wife playing Minecraft... plugs ears...
Yay the dog did not shred the shoe I left out accidentally... just mostly made it wet...
 
@Phrancis answered, but still not totally sure i understand the question :)
 
monking!
thoughts?
0
A: Checklist for how to write a good Code Review question

Mat's MugHow to NOT write a zombie. A zombie is a question that remains unanswered. As a question asker, your goal is to avoid writing one. Beyond meeting the on-topic requirements, I think "good CR questions" can be broken down into several question types. This answer is longer than I would have liked...

feel free to edit / wikify
(looks at the time)
4
 
4:25 AM
@Mat'sMug I got a good chuckle out of it
 
I needed your sanity check. Did not realize the code was broken/not yielding expected results, to begin with. Thank you & accepted. — Phrancis 9 secs ago
@mjolka ^^
 
@Phrancis thanks :)
 
4:37 AM
:)
gone to bed, I am. not enough hours, days have.
 
5:29 AM
hey @Malachi, yup I happen to live in Paris, for now, why what's up?
and congrats for the 10k ;-)
@Mat'sMug awesome post! (I liked your earlier one too on the same question)
 
5:58 AM
Monking
 
monking @skiwi
 
monkin'
 
monking
 
6:42 AM
Monking
@Mat'sMug This looks like you could also write an answer to this meta-question in a similar fashion.
5
Q: Checklist or General Directions on how to write a good CR-ish answer

Vogel612This question is intended to be the counterpart of: Checklist for how to write a good Code Review question Getting started with CodeReview: New users often seem to have problems to understand, what exactly is expected from a CR-Answer. Many come from Stackoverflow, others maybe from Programmer...

 
Monking @Vogel612
 
Monking @Heslacher
 
Monking @Vogel612
 
7:07 AM
TTQW, night all
 
Night @mjolka
 
Ô7
 
Assume I have a method named ReloadPlugin() does this imply, that this method will unload the plugin before it is loading the plugin ?
 
kinda...
though you could also expect that from a method named LoadPlugin()
or rather, I'd have ReloadPlugin() { UnloadPlugin(); LoadPlugin(); }
 
@Vogel612 That is the way, like I want to implement it. For me the name ReloadPlugin is just not descriptive enough, but I can't think of a better name. Maybe I will clarify it in the XML documentation.
 
7:17 AM
yea you'll probably need to do that.
maybe your LoadPlugin() just doesn't do anything when the plugin already is loaded.
so you will need to unload by design
 
I guess, I need some more thinking about this. Thanks anyway.
 
 
1 hour later…
8:51 AM
okay, what in god's name???
@skiwi you there?
Generics and NullPointerException are killing me.
@SuppressWarnings("serial")
private static final Map<Class<?>, ModelConverter<?, String>> modelConverterBacking = new HashMap<Class<?>, ModelConverter<?, String>>() {
	{
		modelConverterBacking.put(Right.class, new RightConverter());
		modelConverterBacking.put(Location.class, new LocationConverter());
	}
};
how the heck do I get a NullPointerException in that code??
sec.
aaand nevermind, thanks rubberduck ;)
 
in a constructor maybe
 
nope, the modelConverterBacking itself was null.
fix:
 
{
    put(Right.class, new RightConverter());
    put(Location.class, new LocationConverter());
}
becaus ho-yay you can call methods on the instance of the class you run through the static initializer.
wtf?
it's kinda the same if you'd call this.put(Right.class, new RightConverter());
@Bhathiya-JaDogg-Perera wrong room?
 
9:01 AM
looks nice
fancy putting it up for a review sometime?
 
It's the correct chat room, so correct I don't realize I'm pressing the bookmark to get here. I'm doing it without thinking.
 
lol
 
I wrote it in 2011, It's probably a mess, and Written in freeBASIC not sure if that language is famous
 
ouu nice, you could even get a thingy-badge...
sec
shiny silver taxonomist
might take a while though ;)
 
@Vogel612 yea
 
9:07 AM
and I will end up creating zombies
 
@skiwi you instantly saw it, right?
@Bhathiya-JaDogg-Perera no probably not. They maybe are a 3-zombie-zombie
 
@Vogel612 I saw it was weird, but still haven't really figured it out
 
@skiwi the modelConverterBackingBean was a null Reference
well inside the static initializer block that is.
 
@Bhathiya-JaDogg-Perera laters ;)
 
9:09 AM
@Vogel612 Still weird
aah
You needed to use just put there
how did that even compile?
 
exactly
I have no clue how it compiled..
but it did.
even through maven
so it's not only eclipse.
 
@Vogel612 You properly messed up there
What you have is:
heh wiat
oh wow
figured it out
 
please enlighten me...
i got it working btw..
 
private static final Map<String, Object> MAP = new HashMap<String, Object>() {
    {
        MAP.put("a", new Object());
    }
};
You are first of all, creating an anonymous inner class extending HashMap<String, Object>
then
you are declaring an initialization block, using { ... } on that class, in which you are legally allowed to refer to any final (or Java 8 effectively final) variable
Hence you are referring to MAP, which is still null, because you haven't constructed it yet
And I just learned that anonymous inner classes can have constructors.
 
what the flying f*ck?
so you mean it would have worked if I had gone for
private static final Map<String, Object> MAP = new HashMap<String,Object>() {
    {
         super();
         MAP.put("a", new Object());
    }
}
 
9:16 AM
not sure if that is possible
but you want something else
 
@SuppressWarnings("serial")
private static final Map<Class<?>, ModelConverter<?, String>> modelConverterBacking = new HashMap<Class<?>, ModelConverter<?, String>>() {
	{
		put(Right.class, new RightConverter());
		put(Location.class, new LocationConverter());
	}
};
▲▲ that is what I got right now.
 
Wow, this is proper evil
you wanted this:
private static final Map<String, Object> MAP = new HashMap<String, Object>() {{
    put("a", new Object());
}};
It is called double-brace initialization
 
d00de.
read again....
 
which I just figured out is exactly what you did before, but it looked more awkward to me
 
there's linebreaks between the braces
it's exactly what I got there..
 
9:18 AM
so difference is that you call the method locally, instead of on the object
 
@skiwi you listening???
 
map.put is wrong, put is correct
@Vogel612 Yes, your current new way is correct, but looks weird
 
yea and it's what I got right now..
eclipse formatting ftw.
 
As you cannot immediately see that it is using double-brace initialization :)
 
I pref double brace in your notation too..
 
9:19 AM
those kind of errors are always fun
I gotta love this question for steady rep
23
Q: Why does Iterable<T> not provide stream() and parallelStream() methods?

skiwiI am wondering why the Iterable interface does not provide the stream() and parallelStream() methods. Consider the following class: public class Hand implements Iterable<Card> { private final List<Card> list = new ArrayList<>(); private final int capacity; //... @Override p...

I prefer to use static initializer blocks though over double-brace initialization
Like
 
??
so you'd have it like:
 
private final static Map<String, Object> MAP = new HashMap<>();
static {
    MAP.put("a", new Object());
}
Might have to do with using diamond operator in Java 7+
 
is that java8??
 
No, Java 7 :)
 
lol it works with 6 too..
(without diamond that is)
failed to start service JPA-Unit
ClassNotFoundException: Could not find JPAMessage
wut?
 
9:25 AM
yes it works in Java 6 as well, true
clean build and pray it's fixed!
 
restarted server...
java.lang.OutOfMemoryError: PermGen space
or not.
operation("shutdown") failed - java.lang.OutOfMemoryError: PermGen space
wut?
 
It's saving lots of new things somewhere?
permgen is used for class files and interned strings I believe, that sort of stuff
 
too many interned strings???
wtf..
I think Ima shoot the whole jboss jvm down and start it from scratch
 
That would only happen though if you are creating lots of random strings
 
850 MB private bytes
 
9:31 AM
it might have loaded in too many classfiles as JBoss can hot swap I guess?
 
yea it can hot-swap.
too many redeploys??
and it works just fine again ;)=
wtf???
I think I just "fixed" the no1 bug in the ticket of someone else...
and I have no idea how or why
 
huh?
what was that then
 
I have not the slightest clue..
the exception was "Detached entity passed to persist"
and it's back again.
hum..
what the hell?
 
code?
 
@Pimgd a tangled mess of Lists, Sets, Maps and other strange things...
 
9:40 AM
ModelConverter taking a string?
 
also. probably waay to large for here.
nope.
 
mmhh
 
ModelConverter taking a model, returning a string and putting it into a Map<String, Object>
 
and uh
how do you return string?
 
return instance.getProperty();
String is prob not the problem here.
aaand it's not even reproducible,,,
fuck my life.
or rather it depends on whether you add or edit.
unfortunately I can't add anything right now..
and I only got one to edit...
brb, writing an Insert-statement and reproducing.
 
9:58 AM
just gr8, the list controller for it is also broken...
 
when did you break it?
 
it is part of the ticket that my colleague has.
It wasn't there..
 

« first day (472 days earlier)      last day (3561 days later) »