- `-i lo` means to capture packets on the lo interface
- `-A` means to show the contents of the packets in ASCII
- `-s 0` means to show the whole packet - not to divide into the parts
- `port 8004` is a pcap expression

for ($i = 0; $i < 9; $i++) { if (true) { break blah; } echo "not shown"; blah: echo "iteration $i\n"; }They even named it as 'break'. They probably think that 'break' is not 'goto' =). But yes, they BREAK the common sane ;). Developers say: Goto is currently missing in PHP, and although there is a limited use for this construct in some cases it can reduce the amount of code a lot. I should say: It doesn't matter how many code you have. But it does matter how easy you can read and understand it.
$foo = ifsetor($_GET['foo'], 42);As for me that's nonsense. This doesn't make things easier but complicates the language. In python persists such construction for dict: dictobject.get('key', 'defvalue'). This will return 'defvalue' if no value in dict with given 'key' is associated. Besides, this is not a global function or operator. This is a method of the object and, yes, it simplifies the construction "dictobject.has_key('key') and dictobject['key'] or 'defvalue'"
function foo ($a = 42, $b = 43, $c = 44, $d = 45) { echo "$a $b $c $d\n"; } foo(c => 54, b => 53);I think there should be "foo($c = 54, $b = 53)" to keep the coding style.
template<typename T> struct __tt { typedef std::map<std::string, T> smap; };And use it:
__tt<int>::smap m;
int main(int argc, char **argv) { struct Nested { static void print() { std::cout << __func__ << std::endl; } }; Nested::print(); return 0; }Or you can apply some macros magic:
#define NESTED_FUNCTION_BEGIN(UNIQUE_NAME) \ struct UNIQUE_NAME { static #define NESTED_FUNCTION_END }; int main(int argc, char **argv) { NESTED_FUNCTION_BEGIN(Nested) void print() { std::cout << __func__ << std::endl; } NESTED_FUNCTION_END Nested::print(); return 0; }
class One { public: virtual void draw0() = 0; virtual void draw1() = 0; }; class Two: public One { public: virtual void draw0() { std::cout << __func__ << std::endl; } virtual void draw1() { std::cout << __func__ << std::endl; } };Define function that will call objects' method by their address.
template<typename T> void draw(T *b, void (T::*f)()) { (b->*f)(); }Define two lists: objects and their methods.
std::list<One *> ls; std::list<void (One::*)()> lsm;Push methods you want to call to the list of methods.
lsm.push_back(&One::draw0); lsm.push_back(&One::draw1);And push objects to the list of objects.
Two T0, T1; ls.push_back(&T0); ls.push_back(&T1);Now you can just iterate on list of objects and on list of their methods.
for (std::list<One *>::iterator i(ls.begin()), j(ls.end());i!=j;++i) for (std::list<void (One::*)()>::iterator o(lsm.begin()), p(lsm.end());o!=p;++o) draw(*i, *o);Using this example you should get
draw0 draw1 draw0 draw1at the output.
PGresult *PQexecParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char * const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat);and
PGresult *PQexec(PGconn *conn, const char *command);Yep, the difference is pretty big. PQexecParams has +6 arguments. The most interesting argument that makes SELECT request result different is resultFormat. PQexec doesn't have it. According to PostgreSQL's manual:
if resultFormat is set to zero it'll obtain results in text format, or if it is set to one it will obtain results in binary format.
Great! I want to get data in binary format. It'll be safe to get abyte(aka blob) data. Do you know what does 'obtain in binary format' mean? PosgreSQL manual hazily says:There is not currently a provision to obtain different result columns in different formats, although that is possible in the underlying protocol.
That means that in 'binary mode' abyte would be binary, numeric would be numeric(int, long, short, ...), date will be returned as long and so on. Yes, I love postgreSQL that I can obtain data in it's native form.My suggestion is to add resultFormat to PQexec