Inaccurate rounding with decimal digits

I made a small post about Inexact rounding up or down with decimal digits. But it is also possible to run into the same bug when rounding floating point numbers to the next number with restricted decimal digits. A really common example is the price calculation. You have the price 1.99 for example and the tax is maybe 19%. The resulting price with tax would be 2.3681. So you will need to round the price with two decimal digits to 2.37.

Continue reading ...

Responsive embedded D3 SVG

The most D3 examples that I can find are not responsive embedded SVG. I guess the main reason for that is not to confuse the reader of a tutorial with stuff outside of D3. With the help of How to Scale SVG from Amelia Bellamy-Royds I would like to show on a minimal D3 example how to make the resulting SVG responsive.

Continue reading ...

Inexact rounding up or down with decimal digits

Calculations with floating point numbers are often producing small hidden bugs in some programming languages. For example rounding down or up with decimal digits. I want to show on some small examples in Java, JavaScript, Python and C the main problem.

Continue reading ...

MathJax - Mathematical expressions via JavaScript

MathJax is a JavaScript engine to display mathematical expressions in web browsers. I would have needed in it some posts before on my blog, but I have never tried. Today I would like to show how easy I have integrated in my blog.

Continue reading ...

CSS conflict between Bootstrap 4 and Prism

Bootstrap 4.0.0-alpha.5 is styling the class .tag and this leads to a CSS conflict with the Prism syntax highlighter. Here my fix to solve this conflict.

Continue reading ...

Upgrade from Bootstrap version 3 to 4

Bootstrap 4.0.0 seems to be released soon. My small blog is mostly based on plain Bootstrap with a few color changes. I will try to upgrade from Bootstrap 3.3.6 to version v4.0.0-alpha.5. This post will just document the changes that I have noticed while upgrading.

Continue reading ...

QUnit with Grunt - A minimal JavaScript unittest example

Writing testable JavaScript code is in my eyes sometimes more complex as writing testable code in other programming languages. JavaScript has it roots in the web development and the normal environment for JavaScript code was the web browser. There was always the global document object. Node.js has changed this assumption.

Continue reading ...

ImageMagick - Resize all images in a directory

I need to resize all images in a directory. The convert command from ImageMagick combined with a loop over all image files in a directory seems to be a good solution.

Continue reading ...

Magento 2 email template layout directives

Instead of just including a block into an email template, Magento makes it possible to load a hole tree of blocks or just in other words a layout. Here a small post about the the layout directive in Magento 2 email templates with source code examples from Magento.

Continue reading ...

Linux - Bluetooth version of connected devices

I had the dream to connect a Wii Remote controller with my web browser. The possibilities are infinite, playing games in the browser for example. Luckily Wii Remote controllers are using Bluetooth for the connection and there is already a group of developers on a possibility to connect Bluetooth devices with the Chrome web browser. With the help of How to get Chrome Web Bluetooth working on Linux from Alan C. Assis I was just one step away from reading the acceleration data of the controller via JavaScript, but unfortunately Web Bluetooth needs Bluetooth 4.0 or above. So this post is just about detecting the Bluetooth version of device with Linux.

Continue reading ...

Newer Older