SQL window RANGE Updated 2025-07-16
rm -f tmp.sqlite
sqlite3 tmp.sqlite "create table t (id integer, val integer)"
sqlite3 tmp.sqlite <<EOF
insert into t values
  (0, 0),
  (1, 5),
  (2, 10),
  (3, 14),
  (4, 15),
  (5, 16),
  (6, 20),
  (7, 25),
  (8, 29),
  (9, 30),
  (10, 30),
  (11, 31),
  (12, 35),
  (13, 40)
EOF
Show how many neighbours each column has with val between val - 2 and val + 2 inclusive:
sqlite3 tmp.sqlite <<EOF
SELECT id, val, COUNT(*) OVER (
  ORDER BY val RANGE BETWEEN 2 PRECEDING AND 2 FOLLOWING
) FROM t;
EOF
Output:
0|0|1
1|5|1
2|10|1
3|14|3
4|15|3
5|16|3
6|20|1
7|25|1
8|29|4
9|30|4
10|30|4
11|31|4
12|35|1
13|40|1
val - 1 and val + 1 inclusive instead:
sqlite3 tmp.sqlite <<EOF
SELECT id, val, COUNT(*) OVER (
  ORDER BY val RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
) FROM t;
EOF
Output:
0|0|1
1|5|1
2|10|1
3|14|2
4|15|3
5|16|2
6|20|1
7|25|1
8|29|3
9|30|4
10|30|4
11|31|3
12|35|1
13|40|1
There seems to be no analogue to HAVING for window functions, so we can just settle for a subquery for once, e.g.:
sqlite3 tmp.sqlite <<EOF
SELECT * FROM (
  SELECT id, val, COUNT(*) OVER (
    ORDER BY val RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING
  ) as c FROM t
) WHERE c > 2
EOF
which outputs:
4|15|3
8|29|3
9|30|4
10|30|4
11|31|3
The best articles by Ciro Santilli Updated 2025-07-16
These are the best articles ever authored by Ciro Santilli, most of them in the format of Stack Overflow answers.
Ciro posts update about new articles on his Twitter accounts.
A chronological list of all articles is also kept at: Section "Updates".
Some random generally less technical in-tree essays will be present at: Section "Essays by Ciro Santilli".
Microwave Updated 2025-07-16
Micro means "small wavelength compared to radio waves", not micron-sized.
Microwave production and detection is incredibly important in many modern applications:
Calculus of variations Updated 2025-07-16
Calculus of variations is the field that searches for maxima and minima of Functionals, rather than the more elementary case of functions from to .
SMEG, cannot determine exact model.
2020-11: started sparking by itself once every 5 minutes. Knob controls dirty in hole, but can't find out how to access. Seems slightly glued insulated around edges.
£112.99
Buying October 2023 as an immediate backup phone after the Google Pixel 3a (2020) touchscreen died, and Motorola Moto G6 Play (2018) wouldn't connect to giffgaff.
Still working checks: May 2024.
Minetest Updated 2025-07-16
github.com/minetest/minetest Written in C++, which is, a plus.
Good Minecraft clone. On Ubuntu 21.10 did:
sudo snap install minetest
which installed 5.4.1, and it worked, except it had no sound, to an error:
ERROR[Main]: Audio: Global Initialization: Failed to open device
Ciro's Edict #5 / Misc OurBigBook.com Updated 2025-07-16
Some smart people just brought up to my attention that OurBigBook.com is a bit like: roamresearch.com/ and other graph knowledges. I feel ashemed for not having seen this software and its alternatives before. I was so focused on the "book aspect" of it that I didn't search much in there. I couldn't find an immediate project killer superset from the options in that area, but maybe one exists. We'll see.
Ubuntu 23.04 Updated 2025-07-16
Uranium Updated 2025-07-16
Complex analysis Updated 2025-07-16
The surprising thing is that a bunch of results are simpler in complex analysis!
User mode emulation Updated 2025-07-16
User mode emulation refers to the ability of certain emulators to emulate userland code running on top of a specific operating system, usually Linux.
For example, QEMU allows you to run a variety of userland ELF programs directly on it, without an underlying Linux kernel running.
User mode emulation is achieved by implementing system calls and special filesystems such as /dev manually on the emulator one by one.
The general tradeoff is that simulation is less acurate as it may lack certain highly advanced kernel functionality you haven't implemented yet. But it is much easier to run executables with it, and you don't have to wait for boot to finish before running, you just run executables directly from the command line.

Unlisted articles are being shown, click here to show only listed articles.