« first day (386 days earlier)      last day (4564 days later) » 

6:00 PM
Apparently, there was a time when posting interesting videos was okay on SO :)
13
Q: What are great programming-related online talks / videos?

naminPlease recommend a particular programming-related talk / video and explain why you like it.

 
anyone here familiar with boost::serialization?
 
Gonna get closed.
But it's a good place to drop a link to our list :)
Oh, it's old and it's not closed.
 
how do you test for success of boost serialization?
 
Deserialise and compare with original?
 
6:04 PM
@RMartinhoFernandes seriously
 
yes, seriously
 
a "no idea" would suffice
:p
 
> Time is what prevents everything from happening at once. — John Archibald Wheeler
 
@wilhelmtell But that is the only way to test it. How else would you?
 
Hi:)
 
6:11 PM
@wilhelmtell Success of what?
 
Is it possible to cancel a synchronous operation after a timeout
Nevermind :)
 
memcpy requires that source and destination parameters must be of the same type?
@MrAnubis Hello
 
Why are you using memcpy? C or C++?
 
memcpy requires they be void* and const void*
 
@LewsTherin What's up man?
 
6:26 PM
@awoodland I guess that's the easy way out for me.
@MrAnubis Hey, same crap dude :(
 
I'm not sure I'd ever describe memcpy as "the easy way out"
 
@LewsTherin same here , anyways memcpy copies the binary bits from src to dst ?
 
memcpy is "the silly way in". Into trouble.
 
@awoodland I mean casting the parameters to void*
 
@MrAnubis Aren't bits always binary? :)
 
6:27 PM
@FredOverflow lol
 
@FredOverflow true :D
 
@LewsTherin No cast required, conversion from any pointer type to void* is implicit in both C and C++.
 
@LewsTherin - if they're pointers that'll happen automatically. if they're not pointers you really don't want to cast them
 
You only need a cast the other way around in C++.
 
(and only a reinterpret_cast or worse would let you do that)
 
6:29 PM
It's in C -_-
 
C loves pointers, casts and void*s.
 
I'm trying to copy the structure in h_addr_list[0] to struct in_addr
But I don't know if I am doing it right.. It appears to work
memcpy(&servAddr.sin_addr,&ptr->h_addr_list[0],sizeof(ptr->h_addr_list[0]));
 
How much do you copy? That is, what type is h_addr_list[0]? It's a pointer, right?
 
EOF char is returned by OS always to application right?
 
Isn't this memcpy call just a pointer cast?
 
6:31 PM
Isn't h_addr_list[0] a char*?
 
@FredOverflow So another dereference is needed
 
What's wrong with servAddr.sin_addr = ptr->h_addr_list[0]; then?
 
@RMartinhoFernandes I don't know! I keep asking myself that lol
The book has it that way
 
Lemme grab some docs.
This thing was returned form gethostname right?
No, wait, not that.
 
gethostbyname
 
6:33 PM
@FredOverflow EOF char is returned by OS always to application and dependent on OS, right?
 
@MrAnubis There is no EOF char. (well, there is, but not the one you're thinking of.)
 
EOF is an int that is -1 I think.
 
@RMartinhoFernandes so how does OS signals program that EOF has encountered?
 
By returning EOF, but EOF is not a char.
 
@FredOverflow both in linux and windows?
 
6:36 PM
Are we talking C? Then yes, EOF is part of C.
 
EOF is an int not a char
 
your mother is not a character
 
actually my mother is quite a character
2
 
@DeadMG She is in a certain television series.
 
@awoodland LOL
 
6:38 PM
@FredOverflow how? it's always OS work to tell to application , isn't it? so how EOF is part of C?
 
@MrAnubis By returning -1 from getchar()? I really don't see the big deal.
EOF is a macro.
#define EOF (-1)
 
@FredOverflow i am idiot :D , now got the idea:)
 
@RMartinhoFernandes did you find anything?
 
Well, you can just copy the pointer.
You cannot modify or free any member of hostent, so it's fine.
 
But you would have to insert a manual cast, probably.
 
6:43 PM
A cast to void* or to struct sockaddr?
 
Oh wait.
> Furthermore, only one copy of the hostent structure is allocated per thread, and an application should therefore copy any information that it needs before issuing any other Windows Sockets API calls.
 
@FredOverflow C++ also returns -1 to denote EOF ?
 
I don't know if this is true for POSIX sockets as well.
 
@MrAnubis Sure, why not? Did you expect -1++ instead? ;)
 
lol , thanks
 
6:45 PM
@MrAnubis (eof() is a member function on an iostream though)
 
@RMartinhoFernandes mmn I hope not...
 
Well, you need to copy the information you'll be taking from the structure.
 
Yeah, the ip address... It doesn't have a port number info. So I am defaulting to port 80
 
That's a reserved port for HTTP.
Oh wait, you're writing an HTTP server, right?
 
An http client. Make a request to a webserver and print the response.
2hrs of my life wasted :'(
 
6:49 PM
Can't you hack a program together that does that with 10 lines of Python in 5 minutes?
 
I don't like snakes :)
I really don't.
 
I don't like your mother
 
His mother doesn't like your snake.
 
feeling's mutual
 
Lol.
I'm about to give up.
 
7:01 PM
bye bye, have fun
 
Lol, I will. But I will be one among Angels. So be careful.
 
what's that in English?
 
Exactly what I said.
 
I see
in a not at all kind of way
 
When the hour is late, then your very eyes will see.
Forgetting to set the address family screws the program up. Bloody ashes
 
7:13 PM
dude, it's way too much to start swearing with fictional swearwords
 
@DeadMG Lol, not really. I do it even when I'm speaking. I guess I'm obssessed
 
oh, I see
it's "not really" way too much, but you are "obsessed"
interesting
 
What fictional swearword was it?
 
can't you tell from the context?
 
Er, no. :(
 
7:16 PM
@RMartinhoFernandes the memcpy doesn't work. Something is definitely screwed
 
yeah- using memcpy in the first place
 
@DeadMG I have to.. I will try bcopy
 
why do you "have to" use memcpy?
 
Just copy the thing. the_type_of_the_address blah = *(the_type_of_the_address*)hostentry->h_addr_list[0].
And make sure 0 is the one you want.
 
@RMartinhoFernandes How would I know if it is the one I want?
 
7:19 PM
How would I know?
 
it's your code
 
@RMartinhoFernandes You are a genius? Doing it the old fashioned way works
 
There's a reason h_addr_list is a list of addresses.
 
Yeah, but why would I need a different ip address as long as it connects to me to the web server
So any random one from the list should work ? :S
 
@LewsTherin What's the old fashioned way?
 
7:21 PM
get it wrong and pretend it's fine
 
@RMartinhoFernandes Sorry, copy assignment. Like you suggested.
 
@RMartinhoFernandes Is memcpy a swearword? :)
> Oh yeah? Well, you're a stupid memcpy!
 
memcpy is a frelling piece of dren. (sorry been watching too much Farscape.)
 
Time to switch to windows.
 
100
A: Java operator overload

paercebalThere are a lot of posts complaining about operator overloading. I felt I had to clarify the "operator overloading" concepts, offering an alternative viewpoint on this concept. Code obfuscating? This argument is a fallacy. Obfuscating is possible in all languages... It is as easy to obfuscat...

I like this answer.
 
7:28 PM
I like MyVengefulKickInYourHead.
 
Apparently not switching. I keep getting the same website!
 
@RMartinhoFernandes Lol.
 
@RMartinhoFernandes is that what you meant? One copy per thread?
 
@LewsTherin No. That part meant that if you called other functions the structure would be reused and you would not be guaranteed to point to the same data.
@FredOverflow Nah, C++ operator overloading is too weak to be used for obfuscation. Haskell's much better for that.
 
@RMartinhoFernandes mmn, so what's wrong... brb
 
7:32 PM
@RMartinhoFernandes Yeah, the Haskell crowd doesn't seem to dislike operator overloading at all :)
 
YES it works now.
 
> Gosling: I left out operator overloading as a fairly personal choice because I had seen too many people abuse it in C++.
> Stroustrup: Many C++ design decisions have their roots in my dislike for forcing people to do things in some particular way [...] Often, I was tempted to outlaw a feature I personally disliked, I refrained from doing so because I did not think I had the right to force my views on others.
Haha brilliant :)
 
Funny that I just read that interview the other day.
 
You must create at least 3 new operators to be an actual Haskell programmer.
 
It's a rite of passage.
 
7:39 PM
Okay, here we go: <=>, >=< and ===>.
 
What are those?
 
The last one is the penis operator.
 
Right, it pokes on things :)
 
The first one is a UFO.
 
7:40 PM
Perl users call it "spaceship".
 
The second one are hips or something.
@RMartinhoFernandes Really? And I thought I was being innovative :(
 
My age is my favorite power of two. :D
 
You have a favourite power of two?
@CatPlusPlus That's not a power of two.
 
7:47 PM
Sure is.
 
I'm pretty sure zero isn't a power of two- Yeah.
 
Oh, wait.
Derp.
I meant 1.
 
Yeah.
As in 2^0.
 
7:48 PM
Two to the what is zero?
 
Stop making fun of me!
 
Oh okay.
 
@Maxpm: zero of course, 0*0 = 0
 
7:49 PM
That's a silly operator.
<: is reverse silly operator.
 
@CatPlusPlus The ones starting with : are actually infix type constructors.
 
@Patrick Powers of two are 2^x.
 
Phsh.
$< is poorer than operator.
 
Anyway, my favorite power of two is 16. 2^0 = 1, 2^1 is 2, 2^2 is 4, 2^4 is 16, and 2^16 is something way too high.
 
@Maxpm Of course they are.. I withdraw my previous comment :P
 
7:51 PM
@CatPlusPlus In your defense, (x & (x-1)) == 0 yields true for 0 ;)
 
Mmkay. :P
 
You know powers of two only up to 4?
What sort of nerd are you.
 
@CatPlusPlus I know them up to 2^16. Seems to be a popular limit.
 
I know 1, 2, 4, 16, 32, 64, 128, 256, 512, 1024, 2048 and 4096 off the top of my head. :(
 
@FredOverflow You know them iterating forward, or random-access?
 
7:54 PM
@RMartinhoFernandes good question. I would say random access up to 2^12.
 
cpx
@Maxpm 2^3
 
@cpx And 8. Thank you.
 
@Maxpm lol, you forgot 8!
Twice!
 
8192 is easy, I find 16384 and 32768 bit useless.
65536 is easy, too.
 
I know them up to 2^16, and then I know 2^32.
 
7:55 PM
I remember 65536 mostly because of TCP/IP.
2^32 is 4 million-ish.
 
@RMartinhoFernandes I know it's 4 billion something, but that's it. And it ends in 95, I believe.
 
@FredOverflow What?
A power of two that ends in 95?
 
@CatPlusPlus You're off by a factor of 1000 :)
 
Heh.
 
@RMartinhoFernandes lol that was 2^32-1 :)
 
7:56 PM
:)
 
I am currently struggling with string literals. I dont know why all these 3 are not the same. char a[2] = {'a', 'x'};

char* b = new char[3];
b[0] = 'a';
b[1] = 'x';
b[2] = '\0';

char* c = "ax"; can somebody explain me that?
 
Beware, a has no NUL terminator.
c points to the 'a' of the string literal "ax".
 
3 is dangerous, invalid, and should be burned.
 
String literals are normally found in read only memory, and they have static storage duration.
It's valid C89 though :)
 
String literals like "Foo" are actually C-strings with null terminators, i.e. "Foo\0".
 
7:58 PM
@FredOverflow of course makes sense
 
It might be language-valid, but it's still not safe.
 
right
 
could you explain that to me?
 
But it was the only way to do it before C got the const keyword.
 
char a[3] = {'a', 'x'} is null-terminated though.
 
7:59 PM
i am wondering that
because strlen for example works fine on a
 
@bamboon If you say c[0] = 'x' you get undefined behavior.
 
@bamboon Pure (bad) luck.
 
@bamboon pure chance
 
i hate luck^^
 
Then you should stay away from UB.
 
8:00 PM
i try to
 
And C strings.
 
yeap, the bad luck
but it would work for a size of 3?
 
Yes, because if you provide less elements in the initialiser than the size, the missing ones get filled with zeroes.
 
makes sense
though
 
8:03 PM
I would avoid it anyway.
 
do empty blocks allocated by new also get filled with zeros? dont think so
 
Theoretically depends on the implementation, but default allocators usually don't do that.
But initialisation will zero out PODs, if you use new T().
For other types, ctor should do that.
 
217
A: Do the parentheses after the type name make a difference with new?

Michael BurrLet's get pedantic, because there are differences that can actually affect your code's behavior. Much of the following is taken from comments made to an "Old New Thing" article. Sometimes the memory returned by the new operator will be initialized, and sometimes it won't depending on whether the...

 
I'm not making a lot of sense lately. :.
 
intersting stuff
that ideone.com site is cool stuff too
 
8:15 PM
@bamboon new char[3] will give you garbage, new char[3]() will give you zeros.
 
@FredOverflow worth noting the Visual C++ never was very compliant about this. i don't know about the latest versions.
 
...Why do they even call it Visual C++? They seem to get a lot of basic things wrong :(
 
Because it's not C++. It's Visual C++.
Damn pluses don't get italicized.
> The Intel compiler intentionally disables many of its optimizations when the code executes on AMD chips. – mikerobi 1 hour ago
Hehe.
 
haha seriously?
 
8:22 PM
When the compiler runs on AMD? Or when the target platform is AMD?
 
ARM is Intels new enemy
 
I've heard LEG is pretty strong, too.
 
@bamboon I hope not the Amalgamated Regional Militia.
 
@RMartinhoFernandes no^^ it is en.wikipedia.org/wiki/ARM
the guys who do all the mobile chips
 
8:27 PM
Ah, not as fun then.
> I cannot compile this code. But I met a code like that and wanted to know whether such a notation is allowed (...)
Where do you go to meet codes?
And, more importantly, are they hot?
 
8:43 PM
link
 
Some silly old question I came across. I have since closed that tab.
 
Ctrl+Z?
 
Ok, ok, I'll find it.
-1
Q: Is it a legal notation: Foo &foo = Bar;

Loomstruct Foo {}; struct Bar : Foo {}; Foo &foo = Bar; // without () I wonder, Is it a legal notation? And if it is legal, could you give some details? Something like, Why it's legal? Or, What is the origin of such a notation? EDIT: I cannot compile this code. But I met a code like that and...

 
I only found this fake link...
 
8:51 PM
Wow.
Is that legal?
Oh, I found the attribution.
 
I have found several of these. Why do such websites even exist?
 
Oh, wait, it's not correctly attributed.
@FredOverflow SO content is free to share and remix.
 
9:14 PM
I cannot delete this audit message.
 
 
1 hour later…
10:16 PM
Possibly stupid question: Does copying arrays take a lot of time?
 
@KianMayne It takes linear time. The larger the array, the longer it takes.
 
@FredOverflow A byte array with 65535 elements?
Oh silly me
I'll just add a little thing asking if the size is the maximum (65535 bytes)
Which won't be very often (0.5% of the time)
 
@KianMayne Why don't you just measure?
The biggest influence is probably cache.
What do you mean by "asking if the size is the maximum (65535 bytes)"?
 
Because I haven't got anything to plug into the copier thingy until I finish another part of the project
Well I basically got a mini protocol
and there is times when a file will be sent over a connection
But most of the time it will just be text
And it won't be any where near the 1600 word mark so it will be under 65535 mark
and other codes on the protocol are just 1 or 2 bytes
and the only time it will be what I reckon will be a noticable time suck will be when it's files that are more than 65kB and that will probably end up implementing ftp and won't be part of the protocol
So I've realised that I don't even need to check and it won't take too long to copy things
 
I just wrote a simple test, and I can copy a 64K array 20.000 times per second.
If you are transferring files, then copying arrays doesn't matter at all. Disk performance will be your bottleneck. And networking, of course :)
 
10:30 PM
Really, you're sending things over the network, and worried about the copy of a simple array?
 
10:41 PM
Accessing data on a CPU register is equivalent to getting that information from your mind; data on cache is like information on your desk (L1), in your room (L2), or in your house (L3); data on RAM is like something on your city; data on disk is like something on Pluto (or Jupiter, if it's an SSD). Network speeds vary a lot, but you're still an astronaut.
 
It's the blocking that I don't want but clearly I don't have to worry about that
 
@RMartinhoFernandes Good work
I think the best method of securely erasing something is melting/burning it
 
Heh, it's not mine.
I don't think I can convince my father to let me waste a few bullets on an old broken drive I have around.
But I'm sure it would be fun.
 
10:58 PM
@KianMayne Personally, I believe dd if=/dev/zero of=/dev/your_harddrive_here is enough.
 
Hehe yeah
 
@FredOverflow But, but, the government, they, they, they have these things, they can get the magnetic something, and residual stuff, and then they can see your porn!
 
@FredOverflow Let me rephrase: the most secure method :)
 
@RMartinhoFernandes sounds rather esoteric
You could also fill your hard drive with boring documentaries and then rename them to porn titles.
like "on shift with the boobs operator"
 
$ mkfifo temp ; yes "Don't bother looking for porn here." > temp& ; dd if=temp of=/dev/your_harddrive_here
 
11:05 PM
Haha
I was just reading about it and yeah just one zero pass will render that hdd well and truly erased with the chances of getting any actual functional data practically nil
 
But the government!
 
Anyone can recover a bit with a certainty of 50%.
 
Hahaha so the chances of fully recovering a 1TB HDD is...
(Using the stupid advertising version because that's probably what it realistically is so 1000GB etc)
 
Secondary storage is sold with sizes in powers of ten.
 
1 in 8 trillion?
 
11:12 PM
(Well, except for 1.44MB floppies, where it was half in powers of ten, and another in powers of two)
 
So 1.25 × 10^-10 %
 
0.000000000125% that you recover it successfully :D
 
The odds of being struck by lightning are said to be 1/1000000 (though it varies from account to account).
 
> Beware: if you recover my hard drive successfully, lightning will strike you!
 
11:17 PM
@FredOverflow 8000 times
 
Ouch.
What kind of power supply does it use?
 
A broken one
 
The odds of recovering the hard drive and being struck by lightning would be 0.000000000000000125%, which leaves your warning without much credibility.
 
evening guise™
 
11:24 PM
been playing BF3 and it has some annoying controls and bugs in it :(
 
Somehow, I'm not surprised.
 
my flatmate finally returned and apparently, doing the washing up she left for a week is above her
I hate people
 
You're normal then.
 
even if generally despising other human beings was normal
I'm far too smart to be normal :)
brb gonna get some fudses
 
What are fudses?
 
11:51 PM
Hmm google doesn't know
What are fudses?
 
@KianMayne Obviously Google doesn't know. It's some word he contorted into sounding silly.
 
But...but..Google knows all...o.O
 

« first day (386 days earlier)      last day (4564 days later) »