1
0
Fork 0

bulk: changing experiments structure and how i use it.

This commit is contained in:
Strix 2025-06-27 16:23:34 +02:00
parent 20d4c9d3b7
commit 521c5b0063
20 changed files with 802 additions and 0 deletions

1
machine/even-odd/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
isEven.bin

View file

@ -0,0 +1,29 @@
import struct
import time
bitWidth = 32
startTime = time.time()
with open('isEven.bin', 'wb') as file:
file.write(b"\x31\xC0") # XOR EAX, EAX
for i in range(2**bitWidth):
print(f"[{round(time.time() - startTime, 1)}s elapsed] status: {i}/{2**bitWidth} ({2**bitWidth - i} left) ", end='\r')
ib = struct.pack("<I", i) # Encode i as 32 bit little endian integer
file.write(b"\x81\xF9" + ib) # CMP ECX, i
if i%2 == 0:
file.write(b"\x75\x03") # JNE +3
file.write(b"\xFF\xC0") # INC EAX
file.write(b"\xC3") # RET
else:
file.write(b"\x75\x01") # JNE +1
file.write(b"\xC3") # RET
file.write(b"\xC3") # Fallback RET
print()
print(f"took: {round(time.time() - startTime, 8)}s")

2
machine/even-odd/ref.md Normal file
View file

@ -0,0 +1,2 @@
This idea is from this deranged post:
https://andreasjhkarlsson.github.io//jekyll/update/2023/12/27/4-billion-if-statements.html

115
machine/finmgrsql/ddl.sql Normal file
View file

@ -0,0 +1,115 @@
-- Drop table
-- DROP TABLE finance.expenses;
CREATE TABLE finance.expenses (
expense_id bigserial NOT NULL,
"target" varchar(128) NOT NULL,
price int8 DEFAULT 0 NULL,
"interval" int4 DEFAULT 30 NULL,
active bool DEFAULT true NOT NULL,
amount int4 DEFAULT 1 NULL,
CONSTRAINT expenses_pkey PRIMARY KEY (expense_id)
);
-- Drop table
-- DROP TABLE finance.incidents;
CREATE TABLE finance.incidents (
incident_id bigserial NOT NULL,
"target" varchar NULL,
amount int8 NULL,
value_date date NULL,
created_on timestamp DEFAULT now() NULL,
CONSTRAINT incidents_pk PRIMARY KEY (incident_id)
);
-- Drop table
-- DROP TABLE finance.income;
CREATE TABLE finance.income (
income_id serial4 NOT NULL,
"source" varchar(64) NULL,
amount int8 NULL,
"interval" int4 DEFAULT 31 NULL,
active bool DEFAULT true NULL,
CONSTRAINT income_pkey PRIMARY KEY (income_id)
);
CREATE OR REPLACE VIEW finance.daily_overview
AS SELECT name,
type,
id,
amount
FROM ( SELECT e.target AS name,
'expenses'::text AS type,
e.expense_id AS id,
- (e.price * e.amount / e."interval") AS amount
FROM finance.expenses e
UNION ALL
SELECT i.source AS name,
'income'::text AS type,
i.income_id AS id,
i.amount / i."interval" AS amount
FROM finance.income i
UNION ALL
SELECT i.target AS name,
'incident'::text AS type,
i.incident_id AS id,
i.amount / (i.value_date - i.created_on::date) AS amount
FROM finance.incidents i) unnamed_subquery;
-- DROP FUNCTION finance.transaction_log(date, int4);
CREATE OR REPLACE FUNCTION finance.transaction_log(from_date date DEFAULT now(), day_range integer DEFAULT 30)
RETURNS TABLE(date date, type text, id bigint, target text, amount bigint)
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN QUERY
WITH date_range AS (
SELECT generate_series(from_date, from_date + day_range, INTERVAL '1 day')::date AS day
),
recurring_expenses AS (
SELECT
d.day AS date,
'expenses' AS type,
e.expense_id AS id,
e.target::TEXT AS target,
-(e.price * e.amount) AS amount
FROM finance.expenses e
JOIN date_range d ON e.active
AND MOD((d.day - DATE '2024-04-01')::int, e.interval) = 0
),
recurring_income AS (
SELECT
d.day AS date,
'income' AS type,
i.income_id AS id,
i.source::TEXT AS target,
i.amount AS amount
FROM finance.income i
JOIN date_range d ON i.active
AND MOD((d.day - DATE '2024-04-01')::int, i.interval) = 0
),
incident_txns AS (
SELECT
i.value_date AS date,
'incidents' AS type,
i.incident_id AS id,
i.target::TEXT AS target,
i.amount
FROM finance.incidents i
WHERE i.value_date BETWEEN from_date AND from_date + day_range
)
SELECT * FROM recurring_expenses
UNION ALL
SELECT * FROM recurring_income
UNION ALL
SELECT * FROM incident_txns
ORDER BY date, type;
END;
$function$
;

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<style>
.h {
display: flex;
}
.mm {
height: 10mm;
width: 1mm;
}
body div *:nth-child(2n) {
background: red;
}
body div * {
background: black;
}
</style>
</head>
<body>
<div class="h" id="mm">
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
<div class="mm"></div>
</div>
<div data-html-copy="#h"></div>
</body>
</html>

1
machine/outro/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
outro.webm

1
machine/outro/NOTICE.txt Normal file
View file

@ -0,0 +1 @@
Any video material used is not in any way owned by the repository owner.

View file

@ -0,0 +1,44 @@
#!/bin/sh
echo "preparing..."
sudo whoami >/dev/null
if ! [ -f "outro.webm" ]; then
yt-dlp \
"https://www.youtube.com/watch?v=3_-a9nVZYjk" \
--format 251 \
-o outro.webm
fi
echo "To cancel, Ctrl-C now..."
sleep 5
endtxt() {
sleep 6
echo "It's been a pleasure..."
sleep 4
echo "and i hate to do this..."
sleep 5
echo "but i got to go..."
sleep 10
echo "I just want to thank..."
sleep 5
echo "My processor, for processing this..."
sleep 3
echo "My ram for not forgetting me!"
sleep 3
echo "My storage for always keeping space for me!"
sleep 1
echo "But mostly..."
sleep 20
echo "You, for killing me *dab*"
}
clear
mpv --really-quiet outro.webm &
mpv_pid=$!
endtxt &
sleep 58
sudo shutdown -P now goodbye world
wait $mpv_pid

1
machine/riscv-asm/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
build/

View file

@ -0,0 +1,17 @@
#!/bin/sh
set -e
echo "Building for RISC-V 64..."
[ -d "build" ] || mkdir build
rm -rf build/*
riscv64-linux-gnu-as main.s -o build/main.o
riscv64-linux-gnu-gcc \
build/main.o \
-o build/main \
-nostdlib \
-static
echo "OK"

View file

@ -0,0 +1,4 @@
#!/bin/sh
rm -rf build

19
machine/riscv-asm/main.s Normal file
View file

@ -0,0 +1,19 @@
.global _start
_start:
addi a7, x0, 64 # syscall write
addi a0, x0, 1 # stdout fd
la a1, str_helloworld # load label into reg: a1
addi a2, x0, 13 # length of string
ecall # call kernel
beqz x0, _exit # branch if = to zero
_exit:
addi a7, x0, 93 # syscall exit
addi a0, x0, 0 # exit code
ecall # call kernel
str_helloworld:
.ascii "Hello World!\n"

4
machine/riscv-asm/run.sh Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
[ "$1" = "build" ] && sh ./build.sh
qemu-riscv64 build/main

2
machine/shrink-video/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
*.webm

41
machine/shrink-video/shrink.sh Executable file
View file

@ -0,0 +1,41 @@
#!/bin/bash
crf=${CRF:-25}
video_codec=${VIDEO_CODEC:-libsvtav1}
audio_codec=${AUDIO_CODEC:-libopus}
while getopts ":c:v:a:" opt; do
case $opt in
c)
crf=$OPTARG
;;
v)
video_codec=$OPTARG
;;
a)
audio_codec=$OPTARG
;;
\?)
echo "no such arg!"
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ $# -eq 0 ]; then
echo "no file selected"
exit 1
fi
if ! [ -f $1 ]; then
echo "no such file"
exit 2
fi
ffmpeg \
-i $1 \
-crf $crf \
-c:v $video_codec \
-c:a $audio_codec \
${2:-out.$1}