Fighting game Updated 2025-07-16
graphviz/node.dot Updated 2025-07-16
graphviz/quotes.dot Updated 2025-07-16
js/matterjs/hello.html Updated 2025-07-16
Hello world adapted from: github.com/liabru/matter-js/wiki/Getting-started/1d138998f05766dc4de0e44ae2e35d03121bb7f2
Also asked at: stackoverflow.com/questions/28079138/how-to-make-minimal-example-of-matter-js-work/76203103#76203103
Renderer questions:
- follow object on viewport: codepen.io/csims314/pen/goZQvG
- draw text: github.com/liabru/matter-js/issues/321
File manager Updated 2025-07-16
Ciro Santilli used to use file managers in the past.
But he finally converted to a shell
cd
aliases that auto-ls
: github.com/cirosantilli/dotfiles/blob/a51bcc324f0cff0eddd4c3bb8654ec223a0adb7b/home/.bashrc#L1058 nodejs/read_child_process_lines.js Updated 2025-07-16
nodejs/sequelize/parallel_select_and_update.js Updated 2025-07-16
This example is the same as nodejs/sequelize/raw/parallel_select_and_update.js, but going through Sequelize rather than with Sequelize raw queries.
NONE
is not supported for now to not have a transaction at all because lazy.The examples illustrates: stackoverflow.com/questions/55452441/for-share-and-for-update-statements-in-sequelize
Sample invocation:where:
node --unhandled-rejections=strict ./parallel_select_and_update.js p 10 100 READ_COMMITTED UPDATE
READ_COMMITTED
: one of the keys documented at: sequelize.org/master/class/lib/transaction.js~Transaction.html which correspond to the standard sQL isolation levels. It not given, don't set one, defaulting to the database's/sequelize's default level.UPDATE
: one of the keys documented at: sequelize.org/master/class/lib/transaction.js~Transaction.html#static-get-LOCK. Update generates aSELECT FOR UPDATE
in PostgreSQL for example. If not given, don't use anyFOR xxx
explicit locking.
Other examples:
node --unhandled-rejections=strict ./parallel_select_and_update.js p 10 100 READ_COMMITTED UPDATE
Then, the outcome is exactly as described at: nodejs/sequelize/raw/parallel_select_and_update.js:
READ_COMMITTED
: failsREAD_COMMITTED UPDATE
: works- This case also illustrates Sequelize transaction retries, since in this transaction isolation level transactions may fail:
nodejs/sequelize/raw/parallel_select_and_update_deterministic.js Updated 2025-07-16
This example contains a deterministic demo of when postgreSQL serialization failures may happen.
Tested on PostgreSQL 13.5.
nodejs/sequelize/raw/parallel_select_and_update.js Updated 2025-07-16
This example is similar to nodejs/sequelize/raw/parallel_update_async.js, but now we are doing a separate SELECT, later followed by an update:
Although this specific example is useless in itself, as we could just use
UPDATE "MyInt" SET i = i + 1
as in nodejs/sequelize/raw/parallel_update_async.js, which automatically solves any concurrency issue, this kind of code could be required for example if the update was a complex function not suitably implemented in SQL, or if the update depends on some external data source.Sample execution:which does:
node --unhandled-rejections=strict ./parallel_select_and_update.js p 2 10 'READ COMMITTED'
- PostgreSQL, see other databases options at SQL example
- 2 threads
- 10 increments on each thread
Another one:this will run SELECT FOR UPDATE rather than just SELECT
node --unhandled-rejections=strict ./parallel_select_and_update.js p 2 10 'READ COMMITTED' 'FOR UPDATE'
Observed behaviour under different SQL transaction isolation levels:
READ COMMITTED
: fails. Nothing in this case prevents:REPEATABLE READ
: works. the manual mentions that if multiple concurrent updates would happen, only the first commit succeeds, and the following ones fail and rollback and retry, therefore preventing the loss of an update.READ COMMITTED
+SELECT FOR UPDATE
: works. And does not do rollbacks, which probably makes it faster. Withp 10 100
,REPEATABLE READ
was about 4.2s andREAD COMMITTED
+SELECT FOR UPDATE
3.2s on Lenovo ThinkPad P51 (2017).SELECT FOR UPDATE
should be enough as mentioned at: www.postgresql.org/docs/13/explicit-locking.html#LOCKING-ROWSFOR UPDATE causes the rows retrieved by the SELECT statement to be locked as though for update. This prevents them from being locked, modified or deleted by other transactions until the current transaction ends. That is, other transactions that attempt UPDATE, DELETE, SELECT FOR UPDATE, SELECT FOR NO KEY UPDATE, SELECT FOR SHARE or SELECT FOR KEY SHARE of these rows will be blocked until the current transaction ends; conversely, SELECT FOR UPDATE will wait for a concurrent transaction that has run any of those commands on the same row, and will then lock and return the updated row (or no row, if the row was deleted). Within a REPEATABLE READ or SERIALIZABLE transaction, however, an error will be thrown if a row to be locked has changed since the transaction started. For further discussion see Section 13.4.
A non-raw version of this example can be seen at: nodejs/sequelize/parallel_select_and_update.js.
Gibbs free energy Updated 2025-07-16
At least from the formula we see that:
- the more exothermic, the more likely it is to occur
- if the entropy increases, the higher the temperature, the more likely it is to occur
- otherwise, the lower the temperature the more likely it is to occur
A prototypical example of reaction that is exothermic but does not happen at any temperature is combustion.
Lab 7 - Gibbs Free Energy by MJ Billman (2020)
Source. Shows the shift of equilibrium due to temperature change with a color change in a HCl CoCl reaction. Unfortunately there are no conclusions because its student's homework. nodejs/sequelize/raw/trigger_count.js Updated 2025-07-16
numpy/fft.py Updated 2025-07-16
Output:With our understanding of the discrete Fourier transform we see clearly that:
sin(t)
fft
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10
rfft
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0
sin(t) + sin(4t)
fft
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0 0 0 0 0 0 10 0 0 10
rfft
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0
- the signal is being decomposed into sinusoidal components
- because we are doing the Discrete Fourier transform of a real signal, for the
fft
, so there is redundancy in the. We also understand thatrfft
simply cuts off and only keeps half of the coefficients
python/getitem_complex.py Updated 2025-07-16
python/pytorch/matmul.py Updated 2025-07-16
Matrix multiplication example.
Fundamental since deep learning is mostly matrix multiplication.
python/sphinx Updated 2025-07-16
To run each example and see the output run:
./build.sh
xdg-open out/index.html
python/sphinx/class Updated 2025-07-16
Basic class example.
python/sphinx/union Updated 2025-07-16
react/ref-click-counter.html Updated 2025-07-16
Dummy example of using a React
ref
This example is useless and to the end user seems functionally equivalent to react/hello.html.It does however serve as a good example of what react does that is useful: it provides a "clear" separation between state and render code (which becomes once again much less clear in React function components.
Notably, this example is insane because at:we are extracing state from some random HTML string rather than having a clean JavaScript variable containing that value.
<button onClick={() => {
elem.innerHTML = (parseInt(elem.innerHTML) + 1).toString()
In this case we managed to get away with it, but this is in general not easy/possible.
riscv/timer.S Updated 2025-07-16
TODO: the interrupt is firing only once:
Adapted from: danielmangum.com/posts/risc-v-bytes-timer-interrupts/
Tested on Ubuntu 23.10:Then on shell 1:and on shell 2:GDB should break infinitel many times on
sudo apt install binutils-riscv64-unknown-elf qemu-system-misc gdb-multiarch
cd riscv
make
qemu-system-riscv64 -machine virt -cpu rv64 -smp 1 -s -S -nographic -bios none -kernel timer.elf
gdb-multiarch timer.elf -nh -ex "target remote :1234" -ex 'display /i $pc' -ex 'break *mtrap' -ex 'display *0x2004000' -ex 'display *0x200BFF8'
mtrap
as interrupts happen. test_executables.js Updated 2025-07-16
Ciro Santilli has been writing scripts of that type for a long time in order to test his programming self-learning setups with asserts.
The most advanced of those being the test system of Linux Kernel Module Cheat.
There are unlisted articles, also show them or only show them.