« first day (802 days earlier)      last day (2022 days later) » 

12:00 AM
There are 1329 unanswered questions (94.7624% answered)
12:10 AM
@nhgrif Yeah, it felt closable but I'm no expert at Swift, so I just left it alone, Sorry.
@EthanBierlein If you take a look at SO's Parse.com tag, it's full of crap
Does anyone here actually know anything about Parse?
A: Parse query checks and increments

nhgrifLately, when writing Code Review posts, I like to point out the first thing I notice when I look at someone code. This is the first thing I notice when I look at your code. Without looking at anything else, I can already tell you that your code is way too deeply nested and therefore absolutel...

@nhgrif Nice answer :-)
12:32 AM
Q: Facebook crawler redirect to force displaying own opengraph meta-tags

Christoph EderFor my website, I use the opengraph to send the right data to the crawler. On the top of all pages on my website, I include the opengraph-script, like this: if (preg_match("/facebookexternalhit/is", $_SERVER['HTTP_USER_AGENT'])) { include("./facebook-crawler.php"); exit(); } face...

@CaptainObvious Oh good, my edit went through before the captain saw
@nhgrif That is a nice idea, to point out the first thing you notice when you look at the code. I think I will do that in the future too.
12:49 AM
It's not always the biggest problem. But it's usually the most obvious problem. The problem that shouldn't have been overlooked before asking someone to review your code.
Like, when I point that issue out, it's kind of like saying "Realistically, if you post any more question here, I hope to never see that problem again."
The first thing you notice doesn't always have to be a bad thing either. Sometimes maybe you'll say "first thing I notice is how clean this code really is"
That's true.
If the first thing I notice is something that needs to be improved, something that's a glaringly bad problem, it's unlikely that I'll necessarily give the question much in-depth thought to what the user is actually asking (unless they're asking about the first thing I noticed)
And I usually look at code first.
@SimonAndréForsberg That's often my introduction, point out the good parts, then move on to the problems/improvements
I just talk about things I notice. I don't usually bother with talking about the good parts. The exception might be when the user is particularly concerned with an area, but I think that area is fine, but they have problems in other areas.
@Quill flowers, then the pot ;-)
Exception? That's usually the rule. I try to address direct questions, but usually it's something completely different that I see.
@RubberDuck What I mean is that I don't necessarily comment about positive aspects unless I'm doing so as a response to a direct question.
Hmm... Phone's dying... Boot the laptop and play with some embedded C?
Although, I quite regularly entirely ignore the direct questions the user is asking.
12:57 AM
Ahhh. Gotchya. Why not? I think it's encouraging to hear the good things too.
I'm not easily impressed, perhaps?
You're not. So, perhaps.
If the user hasn't expressed a specific concern about an area, the criteria for me to make a positive comment is almost to the degree of "Okay, wow. I'm going to start doing that in my own code."
Maybe I just deal with so much crap code I'm impressed when people do something art.
I've done that a few times.
I had a case of that when I started my new job... but it was with a coworkers code... not a CR post.
1:00 AM
sigh. Yeah. I'm neck deep in some vb.net written like awful vb6 by some guy who's gone now.
Webforms suck.
So now, instead of declaring my constants independently, we're putting them in structs.. and nested structs and such...
What's a constant? smh...
I've never seen so many hard coded sql queries copy pasta'd all over in my life.
    struct Constants {
        struct WebConstants {
            struct Paths {
                static let someApiPath = "etaoejaeda"
                static let someOtherApiPath = "aieoraioejfaoie"
        struct JSONKeys {
 // etc...
request.basePath = Constants.WebConstants.Paths.someApiPath
=\ that doesn't look fun
It's actually really good.
1:04 AM
Too many dots for my liking.
Excruciatingly readable though.
And, if you're going into the same struct numerous times:
The API is at least.
What language is that btw?
    typealias UserKeys = Constants.WebConstants.Paths.JSONKeys.User

    dict[UserKeys.ID] = 1
    dict[UserKeys.Name] = "joe"
    // etc
I like the syntax.
And consider this...
1:06 AM
Braces are all "wrong" though. =;)-
The structure of the JSONKeys struct means that when you look at the declaration of those constants... it perfectly matches what the actual JSON data looks like
@Mat'sMug FYI:
in TCG Creation, 1 hour ago, by Duga
Mat's Mug vs. Simon André Forsberg: 38 diff. Year: +928. Quarter: -576. Month: -576. Week: -147. Day: -83.
For example, say you have JSON that looks like this
TTGTB. Behave now, CRitters! ;-)
1:07 AM
"user": {
    "location" : {
        "latitude": 90,
        "longitutde" : 180
    "id" = 1,
   "name" = "joe"
Now your constants are declared like this:
struct User {
    static let id = "id"
    static let name = "name"
    static let location = "location"
    struct Location {
        static let latitude = "latitude"
        static let longitude = "longitude"
Okay. Now you've sold me. I like that.
I'm not used to seeing Simon's and Mat's names in blue.
Neither am I, but it feels right.
let id = userJson[User.id]
let name = userJson[User.name]

if let locationJson = userJson[User.location] as? [String:AnyObject] {
    let latitude = locationJson[User.Location.latitude]
    let longitude = locationJson[User.Location.longitude]
1:11 AM
Gtg myself. Good chatting @nhgrif. Cya @Hosch250
A: Issue to inherit UIAlertAction in Swift

nhgrifThe solution is realistically almost certainly to use class extensions instead. extension UIAlertAction { convenience init(title: String) { self.init(title: title, style: .Default, handler: nil) } } Usage: let okayAction = UIAlertAction(title: "Okay")

To anyone who want to try, here's the latest version of "The 2nd monitor" translator, renamed to Memer
Just copy that to your console and done
1:54 AM
I am just the 22nd user to earn the silver Swift badge. Wow.
Now... 370ish upvotes to the gold iOS badge...
2:08 AM
Keep on going up dude!
I'm feeding more data to the Memer (old "The 2nd monitor" translator)
2:23 AM
def pipeSeparated = "blue|red|green|orange|yellow"
def colors = pipeSeparated.split("|")
assert colors.size() == 5
Caught: Assertion failed:

assert colors.size() == 5
|      |      |
|      28     false
[b, l, u, e, |, r, e, d, |, g, r, e, e, n, |, o, r, a, n, g, e, |, y, e, l, l, o, w]
That's weird
Hm. Must be something with the pipe, maybe it needs escaped. Used a space instead and worked fine
Maybe you found a bug.
I don't think a pipe needs escaping.
def pipeSeparated = "blue|red|green|orange|yellow"
def colors = pipeSeparated.split("\\|")
assert colors.size() == 5
^ works
I think it might have to do with regexes
I hate when regexes are integrated into string classes
the regex.compile() should always have to be explicit
@Phrancis Certainly is.
| is the "or" symbol.
2:39 AM
Q: Checking if two strings are anagrams

toyI have a piece of code that checks if two strings are anagrams. I would like this to be as pythonic as possible. def are_two_string_anagram(string1, string2): if len(string1) != len(string2): return False def char_count(string): char_count = {} for s in string: ...

2:54 AM
This is kinda cool
def newlineSeparated = """
removeLeadingSpaces = { it.trim() }
nonBlankLines = { it }
colors = newlineSeparated.split("\n").collect(removeLeadingSpaces).findAll(nonBlankLines)
assert colors == ["blue", "red", "green", "orange", "yellow"]
That looks cool!
You want to see it in Javascript?
Multi-line strings are Groovy
Readable or crammed up?
Readable, preferably
(this is not PPCG ;)
var newlineSeparated = "

var removeLeadingSpaces = newlineSeparated.replace(/^\s+/g,'');

var colors = removeLeadingSpaces.split(/\r\n|\r|\n/g);
The only possible difference is that it may have an empty line
3:02 AM
Ah, gotta use regex though
In python, just `'''<stuff>'''.split()`
`str.split()` with no argument splits on any whitespace instead of the given string.
var newlineSeparated = "\

var removeLeadingSpaces = newlineSeparated.replace(/^\s+/g,'');

var colors = removeLeadingSpaces.split('    ');
And yes, that's 4 spaces
var newlineSeparated = "\

var colors = newlineSeparated.replace(/^\s+/,'').split(/\s+/g);
2nd shortest I can make
To have a 100% similar to yours, I have to do ridicolous stuff
why not get rid of the ^ in the regex?
I don't get what you're doing there.
why do you need a replace at all?
The replace is to remove the whitespace
But anyway, I have a 'better' version:
var newlineSeparated = '\n\

var splitted = newlineSeparated.split('\n');

var colors = [];

for(var i = 0, l = splitted.length; i < l; i++)
	splitted[i] = splitted[i].replace(/^\s+/,'').replace(/\s+$/,'');

		colors[colors.length] = splitted[i];

A new-line separated multi-line string
@o11c I thought ^ in regex was for the start of a string of characters, like /^hello.*/
3:16 AM
And it is
@Phrancis Other attempt in Javascript:
var colors = '\n\
	return string != '';
	return value.trim();
I won't bother anyone anymore
Have a good night
/me has just discovered that someone i work with loves using the synchronous file system functions in node. :-(
this person also mixes spaces and tabs. i'm going to cry.
re^^ above code... colors = '...'.split('\n').map(String.prototype.trim).filter(function(x) { return x != '') .. and it could get even shorter with ES6
it's pretty much exactly the same as the Python one, except Javascript can't directly compare two arrays
now, if i fix this person's code to use asynchronous methods, it may unwittingly break other things that are depending on parts being synchronous. sigh.
on the bright side, that person is on vacation.
which is why i'm messing with their code instead of just sending an email saying "you should do this, not that"
3:33 AM
Working code can be posted to codereview.stackexchange.comGuy Schalnat 9 secs ago
@EricBlade Well, you have version control... right?
Good :)
4:02 AM
good night CRitters!
Q: PHP - OO shopping cart class + product class interaction

SSJameenI built a small store site for learning purposes. I loaded my 'products' from the db into a products class. I used a method from this class to display the products in HTML. Of course, the HTML contains 'Add to Cart' buttons which POST the product ID and quantity when a button is clicked. The r...

@Mat'sMug Good night, moderator
@CaptainObvious was going to edit title to "Got a cart, let's go shopping - wait, why do I need a cart?"
4:35 AM
@Mat'sMug lol
Q: Wrong answer in SPOJ AP3

abhishek_naikI'm solving this SPOJ question http://www.spoj.com/problems/AP3/. I implemented the following code, which is working just fine on all the test cases that I tried (so the formula I have derived is correct). Referring to the comments posted on SPOJ, I could make out that precision must be paid hee...

Monking and congrats to the new/old moderators !
It works as expected and achieves it intended purpose - just that I get WA on SPOJ. I have also taken care of precision as pointed out in the comments on SPOJ. — abhishek_naik 47 secs ago
4:51 AM
Q: What is causing my program to stop working

idiosincrasia23I wrote the following code in order to find the longest chain of collatz sequence.The actual challenge was to find the longest chain below one million. However, when I try to run the program, window would show the error message saying the program had stopped working.But if put one hundred thousan...

monking @all
5:11 AM
hey @chillworld
congratz @Jamal, @SimonAndréForsberg, @200_success and @Mat'sMug
the best is, If I had 4 votes in final round, this would be it.
I did have difficult to choose who I won't vote to
Q: Freeing shared memory with a signal handler

DaleSwansonI have a homework question that asks me to get 2 integers from the user, put them in shared memory, fork a child, have the child add them and put the result in shared memory, and then the child will end and the parent will print out the sum. The program must also loop until the user does CTRL+C,...

brb, have to complain about our archtype ;)
5:40 AM
Q: How to set segue in iOS

Anju kumbharkarI am working on tableviewcell and i want to pass that cel to next view controller in iOS. but error as Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'TGG'' in segue. and if i use push view controller then it display bla...

5:51 AM
Sigh, why must so many programmers be completely unaware of concurrency problems?
6:07 AM
@o11c Because synchronizing is the magical concurrency fix always.
I'm voting to close this question as off-topic because it belongs to Code Review SE. — shekhar suman 54 secs ago
"I like you thread and Imma let you finish but synchronization is the best fix of ALL TIME"
this is fork()'ed process with some MAP_SHARED memory actually
and when I looked at the disassembly I realized I hadn't even caught the signal race condition before.
this is what?
Just put everything on a clock, VHDL style. Concurrency solved.
It will turn your speedboat CPU into a freighter, but hey, it works.
6:17 AM
@Gemtastic The question I just answered codereview.stackexchange.com/a/96974/57656
@Mast it works (tm)
@Mast Putting things on a clock may make it deterministic, but that doesn't prevent all problems.
Well, to be fair, it is
Even single-threaded applications can race with themselves.
Well, I'm a Java dev so I'm kinda used to threading
And the JVM threading on its own
6:19 AM
I really hate what Java did to the volatile keyword.
We've been having to spam "volatile does not mean thread-safe" ever since.
I don't know how it works in other languages, only Java
@o11c I got so many downvotes from trying to point that out :/
I only know how it works in C-style languages.
Tbh I'm scared that OP's professor accepted that code, given the fact that it hangs indefinitely if compiled with optimization on.
In Java people think that just because you synchronized it and/or made it volatile, it's auto thread safe. No. It isn't.
I do give that it may be confusing that there's two meanings of volatile depending on what java version you run but..
Hm, what changed between Java versions?
6:22 AM
The old defenition I believe was in java5
It changed from only adding visibility to making it also synchronized
If my source was correct that is
Uh, what?
What about what?
The Java sense of synchronized doesn't make sense for volatile variables since the only thing you can do is a single atomic read or write.
Though I dunno about compound assignment.
synchronized only makes sense with multiple statements.
In java, volatile adds visibility for all the threads, and the atomic read an write, BUT since Java6 it's also synchronized so that only one thread can read/write at a time
Uh, that doesn't make sense still. Since it's a single instruction, one thread writes, then "at a time" ends, then another writes, etc.
6:26 AM
It's a tool to help add thread-safety, something which many equals to thread safety.
I will grant that (unlike C) it does grant visibility of reads/writes to other threads, but nothing you've said beyond that makes sense.
It's certainly possible to use atomics to implement higher-level inter-thread communication operations ...
Well, I'm not well versed enough in computer theory to know or have an opinion on what makes sense in general when something is volatile, I only know how it works in java...
Ah, old volatile didn't provide ordering? That's nasty.
And in Java, it's is not thread safe with synchronization, but it's a tool to use in making it thread safe.
@o11c I don't believe it did no. It only had the atomic read/write thing and visibility.
C++ provides 8 different memory orderings, the difference between Java 4 and Java 5 is which one it used.
6:31 AM
If my source is correct. It seems this is something not many people actually know, which is also why I'm looking forward to learning JavaEE
If you don't know which one you should use, use seq_cst (which is what Java 5+ uses)
I thought Java decided that for you? :S
That said, plain old reads and writes are not a very useful use of atomics.
Go on :)
compare-and-swap is probably the most useful
6:32 AM
That makes sense
My personal opinion is that singletons are bad by design. If you can design your code without one, you should. They have their purposes, but if you're assuming synchronization is auto thread-safe, you're gonna have a bad time...
Oh yeah, singletons are evil for all sorts of reasons.
It makes me hate when there's a kernel interface that forces you to use them such as ptrace.
/me makes a note to try ptrace with signalfd
@o11c I've removed your comment on the signal-handler question. No need to sully your excellent and informative answer with name-calling, regardless of whom it's directed at.
@200_success word choice aside, it is critically important to learn that professors are not very good.
6:50 AM
If your review is much more thorough than the professor's then the conclusion should be obvious.
If you must say something, "your professor has carelessly let a lot of issues slide" would be more appropriate language.
Unfortunately, we have too much of a culture that takes teacher's word as law for it to be "obvious" when they are wrong.
It cost me a lot to get out of that mindset.
We also have the issue of that we need to teach people to deliver what the professor wants, but learn how it's really done simultaneously. There are way too many professors that will fail you because you didn't use their way
Even if that includes making your shopping cart a singleton >_>
As far as I'm concerned, it is your obligation to be failed. Anything else would be a violation of the ACM code of ethics, and you will be faced with the same sort of demands in the real world.
7:06 AM
@o11c Well, if you can't flex and do what the professor wants while learning the real deal, then why go to school at all? You still won't get your degree...
On the other hand, the school system here might be a bit different; if you complain about a professor, he/she can actually get sacked.
Q: Undo format when format disappears

sc_rayI was posed a question as follows: Given a sentence like "Sam is a bad man", lets say all the formatting disappears and you are left with one string "samisabadman". Given a dictionary of words, design an algorithm to find the optimal way of "unconcatenating" the sequence of words. The optimality...

7:25 AM
@o11c Keep trying, we all have to learn it someday.
@Vogel612 Monking
@Gemtastic That. Get your degree first, learn how it's really done either in the process or after. But first things first.
I'm a little bummed out that my current education doesn't give you a degree
@Gemtastic if you network properly, you don't really need a degree
@o11c Oh I know. But I still wished I'd get a degree out of it :P
@o11c Networking can be even more difficult, depending on your situation.
Sure, for the first 5 years or so you won't get paid like a degree-holder does, but you are getting paid instead of paying for school.
7:40 AM
School is free here! But you need to live while in school...
Also, you need to get accepted into uni
8:04 AM
Hmm.. I just unpacked and checked our new Gen 6 Server for testing and virtualization
I like it
that's good :)
@Vogel612 What was it's predecessor?
@Mast mostly inexistant
or rather old desktops that were replaced when people moved to macs.
and there each testsystem got one desktop, these all were scattered around the rooms..
then again the company only has less than 20 some employees
8:09 AM
So you went from distributed crap to high-end dedicated?
well.. yes
Sounds good :-)
and in a company without dedicated sysadmins I am the poor sod that will have to install the hypervisor and set stuff up
Depending on what you normally do, that might be a nice break.
maybe I should ask my boss to let me set up a small DHCP and DNS in a separate VM there
@Mast it definitely will be, yes. I'm still kinda wondering, though...
8:13 AM
This is the best stage to implement long needed/wanted changes.
But I'm nowhere near long enough in this company to understand these needed / wanted changes
This question belongs on codereview.stackexchange.comTorxed 20 secs ago
Is there a senior around with whom you can communicate easily?
There may be an unofficial 'if we ever get the chance, this is what we should change' list floating around, written down or not.
well maybe... I don't know...
Just ask.
If they don't care, they don't care. If they do care, they'll be forever grateful.
8:23 AM
Monking @skiwi
@Mast point taken
New blue people!!!
8:23 AM
Oh, the disappointment of waking up on my first day as a mod and seeing that there are no flags to handle! (@200_success seems to be on duty)
And I'm probably out of stars now due to a star backlog
@SimonAndréForsberg Have you ever heard about the Blue Man group?
That would be a way better video to share
8:33 AM
Does CR review db schemas?
@Torxed Why is it off-topic here? — jacwah 12 mins ago
@jacwah because he's not having an actual issue with his code, this is a request to enhance a already working example. Meaning it's due for a review not help (this is a "we help you fix your issue" site and the link i gave is a "we optimize for you" site) — Torxed 4 mins ago
@Gemtastic I highly doubt
You can try DBA
Is this correct?
OP is saying that they're code is too slow on SO
Let Simon handle that
(Again, sorry for calling you Salmon yesterday :/)
8:36 AM
@Gemtastic We had a SQL CREATE script a couple of days ago, that was decided to be on topic
As long as it's a script and not just UML or something
That's not the same as a db schema
@jacwah He wants the schema, not the SQL code
The schema is off-topic here, in my opinion.
Well, I want a review of a db schema
You have the DataBase Administrer
Or how you spell it
That website if for this issue.
I know, I was just wondering if that's something CR handles since DBA is not a reviewing community
8:38 AM
Ping an admin and ask
Try salmon
I suppose you can call it "testing the line" of what this site accepts
I already miss monkey as an admin :/
Q: Are database design reviews in scope?

BenVSee this question: Can you peer review my database design for a school system?

You mean, rolfl?
That post is 4 years old though
8:39 AM
(I don't mind the result of the election, but monkey was a good mod)
Q: What's the proper way to ask for database review?

mikeTheLiarI'm currently designing a database that I wanted to get some input on. It's entirely theoretical at this point, I haven't written a single line of SQL. Would it be acceptable to just post the database diagrams that I've made, pointing out the specific areas that I'm unsure about? If not, what oth...

Is there an easy way to change a key on my keyboard? The left \shift is too small and to the right is a \| key
Yeah, he was a good mod, but it was our decision for him to do not be a mob anymore, in a certain way
I'd want it to be a big \shift key
You can't
Most of the keys have the 'support' to make 'contact' in the middle
8:41 AM
I don't mean physically changing it
@Gemtastic soo.. DBA does accept schema reviews, but they're gray-ish
You can try to set an AutoHotkey script
you can ask them in The HEAP(tm) if you want to make sure
@Vogel612 And database schema reviews are grayish here too
basically I think the schema in and of itself is off
<-- personal opinion
because it's not "code", but design
8:42 AM
I agree with you, but I'm still wanting a review
That's what I'm saying
The schema isn't code
The design should be on DBA
and we don't do design review, but code-review. You can see the CREATE script as "code" but IMO that's still design
The SQL code should be here
Check out the meta posts I've linked and ask one of our new mods
Well, I could write the schema in SQL code
8:44 AM
@Gemtastic That would be polishing it to be on-topic
But it's still the design I want reviewed :P
@Gemtastic We can review database schemas, but the technicality is that you have to ask the question as code (CREATE TABLE…). We don't review E-R diagrams.
@skiwi You can write your own keyboard lay-out.
@200_success imo that's splitting hairs
@Vogel612 Why?
8:44 AM
E-R diagram and CREATE TABLE scripts are basically the same thing, just seen from a different angle
@200_success So the requirement for it to be on CR would be to SQL the design?
high-level architecture reviews are off-topic
Or as put "polish it into being on-topic"
Yes, but there are RDBMS-specific nuances that we can catch in CREATE TABLE statements that wouldn't appear in an E-R diagram.
CREATE TABLEs are also on for DBA though..
and frankly, they know their stuff....
from what I've seen here, the large majority of reviewers is dev people, not dba people
and the SQL boils down to "making it work"
for DBA it boils down to making it good
or even blazingly fast
8:47 AM
@Mast easy way :P I'll try to live with it now
Meh, nobody listens to me
I guess we have had this disagreement recently:
@Vogel612 Database schema reviews have been asked here before. The technicality is that the question has to be asked as code; we don't review E-R diagrams. — 200_success ♦ Jul 10 at 16:44
8:51 AM
@200_success yes we did have it :D
I really need to write up a nice meta about it...
grats new mods :-)
Sadly I missed the party it seems :(

« first day (802 days earlier)      last day (2022 days later) »