Blog List



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


Genetic algorithm part 1: basic

Content page Part 1: Basic Genetic algorithm Part 2: Getting sample price data & ta-lib for node.js Part 3: Preparing important indexes/values Part 4: Portfolio selection; Target: outperform the market by 15%; not good enough Part 5: Evolution Strategy Part 6: Building Classifiers, buy, sell or hold? Part 7: to be announced note: I may revise content



Qt:Parsing a nested JSON

QJsonDocument doc; doc = QJsonDocument::fromJson(“{ ” ” \”city\”: \”London\”, ” ” \”time\”: \”16:42\”, ” ” \”unit_data\”: ” ” [ ” ” { ” ” \”unit_data_id\”: \”ABC123\”, ” ” \”unit_data_number\”: \”21\” ” ” }, ” ” { ” ” \”unit_data_id\”: \”DEF456\”, ” ” \”unit_data_number\”: \”12\” ” ” } ” ” ] ” ” }”); // This


Qt – Menu Bar with QMainWindow

Menu demo code Main.h #ifndef _MAINWINDOW_H #define _MAINWINDOW_H #include “ui_MainWindow.h” #include “Agents.h” class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(); virtual ~MainWindow(); private: Ui::MainWindow widget; Agents *agents; private slots: // functions void InitClass(); void InitConnect(); void FormClose(); void Agents(); }; #endif /* _MAINWINDOW_H */   Main.cpp #include “MainWindow.h” MainWindow::MainWindow() { widget.setupUi(this); InitClass(); InitConnect(); }


Creating Carthage for your iOS project

What is Carthage It is dependency package manager for iOS development and it is not intrusive like Cocoapod. Installation brew carthage How to create a Cartfile? To go the root of your project, create a file called Cartfile. github “Realm/realm-cocoa” == 3.2 github “SwiftyJSON/SwiftyJSON” ~> 4.0 Format origin UserName/Project ~> dependencyVersion == 1.0 means “Use exactly


iOS Tutorials

Creating iOS Framework and use Cocoapods for distribution https://www.raywenderlich.com/126365/ios-frameworks-tutorial Set up Carthage for distribution https://www.raywenderlich.com/165660/carthage-tutorial-getting-started-2


Qt 4.8.x and Netbean 8.x on windows 10 with MinGW

It has been a while and no one really write this post. Netbeans 8.x https://netbeans.org/downloads/ Msys http://www.msys2.org/ MinGW https://sourceforge.net/projects/mingw/ Qt open-source x86 MinGW 4.8.7 for Windows https://download.qt.io/official_releases/qt/4.8/4.8.7/ qt-opensource-windows-x86-mingw482-4.8.7.exe   Qt open-source x86 MinGW 5.10.1 for Windows https://download.qt.io/archive/qt/5.10/5.10.1/single/   Environmental Path Add C:\Mingw\bin and [qt installation root]/bin to your Windows environment Path   Including Runtime Library Copy the stdc++ file


React.js – Central State Control: React-Redux

Content Page Installation Basic Introduction – Kickstarter Sonic boom your UI with Bootstrap 4 – Reactstrap Passing data with Props / State and lifecycle Navigation with React-Router Debugging Tool with React Development Tool Central State Control: Redux Hands-on time Calculated Data with Reselect Making a form with ReduxForm Refs GraphQL Get a serious in-depth book


React.js – Navigation with React-Router

Content Page Installation Basic Introduction – Kickstarter Sonic boom your UI with Bootstrap 4 – Reactstrap Passing data with Props / State and lifecycle Navigation with React-Router Debugging Tool with React Development Tool Central State Control: Redux Hands-on time Calculated Data with Reselect Making form with ReduxForm Get a serious in-depth book Annex A: JSX


Annex B: React.js – PropTypes

These are the PropsTypes that you can check for input.   React.PropTypes.array // array React.PropTypes.bool.isRequired // Boolean and is required。 React.PropTypes.func // function React.PropTypes.number // number React.PropTypes.object // object React.PropTypes.string // string React.PropTypes.node // any of these types : numbers, strings, elements or array of these types React.PropTypes.element // React element React.PropTypes.instanceOf(XXX) // intance of