Skip to content

Instantly share code, notes, and snippets.

View nitaku's full-sized avatar

Matteo Abrate nitaku

  • Pisa, Italy
View GitHub Profile
nitaku /
Last active May 12, 2024 22:24
Minimal JSON HTTP server in python

A minimal HTTP server in python. It sends a JSON Hello World for GET requests, and echoes back JSON for POST requests.

python 8009
Starting httpd on port 8009...
curl http://localhost:8009
{"received": "ok", "hello": "world"}
nitaku /
Last active May 10, 2024 22:47

A map of the sky that uses an azimuthal equidistant projection with star data. Longitudes and latitudes for the geo projection are obtained from declination and right ascension respectively (longitude is also inverted, because, unlike the earth globe, the celestial sphere is seen from the inside).

The boreal (northern) sky is shown at left, while the austral (southern) at right. Because right ascension is given in hours, both maps are divided in 24 slices. A circle is shown every 10 degrees of declination.

Star size indicates magnitude. Bigger circles depict brighter stars.

nitaku /
Last active April 23, 2024 09:25
Leaflet with ESRI satellite tiles

An example that shows an ESRI's satellite layer with Leaflet.js. A lot of different tile services are compatible with Leaflet: click here for a list with live previews.

nitaku /
Last active October 18, 2023 12:17
Three.js isometric camera
nitaku /
Last active September 17, 2023 11:05
Boolean operations on 2D shapes

This example shows the results (orange) of performing four different boolean operations (union, difference, xor and intersection) on two 2D shapes (blue). Thanks to the powerful clipper.js library, the computation is performed in client-side Javascript.

The example is almost entirely taken from this clipper.js demo.

nitaku /
Last active July 27, 2023 11:54
Fuzzy graph

A visualization experiment for displaying fuzzy graphs (Rosenfeld 1975, in Fuzzy Sets and Their Applications to Cognitive and Decision Processes, page 77). Each node has a degree of membership to the set of graph nodes, encoded with its area (in red). The maximum degree of membership (i.e., 1) is represented as a gray circle of unit area. Links have a degree as well, linearly encoded with their thickness (dark gray). The maximum degree for links is limited by the minimum value between the degrees of the nodes it connnects, and is represented with a light gray line, while the unconstrained maximum degree (i.e., 1) is shown as a dotted, empty line.

nitaku /
Last active June 25, 2023 19:14
Hilbert spiral (L-system)

A Lindenmayer system that draws a sequence of growing Hilbert curves following a spiral layout.

Like in the previous experiment, a repetition rule is added to the Hilbert rules (A and B) to obtain the sequence. In order to produce the spiral layout, the rule contains some turns and different repetitions of the Hilbert rules A and B.

The objective is to find a layout that starts from a central point and grows spiraling away from it. The layout is intended to be used for creating a jigsaw treemap, so a naive spiral layout (like this one) is out of the question because of the elongated regions it would produce.

By leveraging the locality properties of the Hilbert curve, the layout presented in this example should somehow manage to both spiral away from a central point and have regions with good as

nitaku /
Last active June 17, 2023 08:24
Multidimensional Scaling

An example of Multidimensional Scaling (almost completely taken from this article by Ben Frederickson).

A matrix of distances between cities is fed into a simple javascript function (again, by Ben Frederickson) that uses numeric.js to compute the cities' position. Rotation and mirroring (manually adjusted in this example) are free.

Click on a city to see an indication of the distance errors.

nitaku /
Last active May 23, 2023 06:44
Isometric treemap (flare)

A first attempt at making a real isometric treemap. Unlike previous attempts, this experiment uses the treemap layout to actually represent a tree (in this example, the flare package hierarchy).

Treemaps are very good to show hierarchies in a compact way, and excel in the case of attributed hierarchies with a quantitative attribute (a classical example would be a file system hierarchy, in which size is given by the number of bytes of each file). However, they are not very good in representing internal nodes, parent-child relations and depth.

Nested treemaps introduce some padding between a parent and its children to better represent this aspect, losing accuracy in area encoding. Despite this improvement, hierarchy depth is still not represented.

An isometric treemap loses some clarity and compactness to introduce an intuitive representation of de

nitaku /
Last active May 8, 2023 17:59
Three.js isometric SVG

An example showing an isometric rendering in SVG, thanks to three.js.

The example is inspired by this post on using three.js to generate illustrations for scientific papers.