Number Rounding Business

Rounding numbers is probably one of the topics in primary school. In school, we’ve learned that half rounds up, anything less than half rounds down. For example, 0.5 rounds to 1, but 0.4 rounds to 1. Duh, I’m stating the obvious you think. It only came to my attention that this is NOT really the default behaviour in a very popular programming language: Python.

Here, is a simple example to try in your own Python console.

Continue reading “Number Rounding Business”

Use npm packages in QML

I’ve been trying to code up some nice GUI for a hobby project which was done in JavaScript (Node.JS). I’ve looked at a few options that I have

  1. Use the not-yet-stable NodeGUI
  2. Go Web and use Electron
  3. Rewrite the core in Python or C++ to use Qt
  4. Use QML which has limited support for JavaScript

I’ve explored the option 1, however, I soon ran into the problems with the Model/View/Delegate architecture which means I would have to implement native plugins/add-ons in order to use ListView. Not to mention the framework itself is still heavily under development.

As for option 2, I’m not a web frontend engineer and personally I much prefer something that is native (or looks and feels native at least). For the third option, it feels a bit overkill but it is a possible way out.

Luckily I don’t have to do the re-implementation, because I’ve managed to get the core functionality bundled into a single JS file which works flawlessly in the QML environment. Before I start diving into the details on how you can make your npm packages work in QML, I have to emphasise that there are many limitations in the QML environment and it’s very likely that only a small subset of the npm package that you’re interested in is going to work.

Continue reading “Use npm packages in QML”

NodeConf EU 2018與會有感

上週有幸到鄰國愛爾蘭的Kilkenny郡參加本年度的NodeConf EU大會。會場選在風景宜人的蹩腳窩郊外,離都柏林機場有一個半小時的車程,不遠,就是estate都不在鎮上,所以每天倒也只能全身心灌注在大會和組織者安排的夜間活動上,倒也是個結交新朋好友的機會。

Continue reading “NodeConf EU 2018與會有感”