This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stackoverflow.com/questions/22519784/how-do-i-convert-an-existing-callback-api-to-promises | |
| // Convert from node style callback | |
| function getStuff(dat,callback){ | |
| gettStuff("dataParam",function(err,data){ | |
| // | |
| }); | |
| }; | |
| // To promise | |
| function getStuffAsync(param) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Is there a way to avoid typing the type of the object? | |
| connect(QSIGNAL(button, clicked), QSLOT(receiver, buttonClicked)); | |
| // C++11 Only | |
| #define QSIGNAL(OBJ, FUNC) OBJ, [&](){ \ | |
| typedef std::remove_reference<decltype(*(OBJ))>::type Type; \ | |
| return &Type::FUNC; }() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ objdump -D -b binary -m i8086 <file> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| #include <cstdio> | |
| int main() { | |
| int a[4]; | |
| a[0] = 3; | |
| a[1] = 2; | |
| a[2] = 1; | |
| a[3] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class A { public: A(int _a, int _b) : a(_a), b(_b){} int a; int b; }; | |
| QList<A*> tstItems; | |
| tstItems.append(new A(1,2)); | |
| tstItems.append(new A(3,4)); | |
| tstItems.append(new A(5,6)); | |
| QList<A*>::iterator tstIt = std::find_if(tstItems.begin(), tstItems.end(), [] (const A *const a) { | |
| qDebug() << "inside lambda " << a; | |
| return a->b == 4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // GOTO label inside class method, do not use in production!!! | |
| // g++ -Wno-pmf-conversions horror.cpp | |
| #ifndef HORROR_H | |
| #define HORROR_H | |
| #include <iostream> | |
| #include <cstdlib> | |
| struct Foo { |