« first day (690 days earlier)      last day (3352 days later) » 

2:00 PM
@Morwenn my thought exactly!
2:13 PM
Q: Iterating over the lines of a stream

qdiiThis structure is supposed to iterate over the lines of an input stream, using std::getline. Any remark is welcome! #include <iostream> //istream #include <cassert> struct line_iterator { explicit line_iterator( std::istream & is ) : m_stream( &is ) , m_line( extract_lin...

@Morwenn Oh god...
In all fairness, you could have some evil fun by writing code in such a way that it is valid for multiple languages and then not tag it
Well, Mr. Singh deleted his own account.
Yeah. I was working on an answer too.. Oh well I guess.
Do we need a tag?
(Do we have one?)
Can't understand why it continued to get downvotes after it was re-opened.
2:24 PM
We do...
Q: Why doesn't it raise a syntax error?

MichaelWhy is this line valid in javascript ? var a = 0[0]; After that, a is undefined.

Because it's tagged Javascript
2:46 PM
@rolfl Why doesn't 2 << -1 in Java return 1 ?
Or am I stupid?
Java internally does a bitmask of the shift value with 0x3f
So, it will do a shift by 31.
which is..... 0
explains it
>> doesn't seem to 'wrap around' at all with negative numbers though, like << do.
2:49 PM
it's masked with 0x1f not ox3f.
me being daft... and miscounting.
yeah, of course.
I '31' sounded reasonable, didn't think about the fact that that corresponds to 0x1f and not 0x3f.
user image
@skiwi chances are it doesn't really work then.
It just seems like it works.
Not my situation right now luckily, but I found that one!
Neither claiming or denying that I have been in such situation before
Q: Java safe Thread Synchronizing

Jordi Castillahaving Data.java public class Data { private int value; public Data(int value) { this.value = value; } public synchronized int getValue(int mTrhead) { System.out.println("MyTrhead " + mTrhead + " gets value " + value); return value; } public synchronized void setValue(i...

3:03 PM
@RubberDuck or you deploy it after testing only to find out that production environment isn't the same as the testing environment or the staging environment, so something is broken, or better, everything is broken
@Malachi Been there, done that What are you even talking about?
@RubberDuck I don't know what question you are talking about, but being on-topic and being a good question are not the same thing.
@skiwi my life story as a programmer...?
@nhgrif agreed, but it wasn't a bad one either.
Today I have been doing HTML, CSS and Javascript, and had to make all of that communicate with a Qt application written in Python.
Hours of fun.
3:08 PM
Wasn't a good one, but certainly didn't deserve 4 downvotes.
Q: Haskell requires more memory than Python when I read map from file. Why?

Alexander RazorenovI have this simple code in Python: input = open("baseforms.txt","r",encoding='utf8') S = {} for i in input: words = i.split() S.update( {j:words[0] for j in words} ) print(S.get("sometext","not found")) print(len(S)) It requires 300MB for work. "baseforms.txt" size is 123M. I've wrote...

Q: Db request for more optimize

Legendary 1) Postgresql 2) User has_many :reports 3) Report belongs_to :user 3) Report belongs_to :publication 4) Publication has_many :reports 4) Publication scope :photos, -> { where(publication_type: 'Social::Photo').where(show: true) } 4) Publication scope :tweets, -> { where(publication_type: 'Socia...

@Malachi What's a development environment? You mean people don't just develop in production? Crazy....
I'm starting to think that I need a new job whether or not I get laid off.
@RubberDuck I actually brought that up in my team meeting yesterday. Project manager said I wouldn't be able to get the Third party holding the Servers to make all our environments the same framework and such, I said that I would have to start testing in production then...he kind of got quiet. we will see when I have to have the third party push the replication button on my stage code....I don't look forward to what might happen
@RubberDuck You know, I was running a text-based browser game yeaaars ago, and it had an index.php that got used for every file with some .htaccess magic; Sometimes when testing new stuff I would cause a syntax error and then nobody could use the site anymore for a minute orso :D
anyone interested in a Star Trek Q question? --> scifi.stackexchange.com/q/84742/25784
3:17 PM
@Malachi Did you really spoiler tag a question about a movie that's almost 40 years old?
LOL yes, yes I did
le sigh
just in case.
> so I will ask it in spoilers in the odd case that you haven't seen it yet.
I did say "in the odd case.."
Q: Java 8 Regex matcher method optimization

RanPaulI have a below method in Java 8 which checks for message pattern and finds the line number from the message private LawfirmInvoice getInvoiceForErrormessage(InvoiceParcel parcel, String message) { if (parcel.getInvoices() != null) { if (parcel.getInvoices().size() == 1) ...

How do I have a nullable integer as an optional Param in VB.NET?
3:20 PM
Also, because I'm a jerk.... google search
"Optional parameters cannot have structure types"
I already tried that.
Sounds like you're running <VB.Net 10.0
The answer on SO is, "you can't".
So, you'll probably have to require it and null check.
If you don't have one to pass, pass null into the call instead.
Why are you using nullable integers anyway @nhgrif?
Now I have to explain Nothing to people...
Because the form for editing something and creating a new something are the same. And if the variable is nothing, that means it's a new record because it doesn't have an ID in the DB yet.
@skiwi Interesting use of transparency......
@rolfl Hover over this chat message, and look at the monitor stand of the above picture.
@nhgrif ahh ok. DB. That makes sense.
3:30 PM
@rolfl Yep noticed it, I had the blue version as it was my own text
I have that now too ... whoopee
The stands are so important that they should always be white
I'm confused...
@SimonAndréForsberg Bah, politicians.
@Residuum OK, I deleted the question and reposted in codereview.stackexchange.comalexchenco 1 min ago
3:34 PM
Q: Is there a cleaner way to write these if statements?

janoChenThe following code reads a file, splits its data, replaces some characters in the data, and then joins the data again: fs.readFile(filename, 'utf8', function(err, data) { if (err) throw err data = data.split('\n\n') var tree = data.slice() for (var i = 0; i < tree.length; ++i) { if...

@CaptainObvious If they look messy, there is a 99.99% chance they can be cleaned up.
@Hosch250 What's the 0.01% case?
@skiwi I've never yet encountered it.
Probably it is less than .01%
But, statistically, you can't quite get to an absolute 100%
Q: Converting imperative style user input menu to functional programming style

Jacob MortensenI am currently trying to teach myself scala by rewriting projects from my intro CS class, which was taught in C++. In addition to just learning the syntax I am trying to gain understanding of how functional programming works and what is considered good functional programming style. Below I've i...

There's usually a cleaner way, but cleaner isn't better 100% of the time.
3:46 PM
Well, there's two tags I would have never thought would be on the same question.
This hashtag has such potential to be chock full of win.
4:04 PM
And it's a question I can actually answer. Woot!
like one or 2 people liked that question and then it was downvoted to 0.... :( I thought it was a good theory.
maybe I just suck at asking questions
4:23 PM
Q: Performance concerns regarding domain model logic

xerxesI have a domain model which determines whether a user has any access left. this class is loaded from the database on each web request. the setter on the property that determines the access limit logic is only accessed when the database loads this data into the domain object. should I be concer...

Just taught a lesson on multi threading and why sleep is usually bad.
Did it sink in?
I don't know yet. I sink so, but he's still sinking about it.
Q: Array Sorting in C++

T145I have this simple implementation for array sorting: #include <iostream> #include <stdlib.h> using namespace std; // some magic for the sorter int compare(const void *i, const void *j) { int a = *(int *) i, b = *(int *) j; return a < b ? -1 : a > b ? 1 : 0; } int main() { int arr[...

Q: Should I add "Service" postfix to service class name?

yukasI have a class CreateUser in services folder in Rails app. Should I leave it as it is or should I rename it CreateUserService? It seem for me like "Service" postfix is useless and does not commit anything to meaning of the class.

Q: AdjacentElementsIteratorAdaptor for Random Access Iterators

NobodyInspired by this comment I decided to implement an iterator adaptor that takes another iterator and returns each element and a given number of its neighbors. The final solution should be applicable to most iterator types but this review is only about my first solution for random access iterators...

You'll probably get a better response and would be more fitting if posted in Code Review codereview.stackexchange.comFred -ii- 1 min ago
If you want someone to review your code you should ask on Code Review but check their help centre before you post. — Hobo Sapiens 1 min ago
4:41 PM
Hmm. I need to do more stuff if I'm going to maintain my current privileges when we graduate.
(Close reason) You'll probably get a better response and would be more fitting if posted in Code Review codereview.stackexchange.com — ʰᵈˑ 1 min ago
@Donald.McLean How many points do we need to keep them?
10k points... Well, getting to there shouldn't be too hard.
It's still a long way to go here :p
Especially if you have a life.
4:57 PM
I try to answer sporadically some questions, but tbh I prefer just sitting here (idle) in chat ;)
@Duga Is someone trying to anger me and @nhgrif?
@ʰᵈˑ Being on-topic at Code Review and off-topic at Stack Overflow are not the same thing. Being on-topic at Code Review is not a close reason. If you feel this would be better on Code Review, then flag it for migration using a custom flag. If you feel this is off-topic for Stack Overflow for a reason defined in the help center, vote to close for that reason. — Simon André Forsberg 40 secs ago
@SimonAndréForsberg I was having a question for you. How do you let Duga interact with the chat of SE? I can't find any information in the SE API related to the chat. (api.stackexchange.com/docs)
@DJanssens You can't via the API, what we are using is sending literal HTTP requests to send messages
It's quite messy, I ported an existing SE bot, not sure anymore who wrote it though, from some other language (Ruby I think?) to Java
5:04 PM
Q: Simulating a GUI windowing system - follow-up

coderoddeThe previous and initial iteration at Simulating a GUI windowing system I have essentially cleaned the code based on the only answer. Now I have: MyCanvas.java: package net.coderodde.gui.simulation; import java.awt.Canvas; import java.awt.Color; import java.awt.Dimension; import java.awt....

@DJanssens @Vogel612 knows about a more library-like solution for using SE Chat in a Java application. I haven't checked that out myself entirely
ah cool
Isn't that rather hard since I guess you also need to handle OAuth?
seen this?
A: Hi! What brings you here today?

cpicancoBrand loyalty? I think that this question is a good starting point to know a little bit more about your customers. Is well know that any product/service can be improved by gathering relevant information about the consumer needs. In my own case, I really enjoy DIY projects. I am not a profession...

@DJanssens A bunch of posts and redirections... yes
Well, I actually read the post and it's quite interesting.
5:18 PM
Sorry, didn't know about Code Review, I'll post it there. — schogol 24 secs ago
Just realized I haven't written my history there.
Don't worry, I'll refrain from boring you.
@SimonAndréForsberg I have been called?
@skiwi that was probably either smokey or ProgramFOX's bot
Concerning the Library-Like solution... it's not finished yet.
alpha is coming up, but I currently can't develop there (because the "owner" hasn't published code yet)
but it's coming...
internally it won't work any different than the mess of HTTP-Requests though
@Vogel612 I believe @Doorknob, also known as KeyboardFire, wrote a bot in Ruby that can interact with the chat.
hmm... he renamed?
dammit I missed out
No, he goes by Doorknob here and KeyboardFire elsewhere on the web.
Boy, I'm making a lot of typos.
5:25 PM
right... smokey was on python basis I think..
I'll have to write a quick thing that can post messages here in C# when I learn to interact with the web.
So far, I've copy/pasted code from SO to ping Google and to attempt to load their page to check if my computer is online - that is it.
@Hosch250 Neither have I.
If I am ever a manager, I'm going to make a strict policy that people have to be polite, or their out the door.
C-type conflict is good in certain quantities, although wearing if you have to continuously defend your statements every time you turn around.
A-type is murderous (both figuratively and literally).
(C == cognitive, A == affective)
@Hosch250 there's something for that already...
@Vogel612 Eh?
@Duga is written in Java.
Anyway, this would just be a learning exercise (well, if I ever write a WP app for SE, it might get used).
Oh, OK.
... I am quite sure it's in use over at anime
Alright, but I still need a learning exercise...
do it anyways
Maybe I'll write an app that can publish to WordPress blogs.
5:34 PM
if you're stuck you can check
If I'm stuck, I'll probably smoke the doc.
there is no doc
the doc is a lie
There is a C# doc.
@Vogel612 because @Hosch250 smoked it.
MSDN is good enough...
5:35 PM
@Hosch250 you'll be stuck with chat "api" if you want to make a bot
I've learned almost everything I know about C# there.
32 mins ago, by skiwi
@DJanssens You can't via the API, what we are using is sending literal HTTP requests to send messages
friends don't let friends cast to object
@DanLyons now if that would've happened in my current project then I maybe had a sensible way of passing data
because Friends who don't let friends cast to object also don't let them create data wrappers that are working on a Map basis with a String key
What are you guys talking about?
I ran into a wonderful regression bug where someone was passing two values to a method for comparing equality and removed the cast one of them had to make sure both values were the same type.
The method called just took in object types, so the compiler naturally didn't complain that the values were now two different types, meaning that the equality check would always fail.
5:40 PM
hmm... that would be a findbugs SCARY & High confidence
Well, I could write a generic swap method that took objects.
there's all kinds of tragedy with this code :|
@DanLyons Java?
it's C#
OK, C# is different, and I don't know it well enough
Java cast does no change the object type.
5:42 PM
Q: Disruptor pattern and C++ acquire/release semantics

headeronlyI'm implementing a quick and dirty lock-free MPMC queue in C++, based on the v3 Disruptor algorithm. The implementation is pretty simple: Data to be shared between threads is stored in a ring buffer. The ring buffer maintains a sequence number that points to the next available slot. Consumer th...

but it isn't a good idea in Java either
the two larger tragedies is that the comparison method works just fine with a generic type argument, and the values are only different types because one of them has primitive obsession
(other than for primitives).
@rolfl Wth, isn't it the whole point of casting?
No, the point of casting is to tell the compiler that you know what you are doing.
(other than with primitives).
For example, the code:
5:45 PM
Oh. Right.
List<String> mylist = ......
ArrayList<String> .....
yeah, you get it.
it does not actally change the type, it just throws an exception if the type was not already that type.
Java has generic covariance?
Q: Age in years at a specific date

bumperboxFor eligibility to events I need to know the age of a competitor at a specific date. Now the thing is the date calcs are checked in two places, an online php app where the entries are registered, and an offline java app that runs the events. So I have 2 versions of the same code, the php one wa...

My worst nightmares..... ^^^^^
Oh wait, List<T> implements ArrayList<T>?
If you want suggestions for code and style improvement, then codereview.stackexchange.com might be a better place to ask. Otherwise, please explain where you are stuck. — Neil Slater 53 secs ago
5:48 PM
other way around....
ArrayList<T> implements List<T>
If you have an instance that you know is a List<T>, you can tell the compiler that you happen to know that the List<T> is actually an ArrayList<T>
So List<T> is an interface right?
(or, it could be a superclass).
you can also cast the other way if you want, but it is implied anyway.
Ah. Well there's a difference!
5:49 PM
You can say:
Q: Age in years at a specific date

bumperboxFor eligibility to events I need to know the age of a competitor at a specific date. Now the thing is the date calcs are checked in two places, an online php app where the entries are registered, and an offline java app that runs the events. So I have 2 versions of the same code, the php one wa...

ArrayList<T> alist = new ArrayList<>();
List<T> listt = (List<T>)arraylistt;
List<T> listu = arraylistt;
ArrayList<T> cast = (ArrayList<T>)listu;
Those will all work.
But, you cannot do:
LinkedList<T> = (LinkedList<T>)listu
well you can try...
but it ends in a ClassCastException
Now, you can do it, but you will get a runtime excpeption.
@rolfl Oh, I would star if I could!
5:54 PM
Optional down casting is cool.
I have decided to +1 that question... it's actually good.
Isn't the question of a which-version-is-best type, but then between two languages? Or is the old php code just there for reference
if let foo = bar as? LinkedList { /* ... */ }
question... why can I not inline edit the tags on that question??
@nhgrif wut?
@Vogel612 PICNIC
5:57 PM
Q: is this recursive copy function sufficient

schogolI created this function and I'm unsure if it is sufficient for "real world use", because all code snippets on the net I found for recursive copy functions used functions like $hDir = opendir($sSrc) which I don't think are necessary. That's why I like to have my func checked by some php-profess...

@Vogel612 optional casting
@rolfl hmm.. I am so free to seriously doubt that...
I am logged in, I can actually hover my mouse there and I got edit privileges...
It works for me.... but, I can't test as you....
hmm. okay...
I know...
Have you refreshed the page?
An edit went through, and maybe the previous edit made the tag-edit disable?
5:59 PM
> Failed to load resource: net::ERR_NAME_RESOLUTION_FAILED
I did refresh the page but DNS had a hiccup..
your DNS server is down, but, because Chat is a websocket, it's OK.
it is no more
6:42 PM
The if clause enters if bar can be downcast to other type and into foo, otherwise not.
@Mat'sMug @RubberDuck You guys around?
Does RubberDuck check for circular references?
Rubberduck assumes the code compiles!
(so... no)
@Hosch250 Yo. What's up?
What do you mean exactly by circular references? (and no btw)
Oh, OK.
I'm just curious as to why you're asking. =)
6:45 PM
I don't know what a circular reference is exactly, but someone wants a Wiki article at the MS Community on how to check for circular references.
hold on...
@Hosch250 Try touching the top of your thumb with that thumb, if you succeed, you have a circular reference
nope. won't even let you do it
Apparently someone didn't know enough to not write one...
Anyway, is a circular reference where A calls B that calls A....
or did you mean Class A has a reference to an instance of Class B, which itself has a reference to an instance of Class A?
6:47 PM
Does recursion count as a cyclic reference?
@Mat'sMug Yeah, something along that line.
@Hosch250 Yes, but the circle length can be any number
Project1 > references > Project2
Project2 > references > Project1
@skiwi Well, yeah...
is it necessarily a bad design if class A refs class B which refs class A?
how about tree nodes with a Parent property?
@Mat'sMug Yes...
6:52 PM
..or how about the entire VBE object model?
I'm off for lunch, see you.
But I think we're talking about two different kinds of circular references.
better "off to lunch" than "out to lunch"....
@Mat'sMug nope
That's how navigation properties in EF work

ClassA Has A Class B and Class B Has a Class C Which Has A Class A
Which is definitely a bad design.
6:54 PM
Author has a list of books that have their author
You guys are making my brain spin.
And there's Class A Has A Reference to Class B Which Has A Reference to Its Parent
Which is a bit more debatable.
But it's a hard thing to properly deal with in VB6 at least.
When did Janos say he'd be back? ....
(Did he say he was going somewhere...?)
Circular references in Java are fine if they are all compiled together.... For example, String join ( Here: docs.oracle.com/javase/8/docs/api/java/lang/… )
It takes a CharSequence object as input...
and CharSequence has a toString() method: docs.oracle.com/javase/8/docs/api/java/lang/…
Abby T. Miller on March 25, 2015

Welcome to the Stack Exchange Podcast Episode #63, recorded March 6, 2015 in front of a live-ish audience. Today’s podcast is brought to you by Cool Whip by Kraft Foods. A description for this result is not available because of this site’s robots.txt — learn more! Our hosts today are Joel Spolsky, David Fullerton, and Jay Hanlon… as usual.

So what’s new? David went to London. (We have an office there. It’s awesome and it has graffiti on the walls.) David flew out to meet the London marketing team, spend time with some of our European developers, and get knighted. Probably. …

@Legato @Mat'sMug What's unclear about this question?
Q: Fetching photos and tweets related to selected publications

Legendary 1) Postgresql 2) User has_many :reports 3) Report belongs_to :user 3) Report belongs_to :publication 4) Publication has_many :reports 4) Publication scope :photos, -> { where(publication_type: 'Social::Photo').where(show: true) } 4) Publication scope :tweets, -> { where(publication_type: 'Socia...

7:07 PM
Has this question been driving anybody else crazy? I look at it at least once a week.
Q: Is my MergeUtility good enough to create an open source project out of?

Aaron AnodideHere is a utility that supports ETL/merging in Entity Framework. If it's not appealing as a general purpose tool, why? If it is appealing as a general purpose tool, how might the design be made better? Also, I'm not the world's most experienced programmer when it comes to writing re-usable co...

@RubberDuck I can't agree with "definitely bad design", I think...
Q: Java 8 file read method optimization

RanPaulI have a method which extract filedata and converts it into String array protected String[] extractLedesText(byte[] fileData) { // Remove the BOM if present byte[] array = { (byte) 0xEF, (byte) 0xBB, (byte) 0xBF }; byte[] data = { fileData[0], fileData[1], fileData[2] }; if (fil...

@nhgrif IMHO.. it just feels wrong and error prone to have A depend on B which depends C which depends on A.
I have a structure which is dependent on itself.
I wonder why it doesn't recursively call itself and blow up, now that I think of it.
7:26 PM
Let me think about it.
@200_success retracted, but it needs a serious edit into readable English.
I tried. Twice.
Deleted both edits.
Damn, if I wouldn't have a real profile picture now, then my old box image would really be outdated
Q: union based approach to implement variant

OrientThis implementation of discriminated union based on C++ inherent unions and inspired by this article, but, alas, there is a lack of constexpr-awareness concern. #pragma once #include <type_traits> #include <typeinfo> #include <limits> template< typename ...types > struct identity { }; template<

8:06 PM
Monking, everyone.
Hey @SirPython and @Donald
@SirPython - I was hoping to draw your attention to this as well (this is regularly pointed out to people as their reputation crosses various thresholds.... and opens the review queues...): meta.codereview.stackexchange.com/a/1947/31503
8:24 PM
That looks fine to me. However "Is this the right way to do this" type questions are really better suited for codereview.stackexchange.com than for stackoverflow. — James_D 1 min ago
@rolfl I've had access to the queue and first posts for a while now. Are you showing me this because I have done something wrong?
I'm pointing it out because you have a relatively high ratio of "no-action-needed" reviews, and was wondering whether you were aware of that post.
Oh! Sorry about the misunderstanding.
From now on, I'll just skip it so it stays in the queue for someone else.
That's the idea. If you don't think you can be the welcome wagon, then leave it for someone else. Many people think "no-action-needed" is the "leave it for someone else" button, but it's the "skip" button you want for that.
8:41 PM
I was always unsure of that - thanks for clearing that up. But then that confuses me about something else: if, on a close or reopen queue entry, vote to close or reopen and click "Done", does that remove that entry from the queue?
On those queues, more than one vote is required.
the first post has only 1 person do the review...
so, doing something and clicking "I'm Done" is fine, because others have been, or will be there too.
Okay. Thank you.
first-post and late-answer queues are the only one-review-and-done queues.
A: Why objects are not dealloced in the dealloc method?

nhgrifThe simplest way to illustrate weak references is with the following example... Given the following two classes: @interface ObjectWithStrongRef : NSObject @property (strong) NSString *ref; @end @interface ObjectWithWeakRef : NSObject @property (weak) NSString *ref; @end We will create an...

Talking about welcoming, I've been noticing a lot of downvotes/closevotes without comments.
8:50 PM
How can I make font in a Stack Exchange post smaller than normal?
that's supported?
Or, just add <sub> .... </sub> .... ;-)
I just do <sub>small text</sub>
Thank you.
Remember that is the HTML for a subscript.
8:54 PM
indeed. <sup>works as well</sup>
That is superscript.
I figured as much
So, it probably is aligned differently.
Like, Text <sub>sub text</sub> will not look the same as Text <sup>sup text</sup>
8:55 PM
exactly. I think that's as much freedom you get on SE posts though, as far as font is concerned (excluding the H tags and ###)
BTW, I've not changed my code to align with the two latest answers on my questions.
I've been writing a paper on Ben and Jerry's, and I never want to see the words "Ben and Jerry's" again!
bbum has commented on that question and my answer.
He works for Apple.
Oh, I thought you were Mat'sMug.
@nhgrif nice!
He has 10,665 net upvotes in Objective-C.
8:59 PM
Nice to be recognized by an Apple employee, unless he told you that you had it all wrong.
He wasn't saying I was wrong, he was just taking on a warning to my example.
A: What's the difference between the atomic and nonatomic attributes?

bbumThe last two are identical; "atomic" is the default behavior (note that it is not actually a keyword; it is specified only by the absence of nonatomic -- atomic was added as a keyword in recent versions of llvm/clang). Assuming that you are @synthesizing the method implementations, atomic vs. no...


« first day (690 days earlier)      last day (3352 days later) »