@sehe I managed to serialize an object to the database and back again by mashing together the boost::serialization example (with bust stops and such) and some of the mongo db doc, and an SO answer on how to use boost::iostreams to create an in memory stream. MongoDB has a binary blob type so I stream it into a vector and then point the binary type to the vector's contents.
Should x-platform issues arise I'll look into that library you mention in your answer :)
Well I found this first (first link when googling: c++ serialize mongodb), which points to this other one of yours, but after looking at the API for MongoDB, it turns out that I can get away with this
@sehe As I mentioned above, I found this code in a SO answer, I've no experience with boost::iostream. The only difference is I replaced std::string with std::vector<char> as to not imply that what I'm serializing is text.
macbook:~ tao$ cat test.c
int main(){printf("%d\n", (int)sizeof(int));}
macbook:~ tao$ gcc test.c
test.c:1:12: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)'
int main(){printf("%d\n", (int)sizeof(int));}
^
test.c:1:12: note: please include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
macbook:~ tao$ ./a.out
4
macbook:~ tao$
In C, the type of a character constant like 'a' is actually an int, with size of 4 (or some other implementation-dependent value). In C++, the type is char, with size of 1. This is one of many small differences between the two languages.
macbook:~ tao$ cat test.c
int main(){printf("%d\n", (int)sizeof(char));}
macbook:~ tao$ gcc test.c
test.c:1:12: warning: implicitly declaring library function 'printf' with type 'int (const char *, ...)'
int main(){printf("%d\n", (int)sizeof(char));}
^
test.c:1:12: note: please include the header <stdio.h> or explicitly provide a declaration for 'printf'
1 warning generated.
macbook:~ tao$ ./a.out
1
macbook:~ tao$
In C, the type of a character constant like 'a' is actually an int, with size of 4 (or some other implementation-dependent value). In C++, the type is char, with size of 1. This is one of many small differences between the two languages.
In C, the type of a character constant like 'a' is actually an int, with size of 4 (or some other implementation-dependent value). In C++, the type is char, with size of 1. This is one of many small differences between the two languages.
I find that the best way to debug TCP issues is to simply log everything all the time. I've been thinking of using a circular buffer to log the events. Once the buffer is full want to "thin" the data by deleting every other entry. Once the buffer is full again this is repeated. Gradual thinning of old data. I wonder if there's some funky data structure exists that would make this easy.
@Xeo I'm back a bit early from the con today since they didn't have any good late night stuff. I picked up a couple of the "small and expensive" wall scrolls. The quality certainly justifies the price difference.
The knots are a lot smaller than in the big wall scrolls.
@Shoe C syntax is so terrible... I am implementing typedef right now, and you can't parse C without a symbol table, because otherwise you don't know whether a * b; is a multiplication or a pointer declaration.
Until now there was a clean separation between syntax analysis and semantic analysis. Now it's all mixed up :(
@sehe I know, I read it. How to trick people into adding stuff to their habit list, etc. How to give that "rewarding" feeling. People have been talking about this and describing it for a loong time now. Back when it was just "refresh your email page" and "connect to MSN first day in the morning"
I can even add to that. "When we walk on the street, it's a slot machine to know what the next stranger looks like. When you hop on the train, it's a slot machine to know if there are empty seats or not"
Maybe I feel especially annoyed because I'm barely out of the "teenager" category and I've had facebook for <1y, I never spam refresh email or anything else, I post as little as possible, I don't give a single fuck about approval from whoeverelse (and facial recognition is off in the EU). Fuck all that.
@Ven You clearly missed the point there, anyway. The characteristics of a slot machine meaningful for the analogy are not the randomness, but the reward patterns.
There's a low-cost action to perform, and there are rewards for performing it.
@nwp Unless it's trivial, pretty soon you'll end up shoving a coroutine inside an iterator.
I want to iterate over files in a directory and recursively over directories in that directory. Can be done with simple recursion, but I want to keep the do_stuff_with_file-logic separate from iterating over the directories. Passing a lambda is ugly, yield(filename) + iterating seemed elegant.