Month: April 2018


Javascript Node.js code snippet

Javascript map iteration myMap.forEach(function(value, key) { console.log(key + ‘ = ‘ + value); }); Async.waterfall parameter injection async.waterfall( [ async.apply(authFunction, this), //authFunction, firstFunction, secondFunction, thirdFunction ], function (err, result) { if (err) _cb(err); _cb(null, result); }); assign MySQL’s Datetime using javascript before executing SQL data.insert_date = new Date(); Async.mapLimit execution using all CPUs var cpus


Qt: post and get example

QNetworkAccessManager *manager = new QNetworkAccessManager(this); QUrl url(“https://accounts.google.com/o/oauth2/token”); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, “application/x-www-form-urlencoded”); QUrl params; params.addQueryItem(“client_id”, “…”); params.addQueryItem(“client_secret”, “…”); params.addQueryItem(“code”, “…”); // etc QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(replyFinished(QNetworkReply *))); manager->post(request, params.encodedQuery());   In Detail You need three things. QNetworkAccessManager * manager; -> To send us a request. QNetworkRequest request; -> what type of demand? get, post, …


C++ future async for parallel computing

This pose is related to another article of mine about using lambda and callback. You can use both techniques together to achieve greater performance gain. Because there are a lot web url around and if you happen that you need to obtain data from there, then you may spend lots of time waiting instead of let