« first day (1002 days earlier)      last day (4172 days later) » 

00:00
Why does acronym SFINAE looks like SNAFU?
Because it has mostly the same letters.
@sehe I hope they don't, haha.
It was just something extremely funny at the time. I mean cmon, that's pretty hilarious given the situation. xD
@milleniumbug no idea what snafu even means
Situation Normal: All Fucked Up
Situation Normal: All Fucked Up.
It's from the military IIRC.
user142019
00:08
@milleniumbug Because both apply to C++.
user142019
@StackedCrooked s/IIRC/and IRC/.
man
choosing feats in D&D 3.5e is tough.
so many awesome-looking feats.
00:25
Anyone read Absolute C++?
That's the book I have to use in half a year.
user142019
> You don't know how impressive it is.
user142019
LOL
That was not about C :P
user142019
He was referring to what he did in C. :P
a little part was about C
00:31
Web server now uses fork(). How do I stop this from making too many processes?
user142019
> I have a first-generation Chromebook, and the thing is slow and horrible.
user142019
:D
user142019
@minitech Use asynchronous I/O instead. See epoll or libev.
user142019
That way you can serve 10k clients on a limited number of threads without problems. Nginx does it too.
00:34
Yep, I’m planning on doing threads. Apache uses processes though, right?
user142019
Yes, but Apache is horrible.
Coliru doesn't work on Opera :(
Yes, I know Apache is horrible :)
Ugh, epoll exists. This was the better way I was looking for at the start, rather than timing out. Thanks @rightfold :)
user142019
epoll is Linux-only, though. The equivalent on OS X is kqueue. libev and libuv contain cross-platform wrappers.
user142019
Why are you writing a web server anyway? Can't you just use Nginx?
00:37
I’m okay with Linux-only.
@rightfold Just out of curiosity.
user142019
Ah, neat.
Wow, that's unfortunate.
@minitech You can use ulimit.
user142019
@chris What a modron.
user142019
@StackedCrooked fugly hack; won't work well.
00:39
@chris Where?
@rightfold Well, yeah, processes are quite a hack to begin with. :D
user142019
@minitech @StackedCrooked If you use the process-based approach, just keep track of the number of processes you create and queue waiting connections instead of using ulimit.
@chris Why?
user142019
listen(2) can even do the queueing for you. To some extent.
Okay, I think I’m missing something very important. Is there an easy way to tell when the client closes the connection to the server?
@rightfold That's the same as saying "don't make too many processes" :P
00:41
read returns 0… eventually…
@StackedCrooked Actually, I was just kind of doing if(!fork()) { while(serve_client(client)); }. :P
user142019
@minitech Look up EPOLLRDHUP if you use epoll. It's documented in epoll_ctl(2).
@minitech Client connection will send a TCP FIN segment.
@StackedCrooked Is that read by read?
user142019
@minitech No.
Not sure how you can know this from the socket API though.
00:43
Yeah, that’s what I’m wondering.
user142019
read(2) is a high-level abstraction. It doesn't care about TCP. It cares about file descriptors.
I was just hoping that might have been when it returned 0.
Go > C++
Argh. It does, doesn’t it?
I’m just not sending Connection: close.
user142019
@user782220 Agree.
user142019
00:45
@minitech Not sure.
@rightfold I suspect, that if read returns a value <0 then you can use errno to figure out if the connection has been closed or not.
user142019
I'd just use EPOLLRDHUP.
@rightfold Yep, I’m going to.
user142019
@StackedCrooked read returns 0 on EOF. Not sure if that also applies to sockets, though.
@StackedCrooked
These calls return the number of bytes received, or -1 if an error occurred. The return value will be 0 when the peer has performed an orderly shutdown.
00:47
But what if the number of bytes read actually is 0? (Due to network lag.)
@rightfold It seems to. Connection: close does it.
@StackedCrooked read will wait.
Ah, I see.
user142019
Connection: close forces the client to close the connection. You rarely want this.
Yep, I want keep-alive. Just making sure that things are actually sane.
user142019
00:49
Ah. :P
Oh yay, epoll(7) includes an example.
user142019
epoll is a piece of cake.
user142019
If you use C++ be sure to write a wrapper that uses RAII though.
user142019
I wrote one before but deleted it. (Far-fetched pun not intended.)
Nah, this is C :)
I will never be ready for C++.
6
00:55
You can do C++ minitech.
I believe in you. <3
user142019
If you like C, use C.
I don’t really like either, but this web server is a fun project anyways!
Also, templates using makefiles. (I know, I know…)
user142019
Do you write an HTTP parser yourself?
Yep, although this blog doesn’t involve any parsing of the body. And I’m going to ignore trailers.
user142019
For it to work with epoll it has to be event-based.
00:57
It’s a… state machine. I think.
user142019
HTTP parser needs to read the headers to discover the length and content encoding of the body.
I just close the connection without reading the body.
user142019
Oh, I see.
By the way; any horrible, glaring errors I should fix right away before things blow up?
Wanna see a record?
14
A: Every recursive problem has an iterative solution

VoodooChildAlready answered please see this link.

user142019
01:02
@minitech lack of epoll. :P
There you go: 140 juicy points for a "See this link" answer.
user142019
> HTTP/1.1 200 OK\nContent-Type: text/html;charset=utf-8\n
user142019
@minitech Must be \r\n, not \n.
user142019
HTTP uses CRLF instead of LF for separating headers.
@Jeffrey They get all the best ones
01:03
@Jeffrey You copied my answer and got 15 or more upvotes :(
@CatPlusPlus /cc @R.MartinhoFernandes Can I get an invite to the steam group? :)
@Rapptz ???
Naaaaaaame
@rightfold Right, all the rest too. Trimming them from the headers is going to be a nightmare too. :(
01:04
@Borgleader You're interrupting season finale, you could be brief about it. :<
@Rapptz What are you talking about?
user142019
@minitech You're not allowed to complain about nightmares when using C.
I don't think I've ever copied an answer in my whole SO career.
@minitech Now that's clean code. Would be even better if there was a space between if, while, for etc. and the ( because it's not a function, but still, really good looking. Awesome. :)
01:06
Oh I didn't mean literally copying, I was just being facetious.
@Tuntuni B]
lol, just because I came up with your same idea doesn't mean I've copied it...
Oh right.
@Rapptz I swear I've never seen that one. Here' get an upvote.
I was being facetious.
@Tuntuni Oh, you’re not being sarcastic? Thank you, then :D
@minitech Of course not lol.
01:08
@CatPlusPlus Call me back at your convenience, this was a non-blocking request
I reached the vote limit :(
I may or may not start putting spaces after keywords. Still on the edge on that.
@minitech Do it :D
I'm still noticing a lack of Steam ID here
borgleader06
01:09
Sent
Okay, time to add the states PROTOCOL_CR and HEADER_VALUE_CR. Sigh.
@CatPlusPlus tyvm
@minitech What are you working on?
@Tuntuni A blog-specific web server.
And if a stupid client (read: one I wrote) just uses \n — should I be lenient? Aaah.
@minitech Generally you should be lenient about what you receive and strict about what you send.
01:11
Making stuff foolproof and dealing with faulty input is always the hardest part.
The problem being when you actually need a lenient piece of software to act strictly…
It's crazy how many crappy answer SO got in its early months.
The bar kept raising.
user142019
Always output \r\n in HTTP.
user142019
Follow the spec.
01:14
: - O
stack doesn't grow towards heap ? wtf
user142019
What?
user142019
Maximum call stack size is usually fixed.
Stack’s position relative to heap is defined??
i was told at uni stack grows towards heap
user142019
If you want an infinite call stack use a segmented stack.
01:16
in PHP, 10 secs ago, by Ash Ketchum
Is there a place where you can get review and opinions on ideas without fearing them getting copied?
in linux it looks like its actually heap > lots of .so stuff > stack
> at uni
lol
@A.H. Yes, but at that point you are working with mapped addresses. So it's "imaginary".
@AshKetchum and you posted it here because...
The linux programming interface is a really good book.
01:17
More people = better possibility of someone knowing and being able to provide a good answer...
@StackedCrooked I am only concerned with where it is according to a process's address space
@AshKetchum You mean online?
Yes, asking online.
Is there an OpenGL 4.0 emulator for Linux?
01:20
@AshKetchum Rule #86: Nothing is safe or sure on The Internet.
@AshKetchum You can ask me. I never accomplish anything.
Then where do you suggest I get an opinion on it?
looks like a nice book
@AshKetchum Real people you trust.
Oh no :( The case already falls through. HEADER_VALUE_CR is going to be worse than I thought.
01:22
but unless i am reading /proc/../maps wrong both the stack and heap grow from low to high
@AshKetchum The loungers for example.
Real people? :D
If I do go and ask real people, I would get questions like, "Are you a nerd? Why would you even waste time on that stuff anyways? Stop dreaming."
sad.
Kinda.
01:24
well shit Etienne I guess it is a good show
What kind of idea is this?
user142019
@Crowz It is.
@rightfold I guessed you might say that.
user142019
Me too.
@Pawnguy7 A website idea.
01:27
Then… how should this parser be written?
user142019
@minitech Take a look at the interface of this one.
@AshKetchum Try to write this website down and buy an host and you'll see if it is a good idea.
@AshKetchum Nerds have it easier to find jobs and they earn more money :)
@StackedCrooked Not those that play Minecraft all day though
guys I just want to exist outside of reality
01:31
wat
@rightfold So multiple huge switch statements then. Good :D
@A.H. Random.
user142019
:P
@Jeffrey That's only a third of it though. Getting people to actually know about the site is other third of it. Then getting them to actively use the website is the final third of it.
Oops, wrong person :D
01:32
I’d usually do it with functions. But this is C.
Why are you using C again?
user142019
You can write functions in C. :v
But function pointers feel dirty.
Maybe they’re not.
They're not so bad.
Member function pointers are dirtier.
@CatPlusPlus Uh… not sure.
user142019
01:33
HOFs are best functions.
@Xeo Come onnn, be my friend. q_q
@AshKetchum you'll have to start somewhere. You have to invest in your ideas for them to be successful.
C is a bad language. Forget it exists.
@minitech In C all you have are functions, function pointers and macros. They are your primary means of abstraction.
@Mikhail Mesa claims OpenGL 3.1 support. That's about as good as it gets, I'm afraid.
user142019
01:34
@StackedCrooked for, while, do-while and if.
At a lower level.
user142019
They're abstractions over jumps.
room topic changed to Lounge<C++>: Don't Use C Stupid. [c++] [c++11] [c++-faq] [no-helpdesk] [programmers-still-bad]
Anyways, usually I’d write it, say in JavaScript: { state_a: function(c) { if(c === ':') { return state_b; } return state_a; }, state_b: function(c) { if(c !== ' ') { return state_b(c); } }.
New acronym: DUCkS.
01:34
If that makes any sense whatsoever.
Is it worth it to do that in C?
user142019
@minitech And in C, the equivalent is through function pointers.
@minitech In C++ you could write similar code with lambdas.
user142019
Or blocks if you like clang's language extensions.
Should I, though? It’s possible using switch.
user142019
You can write a switch that calls functions.
01:36
Huge mess of case versus huge mess of global functions.
room topic changed to Lounge<C++>: Don't Use C Stupid. DUCS. Pronounced like "ducks". [c++] [c++11] [c++-faq] [no-helpdesk] [programmers-still-bad]
BEST IDEA I'VE HAD THIS MONTH
is it just me, or does everything using twitter bootstrap look super generic now?
Why am I doing this again?
And you can use it for C++, too!
user142019
And C#. :(
01:37
@Crowz It’s not just you and it’s not just now
@CatPlusPlus what do you mean?
Bootstrap is a framework with a default look&feel, which many people (including me) don't bother to change.
user142019
A. H.? Adolf Hitler?
Because seriously, can't be arsed.
01:37
@minitech I've been trying to make a decently unique looking webpage for probably 3 hours now, they all look the same
lol
Address space layout randomization (ASLR) is a computer security method which involves randomly arranging the positions of key data areas, usually including the base of the executable and position of libraries, heap, and stack, in a process's address space. Benefits Address space randomization hinders some types of security attacks by making it more difficult for an attacker to predict target addresses. For example, attackers trying to execute return-to-libc attacks must locate the code to be executed, while other attackers trying to execute shellcode injected on the stack have to fin...
I cannot decide between leaving my clouds broken but ok looking, or fixing it...
@minitech I laughed a little too hard at that
user142019
01:39
@minitech The tweet button is the only thing that looks sensible.
@Pawnguy7 if they look ok they are not completely broken. Rule #23 states: Never fix things before they are completely broken.
But seriously, fuck C.
Don't use it.
user142019
Yes we know C is terrible now shut up about it and let him use C if he likes to use C.
yes, write in assembly instead >_<
@minitech Welcome back to the 90s!
01:40
Who are you and what did you do with Zoidberg
hey people still use C to write drivers
@minitech Btw, mutual recursion? Neat.
Hey people are still bad at programming.
It's even in tags.
I'm bad at programming
@StackedCrooked Well, it’s not actually recursing.
user142019
01:41
This industry is too young for anyone to be able to be a good programmer.
Ooh.
I think I found it.
@CatPlusPlus Well, I would love to write this in Python.
But I’m doing the whole thing for no reason
So
user142019
import http_server # Done!
So that's still not a reason to use C.
You're part of the problem man
@minitech Usually you want to make most of it table driven. A rectangular matrix with one column for each input character and one row for each state. For each of those you have a next state and (possibly) an action to take. Read a character, carry out the action, and transition to the next state. And yes, if you're doing it in C, the action will probably be a pointer to a function.
01:42
@CatPlusPlus He's young :)
@JerryCoffin And using function pointers is not a horrible thing?
@minitech No.
It's the only thing you can use.
@CatPlusPlus that makes things way more complicated
@CatPlusPlus There’s always goto.
01:43
function pointers are fast if you use it correctly
user142019
goto hell;
@CatPlusPlus Not the only thing, but generally the cleanest.
goto is restricted to the function scope iirc
user142019
@CatPlusPlus Turned him into Vinyl Scratch.
hell: undefined variable
user142019
01:43
@StackedCrooked ja, of course.
user142019
inb4 longjmp
So the harm you can do with goto is restricted.
I just finished watching Supernatural. I wish we could exorcise bad languages.
Unless you put your entire program in the main function and use goto instead of functions.
01:44
That was a long time ago. Don’t blame me…
better still, exorcise the demons of stupidity
@StackedCrooked Sure. If you really insist on it (don't) you can use setjmp/longjmp to simulate cross-function gotos (don't do it).
@minitech You should split it up into small functions.
Why do Twitter bootstrap exists again?
01:46
@Jeffrey To make things boring and incompatible with some less popular browsers.
@StackedCrooked I will, now that I know function pointers are A-OK.
user142019
@minitech goto is completely fine but GTFO if you name your lables _0 and _1. :v
user142019
I mean… this isn't BASIC.
I thought it was BASIC
@Jeffrey Easier web development.
@Rapptz Easier web development is eschewing CSS in favour of… not CSS.
01:47
It's easier to just use a template rather than the vanilla css for people who can't design.
@Rapptz HTML+CSS? Isn't it easy enough?
user142019
The only component of Twitter Bootstrap that is worth using is the grid system because it's the only decent grid system available.
Yeah Bootstrap's grid system is really nice.
@rightfold Bleh, who needs grids.
Apart from serious designers.
user142019
Serious designers.
01:48
Grids make the page look nicer
how do I become eternity?
And funny designers.
user142019
@Crowz Crowz = eternity;
user142019
Fuck languages that have assignment as an expression instead of a statement.
CROWZ IS BEYOND THE VOID crowz > void
01:49
@rightfold grid system?
user142019
@rightfold you have a typo
@Crowz put you self in an infinite loop while(1) {Crowz->doThings();}
user142019
def crowz() {
   crowz()
}
user142019
01:51
Looks like a combination of Python and Perl.
@rightfold What’s wrong with that?
user142019
@minitech goto-ing a label that isn't in scope.
@rightfold But it doesn’t work.
So.
user142019
Yes, it doesn't work because the label isn't in scope.
01:52
Do you feel that it should be in scope?
fuckin'... why is amazon video still broken?
user142019
@StackedCrooked Nothing happens.
user142019
@minitech No, of course not.
@rightfold Because it needs to download megs of output. It appears after a few seconds.
user142019
You cannot jump to a label in a different function.
01:53
@rightfold Then what’s the problem?
Or am I not understanding the :(
user142019
He's just fooling around.
Whoa, @StackedCrooked, you built that?
user142019
Had to use Chrome's task manager to kill it. :D
user142019
@minitech Yes he did.
01:54
It’s lovely. :)
@rightfold main.cpp and output
@minitech Thanks :D
user142019
@StackedCrooked I wanted to FTFY but I failed. :(
@StackedCrooked Although, why the frames?
user142019
Because he sucks at web development. :P
@minitech Because with frames it's easy to make the output area resizable. Without frames it's possible with JavaScript, but it's not simple.
And I suck at web dev :)
01:59
Ah, I guess.
user142019
It is simple.
Too bad resize: vertical doesn’t work with the Ace editor, IIRC.
user142019
Ace is terrible and Coliru should switch to CodeMirror.

« first day (1002 days earlier)      last day (4172 days later) »