You can use the superfast esbuild instead of uglifyjs-folder and csso-cli to copy (and minify) your JavaScript and/or CSS files (without having to bundle the files) in your npm scripts.
Vector tiles with PostGIS, PHP and OpenLayers
This is an example about how to create vector tiles with PostGIS 3.3 (and PostgreSQL 15.3), serve them with PHP 8.1 and use them in OpenLayers 7.5. In contrast to the few tutorials available on the internet, it not only uses the latest PostGIS version 3.3, which further simplified the generation of vector tiles by …
Continue reading “Vector tiles with PostGIS, PHP and OpenLayers”
How to get the version of a module from its package.json
node.js < 12 VERSION=$(node -p “require(‘some-module/package.json’).version”) node.js 12+ In Node.js 12+ you can no longer get the version of a module dependency with the version property unless the path is explicitly exported in the module with: { “exports”: { “./package.json”: “./package.json” } } What you can do instead, is to use a regular expression to …
Continue reading “How to get the version of a module from its package.json”
Apache serves cached files with garbled text at end
When using Apache running on a VirtualBox machine with a shared folder, small files such as JavaScript or CSS files might not get updated from the host and served with additional characters at the end. This happens because of a bug in VirtualBox when Apache is using sendfile to improve data transfer. Just turn the …
Continue reading “Apache serves cached files with garbled text at end”
Use JSDoc 3 and PhpStorm to generate JavaScript documentation
This is an update to my former installation guide How to Generate JavaScript Documentation with JSDoc 3 and PhpStorm, which was written in 2013. Since then, JSDoc 3 moved from Mozilla’s Rhino to Node.js to generate the documentation, which is why that guide no longer works (unless you use an older version of JSDoc 3). …
Continue reading “Use JSDoc 3 and PhpStorm to generate JavaScript documentation”
PhpStorm: Complete code versus complete current statement
Here are two useful keyboard shortcuts for PhpStorm which sound similar, but are quite different: complete code CTRL + SPACE will either finish your code if what you typed so far is unambiguous or otherwise offer a list to choose from. complete current statement CTRL + SHIFT + ENTER will add a semicolon at the …
Continue reading “PhpStorm: Complete code versus complete current statement”
JavaScript tip: Shorten document.getElementById with Function.prototype.bind
I found this really nice one liner on Nick Desaulniers blog about Function.prototype.bind Edge Cases: // var byId = function(id) { return document.getElementById(id); } var byId = document.getElementById.bind(document); Love it!
How to load leaflet.js and leaflet plugins with dojo AMD
<script type=”text/javascript”> var dojoConfig = { baseUrl: ‘/lib’, async: true, packages: [ {name: ‘Leaflet’, location: ‘./Leaflet’} ], map: { // lets you switch between minified and source version of leaflet for development ‘*’: { ‘Leaflet/leaflet’: ‘Leaflet/leaflet-src’ } } }; </script> <script type=”text/javascript” src=”lib/dojo/dojo.js”></script> <script type=”text/javascript”> require([ ‘require’, ‘Leaflet/leaflet’ ], function(require, L) { // load plugin …
Continue reading “How to load leaflet.js and leaflet plugins with dojo AMD”
Boxplot renderer plugin for jqPlot
For work I needed a way to show boxplots (see diagram to the right) using the jqPlot library. All I had to do was override the draw() method of OHLCRenderer (see code below). Update 13.10.2017: Upon request I created a working demo of the BoxplotRenderer using some helper classes to setup jqPlot charts from another …
How to import c3.js with the dojo AMD loader
I came across the nice chart library c3.js, which is based on d3.js. In order to load it via an AMD require call with dojo, you also need to set the main property in the dojoConfig, e.g.: dojoConfig = { packages: [ { name: ‘d3’, location: ‘../../../d3’, main: ‘d3’ } { name: ‘c3’, location: ‘../../../c3’, …
Continue reading “How to import c3.js with the dojo AMD loader”