Compare commits

..

17 Commits

38 changed files with 22689 additions and 50 deletions

8
.gitignore vendored
View File

@@ -10,3 +10,11 @@ input.txt
greek.csv
node_modules
target
_build/
dist/
dist-newstyle/
*.pdf
*.ps
*~
*.zip
.ipynb_checkpoints/

View File

@@ -5,4 +5,5 @@
(lisa 10.45 (laura)) ; honig + nüsse
(lisa 5.99 (lisa laura johannes kieran)) ; vegane würste + nüsse
(johannes 1.89 (lisa laura johannes kieran)) ; reeses
(laura 20 (lisa laura johannes kieran)) ; sprit
)

View File

@@ -5,6 +5,7 @@
(srfi srfi-69)
(ice-9 pretty-print))
(define (balance expenses)
(define (add-expense! totals expense)
(let* ((payer (car expense))
@@ -22,7 +23,7 @@
participants)
;; update payer
(hash-table-update! totals payer
(lambda (x) (+ x amount))
(lambda (x) (+ x amount (- share)))
(lambda () 0))))
(define totals (make-hash-table))
(for-each (lambda (expense)

15
hijri/hijri.go Normal file
View File

@@ -0,0 +1,15 @@
package main
import (
"fmt"
"time"
"github.com/kiaderouiche/go-hijricalendar"
)
func main() {
// Get a new instance of hijri.Time representing the current time
ht := hijri.Now(hijri.UmmAlQura())
// Get year, month, day
fmt.Println(ht.Date())
fmt.Println(ht.Year(), ht.Month(), ht.Day())
}

View File

@@ -0,0 +1,8 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
(pkgs.ghc.withPackages (hs: [
hs.mcmc
]))
];
}

View File

@@ -0,0 +1,48 @@
(random-seed (time-nanosecond (current-time)))
(define (sample elements)
(let* ((len (length elements))
(random-index (random len)))
(list-ref elements random-index)))
(define (flatten lst)
(cond
((null? lst) '())
((list? (car lst)) (append (flatten (car lst)) (flatten (cdr lst))))
(else (cons (car lst) (flatten (cdr lst))))))
(define (symbols-to-string symbol-list)
(apply string-append (map symbol->string symbol-list)))
(define V '(a e i o u))
(define C '(p t k b d g f s h v z m n r l y w))
(define syllable-types
'((C V)
(V)
(C V C)
(V C)))
(define (random-syllable)
(let* ((syllable-type (sample syllable-types)))
(map
(lambda (cover-symbol)
(sample (case cover-symbol
((C) C)
((V) V)
(else (error #f "Invalid symbol")))))
syllable-type)))
(define (multiple n f)
(if (= n 0) '()
(cons (f)
(multiple (- n 1) f))))
(let*
((max-syllables 5)
(syllable-count (+ 1 (random max-syllables)))
(syllables (multiple syllable-count random-syllable)))
(begin
(display (symbols-to-string (flatten syllables)))
(newline)))

4
name-eugenics/shell.nix Normal file
View File

@@ -0,0 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [ pkgs.chez ];
}

View File

@@ -0,0 +1,23 @@
#!/bin/sh
VAULT=~/cloud/syncthing/obsidian
rg --no-filename '^\s*- \[ ]' "$VAULT" \
| awk '
BEGIN {
# initialize "last-tag"
# initialize tags assoc array
}
{
# find out tag
# remove tag from task text
# add task text to assoc array
# save last-tag
}
/^\s+/ {
# save under last-tag in assoc array if no tag
}
END {
# group by tag
}
'

3
ocaml/README.md Normal file
View File

@@ -0,0 +1,3 @@
_Climbing on the camel's back._ 🐫
Experiments with OCaml, inspired by [Bobkonf](https://bobkonf.de) 2026.

5
ocaml/dune Normal file
View File

@@ -0,0 +1,5 @@
(executable
(name main)
(modes js)
(libraries js_of_ocaml)
(preprocess (pps js_of_ocaml-ppx)))

2
ocaml/dune-project Normal file
View File

@@ -0,0 +1,2 @@
(lang dune 3.10)
(name ocaml_js_demo)

27
ocaml/flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1773282481,
"narHash": "sha256-b/GV2ysM8mKHhinse2wz+uP37epUrSE+sAKXy/xvBY4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fe416aaedd397cacb33a610b33d60ff2b431b127",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

73
ocaml/flake.nix Normal file
View File

@@ -0,0 +1,73 @@
{
description = "OCaml -> JavaScript demo using js_of_ocaml";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
in
{
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
ocaml
dune_3
ocamlPackages.js_of_ocaml
ocamlPackages.js_of_ocaml-compiler
nodejs
tmux
ocamlPackages.ocaml-lsp
ocamlPackages.ocamlformat
(pkgs.writeShellApplication {
name = "dev";
runtimeInputs = [ dune nodejs tmux ];
text = ''
SESSION=ocaml-js
tmux new-session -d -s "$SESSION"
tmux new-window -t "$SESSION" -n build
tmux send-keys -t "$SESSION:0" "dune build main.bc.js --watch" C-m
tmux new-window -t "$SESSION" -n server
tmux send-keys -t "$SESSION:1" "npx live-server result" C-m
tmux attach -t "$SESSION"
'';
})
];
shellHook = ''
echo "Run 'dev' to start tmux dev environment."
'';
};
packages.${system}.default = pkgs.stdenv.mkDerivation {
pname = "ocaml-js-demo";
version = "0.1";
src = ./.;
nativeBuildInputs = with pkgs; [
ocaml
dune_3
ocamlPackages.js_of_ocaml
ocamlPackages.js_of_ocaml-compiler
ocamlPackages.js_of_ocaml-ppx
];
buildPhase = ''
dune build main.bc.js
'';
installPhase = ''
mkdir -p $out
cp _build/default/main.bc.js $out/
cp index.html $out/
'';
};
};
}

15
ocaml/index.html Normal file
View File

@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>OCaml DOM demo</title>
</head>
<body>
<h1 id="title">OCaml DOM Demo</h1>
<button id="btn">Click me</button>
<p id="output"></p>
<script src="main.bc.js"></script>
</body>
</html>

23
ocaml/main.ml Normal file
View File

@@ -0,0 +1,23 @@
open Js_of_ocaml
(* open Js_of_ocaml.Dom_html *)
let document = Dom_html.document
let by_id id =
Js.Opt.get
(document##getElementById (Js.string id))
(fun () -> failwith ("Missing element: " ^ id))
let () =
let button = by_id "btn" in
let output = by_id "output" in
let clicks = ref 0 in
button##.onclick :=
Dom_html.handler (fun _ ->
incr clicks;
output##.textContent :=
Js.some (Js.string ("Clicked " ^ string_of_int !clicks ^ " times"));
Js._false
)

18
print-remote/print.sh Normal file
View File

@@ -0,0 +1,18 @@
printer=OfficeJet
proxy=zaatar
remote_temporary_directory=$(ssh "$proxy" 'mktemp -d')
clean() {
ssh "$proxy" "rm -rf $remote_temporary_directory"
}
trap clean EXIT
for file in $@; do
if [ -f "$file" ]; then
rsync "$file" "$proxy:$remote_temporary_directory"
ssh "$proxy" lpr -P "$printer" "$remote_temporary_directory/$(basename "$file")"
else
echo Skipping non-file "$file" >&2
fi
done
ssh "$proxy" lpq -P "$printer"

11
pronouncer/bereshit Normal file
View File

@@ -0,0 +1,11 @@
בְּרֵאשִׁ֖ית בָּרָ֣א אֱלֹהִ֑ים אֵ֥ת הַשָּׁמַ֖יִם וְאֵ֥ת הָאָֽרֶץ׃ ב וְהָאָ֗רֶץ הָיְתָ֥ה תֹ֙הוּ֙ וָבֹ֔הוּ וְחֹ֖שֶׁךְ עַל־פְּנֵ֣י תְה֑וֹם וְר֣וּחַ אֱלֹהִ֔ים מְרַחֶ֖פֶת עַל־פְּנֵ֥י הַמָּֽיִם׃ ג וַיֹּ֥אמֶר אֱלֹהִ֖ים יְהִ֣י א֑וֹר וַֽיְהִי־אֽוֹר׃ ד וַיַּ֧רְא אֱלֹהִ֛ים אֶת־הָא֖וֹר כִּי־ט֑וֹב וַיַּבְדֵּ֣ל אֱלֹהִ֔ים בֵּ֥ין הָא֖וֹר וּבֵ֥ין הַחֹֽשֶׁךְ׃ ה וַיִּקְרָ֨א אֱלֹהִ֤ים ׀ לָאוֹר֙ י֔וֹם וְלַחֹ֖שֶׁךְ קָ֣רָא לָ֑יְלָה וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם אֶחָֽד׃
  
[לוי]ו וַיֹּ֣אמֶר אֱלֹהִ֔ים יְהִ֥י רָקִ֖יעַ בְּת֣וֹךְ הַמָּ֑יִם וִיהִ֣י מַבְדִּ֔יל בֵּ֥ין מַ֖יִם לָמָֽיִם׃ ז וַיַּ֣עַשׂ אֱלֹהִים֮ אֶת־הָרָקִ֒יעַ֒ וַיַּבְדֵּ֗ל בֵּ֤ין הַמַּ֙יִם֙ אֲשֶׁר֙ מִתַּ֣חַת לָרָקִ֔יעַ וּבֵ֣ין הַמַּ֔יִם אֲשֶׁ֖ר מֵעַ֣ל לָרָקִ֑יעַ וַֽיְהִי־כֵֽן׃ ח וַיִּקְרָ֧א אֱלֹהִ֛ים לָֽרָקִ֖יעַ שָׁמָ֑יִם וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם שֵׁנִֽי׃
  
[ישראל]ט וַיֹּ֣אמֶר אֱלֹהִ֗ים יִקָּו֨וּ הַמַּ֜יִם מִתַּ֤חַת הַשָּׁמַ֙יִם֙ אֶל־מָק֣וֹם אֶחָ֔ד וְתֵרָאֶ֖ה הַיַּבָּשָׁ֑ה וַֽיְהִי־כֵֽן׃ י וַיִּקְרָ֨א אֱלֹהִ֤ים ׀ לַיַּבָּשָׁה֙ אֶ֔רֶץ וּלְמִקְוֵ֥ה הַמַּ֖יִם קָרָ֣א יַמִּ֑ים וַיַּ֥רְא אֱלֹהִ֖ים כִּי־טֽוֹב׃ יא וַיֹּ֣אמֶר אֱלֹהִ֗ים תַּֽדְשֵׁ֤א הָאָ֙רֶץ֙ דֶּ֗שֶׁא עֵ֚שֶׂב מַזְרִ֣יעַ זֶ֔רַע עֵ֣ץ פְּרִ֞י עֹ֤שֶׂה פְּרִי֙ לְמִינ֔וֹ אֲשֶׁ֥ר זַרְעוֹ־ב֖וֹ עַל־הָאָ֑רֶץ וַֽיְהִי־כֵֽן׃ יב וַתּוֹצֵ֨א הָאָ֜רֶץ דֶּ֠שֶׁא עֵ֣שֶׂב מַזְרִ֤יעַ זֶ֙רַע֙ לְמִינֵ֔הוּ וְעֵ֧ץ עֹֽשֶׂה־פְּרִ֛י אֲשֶׁ֥ר זַרְעוֹ־ב֖וֹ לְמִינֵ֑הוּ וַיַּ֥רְא אֱלֹהִ֖ים כִּי־טֽוֹב׃ יג וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם שְׁלִישִֽׁי׃
  
[ע"כ ישראל]יד וַיֹּ֣אמֶר אֱלֹהִ֗ים יְהִ֤י מְאֹרֹת֙ בִּרְקִ֣יעַ הַשָּׁמַ֔יִם לְהַבְדִּ֕יל בֵּ֥ין הַיּ֖וֹם וּבֵ֣ין הַלָּ֑יְלָה וְהָי֤וּ לְאֹתֹת֙ וּלְמ֣וֹעֲדִ֔ים וּלְיָמִ֖ים וְשָׁנִֽים׃ טו וְהָי֤וּ לִמְאוֹרֹת֙ בִּרְקִ֣יעַ הַשָּׁמַ֔יִם לְהָאִ֖יר עַל־הָאָ֑רֶץ וַֽיְהִי־כֵֽן׃ טז וַיַּ֣עַשׂ אֱלֹהִ֔ים אֶת־שְׁנֵ֥י הַמְּאֹרֹ֖ת הַגְּדֹלִ֑ים אֶת־הַמָּא֤וֹר הַגָּדֹל֙ לְמֶמְשֶׁ֣לֶת הַיּ֔וֹם וְאֶת־הַמָּא֤וֹר הַקָּטֹן֙ לְמֶמְשֶׁ֣לֶת הַלַּ֔יְלָה וְאֵ֖ת הַכּוֹכָבִֽים׃ יז וַיִּתֵּ֥ן אֹתָ֛ם אֱלֹהִ֖ים בִּרְקִ֣יעַ הַשָּׁמָ֑יִם לְהָאִ֖יר עַל־הָאָֽרֶץ׃ יח וְלִמְשֹׁל֙ בַּיּ֣וֹם וּבַלַּ֔יְלָה וּֽלְﬞהַבְדִּ֔יל בֵּ֥ין הָא֖וֹר וּבֵ֣ין הַחֹ֑שֶׁךְ וַיַּ֥רְא אֱלֹהִ֖ים כִּי־טֽוֹב׃ יט וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם רְבִיעִֽי׃
  
כ וַיֹּ֣אמֶר אֱלֹהִ֔ים יִשְׁרְצ֣וּ הַמַּ֔יִם שֶׁ֖רֶץ נֶ֣פֶשׁ חַיָּ֑ה וְעוֹף֙ יְעוֹפֵ֣ף עַל־הָאָ֔רֶץ עַל־פְּנֵ֖י רְקִ֥יעַ הַשָּׁמָֽיִם׃ כא וַיִּבְרָ֣א אֱלֹהִ֔ים אֶת־הַתַּנִּינִ֖ם הַגְּדֹלִ֑ים וְאֵ֣ת כׇּל־נֶ֣פֶשׁ הַֽחַיָּ֣ה ׀ הָֽרֹמֶ֡שֶׂת אֲשֶׁר֩ שָׁרְצ֨וּ הַמַּ֜יִם לְמִֽינֵהֶ֗ם וְאֵ֨ת כׇּל־ע֤וֹף כָּנָף֙ לְמִינֵ֔הוּ וַיַּ֥רְא אֱלֹהִ֖ים כִּי־טֽוֹב׃ כב וַיְבָ֧רֶךְ אֹתָ֛ם אֱלֹהִ֖ים לֵאמֹ֑ר פְּר֣וּ וּרְב֗וּ וּמִלְא֤וּ אֶת־הַמַּ֙יִם֙ בַּיַּמִּ֔ים וְהָע֖וֹף יִ֥רֶב בָּאָֽרֶץ׃ כג וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם חֲמִישִֽׁי׃
  
כד וַיֹּ֣אמֶר אֱלֹהִ֗ים תּוֹצֵ֨א הָאָ֜רֶץ נֶ֤פֶשׁ חַיָּה֙ לְמִינָ֔הּ בְּהֵמָ֥ה וָרֶ֛מֶשׂ וְחַֽיְתוֹ־אֶ֖רֶץ לְמִינָ֑הּ וַֽיְהִי־כֵֽן׃ כה וַיַּ֣עַשׂ אֱלֹהִים֩ אֶת־חַיַּ֨ת הָאָ֜רֶץ לְמִינָ֗הּ וְאֶת־הַבְּהֵמָה֙ לְמִינָ֔הּ וְאֵ֛ת כׇּל־רֶ֥מֶשׂ הָֽאֲדָמָ֖ה לְמִינֵ֑הוּ וַיַּ֥רְא אֱלֹהִ֖ים כִּי־טֽוֹב׃ כו וַיֹּ֣אמֶר אֱלֹהִ֔ים נַֽעֲשֶׂ֥ה אָדָ֛ם בְּצַלְמֵ֖נוּ כִּדְמוּתֵ֑נוּ וְיִרְדּוּ֩ בִדְגַ֨ת הַיָּ֜ם וּבְע֣וֹף הַשָּׁמַ֗יִם וּבַבְּהֵמָה֙ וּבְכׇל־הָאָ֔רֶץ וּבְכׇל־הָרֶ֖מֶשׂ הָֽרֹמֵ֥שׂ עַל־הָאָֽרֶץ׃ כז וַיִּבְרָ֨א אֱלֹהִ֤ים ׀ אֶת־הָֽאָדָם֙ בְּצַלְמ֔וֹ בְּצֶ֥לֶם אֱלֹהִ֖ים בָּרָ֣א אֹת֑וֹ זָכָ֥ר וּנְקֵבָ֖ה בָּרָ֥א אֹתָֽם׃ כח וַיְבָ֣רֶךְ אֹתָם֮ אֱלֹהִים֒ וַיֹּ֨אמֶר לָהֶ֜ם אֱלֹהִ֗ים פְּר֥וּ וּרְב֛וּ וּמִלְא֥וּ אֶת־הָאָ֖רֶץ וְכִבְשֻׁ֑הָ וּרְד֞וּ בִּדְגַ֤ת הַיָּם֙ וּבְע֣וֹף הַשָּׁמַ֔יִם וּבְכׇל־חַיָּ֖ה הָֽרֹמֶ֥שֶׂת עַל־הָאָֽרֶץ׃ כט וַיֹּ֣אמֶר אֱלֹהִ֗ים הִנֵּה֩ נָתַ֨תִּי לָכֶ֜ם אֶת־כׇּל־עֵ֣שֶׂב ׀ זֹרֵ֣עַ זֶ֗רַע אֲשֶׁר֙ עַל־פְּנֵ֣י כׇל־הָאָ֔רֶץ וְאֶת־כׇּל־הָעֵ֛ץ אֲשֶׁר־בּ֥וֹ פְרִי־עֵ֖ץ זֹרֵ֣עַ זָ֑רַע לָכֶ֥ם יִֽהְיֶ֖ה לְאׇכְלָֽה׃ ל וּֽלְכׇל־חַיַּ֣ת הָ֠אָ֠רֶץ וּלְכׇל־ע֨וֹף הַשָּׁמַ֜יִם וּלְכֹ֣ל ׀ רוֹמֵ֣שׂ עַל־הָאָ֗רֶץ אֲשֶׁר־בּוֹ֙ נֶ֣פֶשׁ חַיָּ֔ה אֶת־כׇּל־יֶ֥רֶק עֵ֖שֶׂב לְאׇכְלָ֑ה וַֽיְהִי־כֵֽן׃ לא וַיַּ֤רְא אֱלֹהִים֙ אֶת־כׇּל־אֲשֶׁ֣ר עָשָׂ֔ה וְהִנֵּה־ט֖וֹב מְאֹ֑ד וַֽיְהִי־עֶ֥רֶב וַֽיְהִי־בֹ֖קֶר י֥וֹם הַשִּׁשִּֽׁי׃

8
pronouncer/input Normal file
View File

@@ -0,0 +1,8 @@
בְּרֵאשִׁית בָּרָא אֱלֹהִים אֵת הַשָּׁמַיִם וְאֵת הָאָֽרֶץ׃
וְהָאָרֶץ הָיְתָה תֹהוּ וָבֹהוּ וְחֹשֶׁךְ עַל־פְּנֵי תְהוֹם וְרוּחַ אֱלֹהִים מְרַחֶפֶת עַל־פְּנֵי הַמָּֽיִם׃
וַיֹּאמֶר אֱלֹהִים יְהִי אוֹר וַֽיְהִי־אֽוֹר׃
וַיַּרְא אֱלֹהִים אֶת־הָאוֹר כִּי־טוֹב וַיַּבְדֵּל אֱלֹהִים בֵּין הָאוֹר וּבֵין הַחֹֽשֶׁךְ׃
וַיִּקְרָא אֱלֹהִים ׀ לָאוֹר יוֹם וְלַחֹשֶׁךְ קָרָא לָיְלָה וַֽיְהִי־עֶרֶב וַֽיְהִי־בֹקֶר יוֹם אֶחָֽד׃ פ
וַיֹּאמֶר אֱלֹהִים יְהִי רָקִיעַ בְּתוֹךְ הַמָּיִם וִיהִי מַבְדִּיל בֵּין מַיִם לָמָֽיִם׃
וַיַּעַשׂ אֱלֹהִים אֶת־הָרָקִיעַ וַיַּבְדֵּל בֵּין הַמַּיִם אֲשֶׁר מִתַּחַת לָרָקִיעַ וּבֵין הַמַּיִם אֲשֶׁר מֵעַל לָרָקִיעַ וַֽיְהִי־כֵֽן׃
וַיִּקְרָא אֱלֹהִים לָֽרָקִיעַ שָׁמָיִם וַֽיְהִי־עֶרֶב וַֽיְהִי־בֹקֶר יוֹם שֵׁנִֽי׃ פ

90
pronouncer/process.sed Executable file
View File

@@ -0,0 +1,90 @@
#!/usr/bin/env -S sed -f
s/ֽ//g # meteg
s/\([ְֱִֵֶַָֹֹ]\?\)\(ּ\?\)\([ׁׂ]\?\)/\3\2\1/g
s/[֛֖֥֑֣֤֧֮֒֗֙֨֠֔֩֡]/'/g
s/ךְ/ך/g
s/שׁ/š/g
s/שׂ/ś/g
s/בּ/b/g
s/דּ/d/g
s/גּ/g/g
s/[פף]ּ/p/g
s/תּ/t/g
s/[כך]ּ/k/g
s/ב/β/g
s/ד/δ/g
s/ג/γ/g
s/[פף]/φ/g
s/ת/θ/g
s/[כך]/χ/g
s/ח//g
s/[ןנ]/n/g
s/ר/r/g
s/א/ʾ/g
s/[מם]/m/g
s/[צץ]//g
s/ל/l/g
s/ז/z/g
s/ק//g
s/ט//g
s/ה/h/g
s/ע/ʿ/g
s/וּ/û/g
s/ֵי/ê/g
s/ִי/î/g
s/ְ/ə/g
s/ֱ/ĕ/g
s/ֶ/e/g
s/ֹ/ō/g
s/ַ/a/g
s/ֲ/ă/g
s/ֵ/ē/g
s/ִ/i/g
s/ֻ/u/g
s/ָ/ā/g
s/ׇ/o/g
s/ו/v/g
s/י/y/g
s//ô/g
s/\(.\)ּ/\1\1/g
s/\([ḥʿ]\)a\b/a\1/g # patah furtivum
s/\([ai]\)\([rḇḳy]\)ə/\1\2/g
s/־/-/g
s/׃/./g
s/\([aeiuāēōêîû]\)\('\?\)\([ptk]\)\('\?\)\([aeiuāēōêîû]\)/\1\2\3\3\4\5/g # dagesch forte
s/\([aeiuoá]\)\(.\)ə/\1\2/g # schwa quiescens
s/\bφ\b//g
s/a'/á/g
s/ā\(.\?\)'/ā́\1/g
s/ē\(.\?\)'/ḗ\1/g
s/e\(.\?\)'/é\1/g
s/ō\(.\?\)'/ṓ\1/g
s/ô\(.\?\)'/ố\1/g
s/i\(.\?\)'/i\1/g
s/î\(.\?\)'/î́\1/g
s/i'y\|î'/î́/g
s/iy/î/g
s/ḗy/ế/g
s//ố/g
s/ō'/ṓ/g
s/û'\|'û/û́/g
s/i'/í/g
s/φ//g
s/θ//g
s/χ//g
s/β//g
s/δ//g
s/γ//g

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,76 @@
import pandas as pd
import numpy as np
from typing import List, Tuple, Literal, Generator
from numpy.typing import NDArray
import itertools
import math
import random
type Binary = Literal[0] | Literal[1]
def get_transitions[A](series: List[A], step=1) -> List[Tuple[A, A]]:
cycled_series = series[step:] + series[:step]
return list(zip(series, cycled_series))
def transition_matrix[A](transitions: List[Tuple[A, A]]) -> NDArray[np.integer]:
element, next_element = zip(*transitions)
crosstab = pd.crosstab(element, next_element)
return np.matrix(crosstab)
def correlation(matrix: NDArray[np.integer]) -> float:
if matrix.shape != (2, 2):
raise ValueError("The input matrix must be 2x2")
main_diagonal_product = matrix[0, 0] * matrix[1, 1]
other_diagonal_product = matrix[0, 1] * matrix[1, 0]
difference = main_diagonal_product - other_diagonal_product
row_sums = matrix.sum(axis=1)
col_sums = matrix.sum(axis=0)
product_of_sums = np.prod(row_sums) * np.prod(col_sums)
sqrt_product_of_sums = np.sqrt(product_of_sums)
return difference / sqrt_product_of_sums
def correlation_ranges[A](series: List[A]) -> Generator[float, None, None]:
step = 0
while True:
transitions = get_transitions(series, step=step)
matrix = transition_matrix(transitions)
current_correlation = correlation(matrix)
yield current_correlation
step += 1
type MetricalSyllable = Literal["-"] | Literal["u"]
sonett = list(14 * ((5 * "u-") + "u"))
limerick = list(2 * "u-uu-uu-u" + 2 * "u-uu-" + "u-uu-uu-u")
def get_hexameter(k: int = 1):
result = []
for _ in range(k):
hexameter = list("".join(random.choices(["-uu", "--"], k=5)) + random.choice(["--", "-u"]))
result.extend(hexameter)
return result
mat = transition_matrix(get_transitions(sonett))
print(mat)
print(correlation(mat))
mat = transition_matrix(get_transitions(limerick))
print(mat)
print(correlation(mat))
mat = transition_matrix(get_transitions(get_hexameter(k=2000)))
print(mat)
print(correlation(mat))
mat = transition_matrix(get_transitions(random.choices(["-", "u"], k=20000)))
print(mat)
print(correlation(mat))
print(list(itertools.islice(correlation_ranges(get_hexameter(k=2000)), 40)))

132
roff/letter.txt Normal file
View File

@@ -0,0 +1,132 @@
Title of my paper
Jim Hall
Class
Instructor
Date
left center right
1. Introduction
One cool thing I like about the history of Unix is how
Unix developed into a document processing system. The short
history of that is the Unix team wanted to purchase a new
computer to keep working on Unix. But management said "No."
Around that same time, the Patents team wanted to buy a
new computer to write patent applications, but the vendor
hadn't finished the software yet. The Unix team went to
them and said:
Hey, if you buy us a new computer, we'll update the
existing roff typesetting system so you can write
patent applications.
That's how Unix created the first nroff program, new
roff. Later, they updated nroff to become troff, the type-
setter roff, and even later ditroff, the device idenependent
version of troff.
left 1

2
roff/margins.me Normal file
View File

@@ -0,0 +1,2 @@
.ll 60
.po 10

465
roff/paper-ps Normal file
View File

@@ -0,0 +1,465 @@
x T ps
x res 72000 1 1
x init
p1
V168000
H100000
DFd
x font 38 TB
f38
s10000
h263010
md
tT
H369500
title
wh2500
tof
wh2500
tmy
wh2500
tpaper
n12000 0
x font 5 TR
f5
V204000
H382915
tJim
wh2500
tHall
n12000 0
V228000
H389165
tClass
n12000 0
V252000
H380560
tInstructor
n12000 0
V276000
H390560
tDate
n12000 0
V792000
p1
x font 38 TB
f38
s10000
V60000
H100000
tleft
h272795
tcenter
h265565
tright
n12000 0
V96000
H100000
t1.
wh5000
tIntr
H129540
toduction
h5000
n12000 0
x font 5 TR
f5
V124200
H125000
tOne
wh2574
tcool
wh2574
tthing
wh2573
tI
wh2573
tlik
H203524
te
wh2573
tabout
wh2573
tthe
wh2573
thistory
wh2573
tof
wh2573
tUnix
wh2573
tis
wh2573
tho
H332945
tw
wh2573
tUnix
wh2573
tde
H374501
tv
H379351
teloped
wh2573
tinto
wh2573
ta
wh2573
tdocument
wh2573
tprocessing
wh2573
tsystem.
wh5073
tThe
wh2573
tshort
wh2573
thistory
wh2573
tof
wh2573
tthat
wh2573
tis
wh2573
tthe
wh2573
tUnix
n12000 0
V148200
H100000
tteam
wh2500
tw
H129060
tanted
wh2500
tto
wh2500
tpurchase
wh2500
ta
wh2500
tne
H217670
tw
wh2500
tcomputer
wh2500
tto
wh2500
tk
H282840
teep
wh2500
tw
H306340
torking
wh2500
ton
wh2500
tUnix.
wh5000
tBut
wh2500
tmanagement
wh2500
tsaid
wh2500
Clq
h4440
tNo.
H482570
Crq
h4440
n12000 0
V176400
H125000
tAround
wh2549
tthat
wh2549
tsame
wh2549
ttime,
wh2549
tthe
wh2549
tP
H241755
tatents
wh2549
tteam
wh2549
tw
H296743
tanted
wh2549
tto
wh2549
tb
H336081
tuy
wh2549
ta
wh2549
tne
H364809
tw
wh2549
tcomputer
wh2549
tto
wh2549
twrite
wh2549
tpatent
wh2549
tapplications,
wh2549
tb
H533493
tut
wh2549
tthe
wh2549
tv
H563441
tendor
wh2549
thadn'
H611350
tt
wh2550
Cfi
h5560
tnished
wh2550
tthe
wh2550
tsoftw
H687790
tare
n12000 0
V200400
H100000
tyet.
wh5000
tThe
wh2500
tUnix
wh2500
tteam
wh2500
twent
wh2500
tto
wh2500
tthem
wh2500
tand
wh2500
tsaid:
n12000 0
s9000
V227400
H120000
tHe
H130359
ty
H134274
t,
wh2250
tif
wh2250
tyou
wh2250
tb
H166593
tuy
wh2250
tus
wh2250
ta
wh2250
tne
H202611
tw
wh2250
tcomputer
H244992
t,
wh2250
twe'
H262893
tll
wh2250
tupdate
wh2250
tthe
wh2250
te
H313500
txisting
wf38
h2250
tr
H344091
toff
wf5
h2250
ttypesetting
wh2250
tsystem
wh2250
tso
wh2250
tyou
wh2250
tcan
wh2250
twrite
wh2250
tpatent
wh2250
tapplications.
n10800 0
s10000
V259800
H125000
tThat'
H146110
ts
wh3963
tho
H163713
tw
wh3963
tUnix
wh3963
tcreated
wh3963
tthe
wh3963
Cfi
h5560
trst
wf38
h3963
tnr
H277218
toff
wf5
h3963
tprogram,
wx font 40 TI
f40
h4323
tne
H342834
tw
wh3963
tr
H356907
tof
H364507
tf
f5
h1960
t.
wh6463
tLater
H398910
t,
wh3963
tthe
H417443
ty
wh3963
tupdated
wf38
h3963
tnr
H471849
toff
wf5
h3963
tto
wh3963
tbecome
wf38
h3963
ttr
H541868
toff
f5
t,
wh3962
tthe
wf40
h4092
ttypesetter
wh3962
tr
H622584
tof
H630184
tf
f5
h1960
t,
wh3962
tand
wh3962
te
H663978
tv
H668828
ten
wh3962
tlater
n12000 0
f38
V283800
H100000
tditr
H115930
toff
f5
t,
wh2500
tthe
wf40
h2850
tde
H156950
tvice
wh2500
tidenependent
wf5
h3180
tv
H236900
tersion
wh2500
tof
wf38
h2500
ttr
H282260
toff
f5
t.
n12000 0
f38
V756000
H100000
tleft
h581120
t1
n12000 0
x trailer
V792000
x stop

53
roff/paper.me Normal file
View File

@@ -0,0 +1,53 @@
.tp
.he 'left'center'right'
.fo 'left''%'
.sp 6
.ce 5
.b "Title of my paper"
.sp 2
Jim Hall
.sp
Class
.sp
Instructor
.sp
Date
.bp
.\" .ls 2
.sh 1 Introduction
.lp
One cool thing I like about the history of Unix is how
Unix developed into a document processing system.
The short history of that is the Unix team wanted to
purchase a new computer to keep working on Unix.
But management said
.q No.
.pp
Around that same time, the Patents team wanted to buy a
new computer to write patent applications, but the
vendor hadn't finished the software yet.
The Unix team went to them and said:
.(q
Hey, if you buy us a new computer,
we'll update the existing
.b roff
typesetting system so you can write patent applications.
.)q
.pp
That's how Unix created the first
.b nroff
program,
.i "new roff" .
Later, they updated
.b nroff
to become
.b troff ,
the
.i "typesetter roff" ,
and even later
.b ditroff ,
the
.i "device idenependent"
version of
.b troff .
.sh 2 Introduction

4
roff/shell.nix Normal file
View File

@@ -0,0 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [pkgs.groff];
}

View File

@@ -10,7 +10,7 @@ exec >&2
for i in `seq 8000 1000 10000`; do
echo $i 100
done | ./target/debug/rusty-jeep 1
done | ./target/release/rusty-jeep 1
echo 'if you heard that sound, then goto sleep..^_^'
echo sleep "$@"
@@ -19,4 +19,4 @@ sleep "$@"
echo 'wake up!'
while :; do
echo $(echo "($(od -tu -An -N 2 /dev/urandom)%1000)+500"|bc) $(echo "($(od -tu -An -N 2 /dev/urandom)%500)+100"|bc)
done | ./target/debug/rusty-jeep 1
done | ./target/release/rusty-jeep 1

48
scan2pdf/shell.nix Normal file
View File

@@ -0,0 +1,48 @@
{ pkgs ? import <nixpkgs> {} }:
let
crop_ppm = (pkgs.writers.writePython3Bin "crop_ppm" {libraries = [pkgs.python3Packages.opencv4];} ''
import cv2
import sys
for path in sys.argv[1:]:
img = cv2.imread(path)[30:-30, 30:]
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
_, thresh = cv2.threshold(gray, 1, 255, cv2.THRESH_BINARY)
contours, hierarchy = cv2.findContours(
thresh,
cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE
)
cnt = max(contours, key=cv2.contourArea)
x, y, w, h = cv2.boundingRect(cnt)
print(path, x, y, w, h)
crop = img[y:y + h, x:x + w]
cv2.imwrite(path, crop)
'');
in
pkgs.mkShell {
packages = [
pkgs.poppler_utils
pkgs.mupdf
crop_ppm
(pkgs.writers.writeDashBin "generate" ''
set -x
pwd=$(pwd)
tmpdir=$(mktemp -d)
cd "$tmpdir"
[ $# -eq 1 ] || {
echo Please provide one PDF file as argument. >&2
exit 1
}
[ -f "$1" ] || {
echo "$1" does not exist. >&2
exit 1
}
basename=$(basename "$1" .pdf)
${pkgs.poppler_utils}/bin/pdftoppm "$1" exploded
${crop_ppm}/bin/crop_ppm exploded*.ppm
${pkgs.imagemagick}/bin/convert exploded*.ppm "$pwd/cropped-$basename.pdf"
${pkgs.mupdf}/bin/mutool poster -x 2 "$pwd/cropped-$basename.pdf" "$pwd/split-cropped-$basename.pdf"
'')
];
}

View File

@@ -0,0 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [ pkgs.racket ];
}

View File

@@ -0,0 +1,15 @@
#lang typed/racket
(: sum (-> (Listof Number) Number))
(define (sum list) (foldr + 0 list))
(: mean (-> (Listof Number) Number))
(define (mean sample)
(/ (sum sample) (length sample)))
(: standard-deviation (-> (Listof Number) Number))
(define (standard-deviation sample)
(let* ((degrees-of-freedom (- (length sample) 1))
(sample-mean (mean sample))
(sum-of-squared-errors (sum (map (lambda (xi) (expt (- xi sample-mean) 2)) sample))))
(sqrt (/ sum-of-squared-errors degrees-of-freedom))))

51
streaming-link-bot/bot.py Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env python
from telegram import Update, ForceReply
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
import os
import re
import requests
import sys
def convert_link(link: str) -> str:
if "spotify" in link:
to_service = "youtube_music"
elif "youtube" in link:
to_service = "spotify"
link = re.sub(r"//(www\.)?youtube.com", "//music.youtube.com", link)
else:
raise ValueError("Invalid streaming service: " + link)
print(f"Trying to convert {link}", file=sys.stderr)
r = requests.get(f'https://ytm2spotify.com/convert?url={link}&to_service={to_service}')
print(r.text, file=sys.stderr)
json = r.json()
print(json, file=sys.stderr)
return json["results"][0]["url"]
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
user = update.effective_user
await update.message.reply_html(
rf"Hi {user.mention_html()}! You can send me links to Spotify songs and I'll give you the link on YouTube Music—and vice versa.",
reply_markup=ForceReply(selective=True),
)
async def streaming_link(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
try:
converted = convert_link(update.message.text)
await update.message.reply_text(converted)
except Exception as e:
print(e, file=sys.stderr)
await update.message.reply_text("Cannot convert this.")
def main(token: str) -> None:
application = Application.builder().token(token).build()
application.add_handler(CommandHandler("start", start))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, streaming_link))
application.run_polling(allowed_updates=Update.ALL_TYPES)
if __name__ == "__main__":
token = os.getenv("TELEGRAM_TOKEN")
if token:
main(token)
else:
print("Missing TELEGRAM_TOKEN environment variable", file=sys.stderr)

View File

@@ -0,0 +1,11 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (py: [
py.yt-dlp
py.spotipy
py.ytmusicapi
py.python-telegram-bot
]))
];
}

View File

@@ -1,3 +1,4 @@
-- | Module to find and print all repetitions of substrings in a given string.
module Main where
import Control.Monad (forM_)
@@ -6,6 +7,7 @@ import Data.List (sortOn)
import Data.Map qualified as Map
import Data.Set qualified as Set
-- | Creates a sliding window of a given size over a list.
slidingWindow :: Int -> [a] -> [[a]]
slidingWindow size list
| size > 0 && length list >= size =
@@ -29,6 +31,7 @@ pairwiseComparison xs = [(x1, i, j) | (i, x1) <- ixs, (j, x2) <- ixs, x1 == x2,
allPairwiseComparisons :: (Eq a) => [a] -> [[([a], Int, Int)]]
allPairwiseComparisons xs = map (\n -> pairwiseComparison (slidingWindow n xs)) [0 .. length xs]
-- | Finds all repetitions of substrings of a given list.
allRepetitions :: (Ord a) => [a] -> [Map.Map [a] (Set.Set Int)]
allRepetitions xs = map (\n -> findRepetitions (slidingWindow n xs)) $ reverse [0 .. length xs]
@@ -40,11 +43,15 @@ printAllRepetitions str substrRepetitions = do
zipWith
(const $ \x -> if x then '*' else ' ')
str
[i `elem` concatMap (\x -> [x .. x + length key - 1]) (Set.toList value) | i <- [0 ..]]
(isInRange (length key) (Set.toList value))
putStrLn $ "\t" ++ show key
where
score (substring, occurrences) = negate $ length substring ^ 2 * Set.size occurrences
isInRange len indices = [i `elem` concatMap (\x -> [x .. x + len - 1]) indices | i <- [0 ..]]
-- | Prints a pairwise comparison of the substrings in a grid format.
-- The grid will have 'x' for matching pairs and '_' for non-matching pairs.
-- The first row and column will show the indices of the substrings.
printPairwiseComparison :: [(Int, Int)] -> IO ()
printPairwiseComparison [] = return ()
printPairwiseComparison xys =
@@ -64,6 +71,7 @@ printPairwiseComparison xys =
putChar '\n'
putChar '\n'
main :: IO ()
main = do
let str = map toLower $ (" " ++) $ "nachts im dichten fichtendickicht da sind dicke fichten wichtig"
printAllRepetitions str (allRepetitions str)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
packages = [
(pkgs.python3.withPackages (py: [
py.jupyter
py.seaborn
py.matplotlib
py.pandas
py.numpy
]))
];
}