commit de2a6bcf967a583ef5df093156ae0292d5187e6b Author: Timur Kh. Date: Sun Nov 29 23:35:05 2026 +0300 initial commit diff --git a/.gitea/workflows/build-1sem.yml b/.gitea/workflows/build-1sem.yml new file mode 100644 index 0000000..df79137 --- /dev/null +++ b/.gitea/workflows/build-1sem.yml @@ -0,0 +1,77 @@ +name: Build 1sem PDFs & update latest + +on: + push: + branches: + - '**' + workflow_dispatch: + +jobs: + build-and-release: + if: startsWith(github.ref, 'refs/heads/') + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Typst + uses: typst-community/setup-typst@v4 + + - name: Compile 1sem PDFs + run: | + mkdir -p dist + shopt -s nullglob + files=(1sem/*.typ) + if [ ${#files[@]} -eq 0 ]; then + echo "No .typ files found in 1sem/" + exit 1 + fi + for f in "${files[@]}"; do + name="$(basename "$f" .typ)" + echo "Compiling $f -> dist/${name}.pdf" + typst compile --root . "$f" "dist/${name}.pdf" + done + + - name: Update latest tag + run: | + git tag -f latest "${GITHUB_SHA}" + git push -f origin refs/tags/latest + + - name: Recreate latest release and upload PDFs + env: + GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + API="${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}" + AUTH="Authorization: token ${GITEA_TOKEN}" + + # Delete existing 'latest' release if present + existing_id=$(curl -fsS -H "$AUTH" "${API}/releases/tags/latest" | jq -r '.id // empty' || true) + if [ -n "${existing_id}" ]; then + curl -fsS -X DELETE -H "$AUTH" "${API}/releases/${existing_id}" + fi + + # Create new 'latest' release pointing to current commit + payload=$(jq -n \ + --arg tag "latest" \ + --arg sha "${GITHUB_SHA}" \ + --arg name "latest" \ + --arg body "Автосборка PDF из \`1sem/\` для коммита \`${GITHUB_SHA:0:7}\`" \ + '{tag_name: $tag, target_commitish: $sha, name: $name, body: $body, draft: false, prerelease: false}') + + release_id=$(curl -fsS -X POST \ + -H "$AUTH" \ + -H "Content-Type: application/json" \ + -d "$payload" \ + "${API}/releases" | jq -r '.id') + + # Upload all compiled PDFs as release assets + for pdf in dist/*.pdf; do + filename="$(basename "$pdf")" + echo "Uploading ${filename}..." + curl -fsS -X POST \ + -H "$AUTH" \ + -F "attachment=@${pdf}" \ + "${API}/releases/${release_id}/assets?name=${filename}" > /dev/null + done diff --git a/1sem/algo.typ b/1sem/algo.typ new file mode 100644 index 0000000..c5179a6 --- /dev/null +++ b/1sem/algo.typ @@ -0,0 +1,32 @@ +#import "../template.typ": * +#show: exam-notes.with(subject: "Алгоритмы и структуры данных") + +#ticket(1, "Асимптотика и мастер-теорема") + +#definition(title: $bigO(g(n))$)[ + Функция $f(n) in bigO(g(n))$, если найдутся $c > 0$ и $n_0 in NN$ такие, что + $0 <= f(n) <= c dot g(n)$ для всех $n >= n_0$. +] + +#theorem(title: "Мастер-теорема")[ + Для $T(n) = a T(n / b) + f(n)$ при $a >= 1, b > 1$... +] + +#proof[ + Раскрываем дерево рекурсии высоты $log_b n$... +] + +#remark[ + Не забыть на устном уточнить условие регулярности для 3-го случая. +] + +== Пример кода +```cpp +int binary_search(const std::vector& a, int target) { + int l = -1, r = static_cast(a.size()); + while (r - l > 1) { + int m = l + (r - l) / 2; + (a[m] < target ? l : r) = m; + } + return r; +} diff --git a/1sem/angem.typ b/1sem/angem.typ new file mode 100644 index 0000000..362a47a --- /dev/null +++ b/1sem/angem.typ @@ -0,0 +1,2 @@ +#import "../template.typ": * +#show: exam-notes.with(subject: "Аналитическая геометрия") diff --git a/1sem/diskra.typ b/1sem/diskra.typ new file mode 100644 index 0000000..647851f --- /dev/null +++ b/1sem/diskra.typ @@ -0,0 +1,2 @@ +#import "../template.typ": * +#show: exam-notes.with(subject: "Дискретная математика") \ No newline at end of file diff --git a/1sem/matan.typ b/1sem/matan.typ new file mode 100644 index 0000000..e64e96e --- /dev/null +++ b/1sem/matan.typ @@ -0,0 +1,2 @@ +#import "../template.typ": * +#show: exam-notes.with(subject: "Введение в математический анализ") \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6295fbc --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +SUBJECTS := matan angem diskra algo +PDFS := $(addsuffix .pdf, $(SUBJECTS)) + +.PHONY: all clean watch-% + +all: $(PDFS) + +%.pdf: %.typ template.typ + typst compile $< $@ + +watch-%: %.typ + typst watch $< $*.pdf + +clean: + rm -f $(PDFS) + \ No newline at end of file diff --git a/template.typ b/template.typ new file mode 100644 index 0000000..a0eb5eb --- /dev/null +++ b/template.typ @@ -0,0 +1,116 @@ +#let NN = $bb(N)$ +#let ZZ = $bb(Z)$ +#let QQ = $bb(Q)$ +#let RR = $bb(R)$ +#let CC = $bb(C)$ +#let eps = $epsilon$ +#let norm(x) = $lr(||#x||)$ +#let inner(a, b) = $lr(angle.l #a, #b angle.r)$ +#let bigO(x) = $cal(O)(#x)$ + +#let callout(label, accent, bg, title: none, body) = block( + width: 100%, + fill: bg, + stroke: (left: 2.5pt + accent), + inset: (x: 10pt, y: 8pt), + radius: (right: 3pt), + breakable: true, +)[ + #text(weight: "bold", fill: accent)[ + #label#if title != none [ (#title)]#"." + ] + #h(0.35em) + #body +] + +#let definition(title: none, body) = callout( + "Определение", rgb("#2563eb"), rgb("#eff6ff"), title: title, body +) +#let theorem(title: none, body) = callout( + "Теорема", rgb("#b91c1c"), rgb("#fef2f2"), title: title, body +) +#let lemma(title: none, body) = callout( + "Лемма", rgb("#7c3aed"), rgb("#f5f3ff"), title: title, body +) +#let remark(title: none, body) = callout( + "Замечание", rgb("#475569"), rgb("#f8fafc"), title: title, body +) + +#let proof(body) = block(width: 100%, breakable: true, above: 0.6em, below: 0.9em)[ + #emph[Доказательство.] #body #h(1fr) #box(width: 0.55em, height: 0.55em, stroke: 0.65pt) +] + +#let ticket(num, title, new-page: false) = { + if new-page { pagebreak(weak: true) } + heading(level: 1)[Билет #num. #title] +} + +#let exam-notes( + subject: "Предмет", + semester: "МФТИ ВШПИ · 1 семестр, осень 2026", + show-outline: true, + body, +) = { + set document(title: subject) + set page( + paper: "a4", + margin: (x: 1.8cm, y: 2cm), + numbering: "1 / 1", + header: context { + if counter(page).get().first() > 1 [ + #set text(size: 8.5pt, fill: luma(120)) + #subject #h(1fr) #semester + #v(-0.6em) + #line(length: 100%, stroke: 0.4pt + luma(200)) + ] + }, + ) + + set text(lang: "ru", size: 10.5pt) + set par(justify: true, leading: 0.62em) + set heading(numbering: none) + set list(indent: 0.8em) + set enum(indent: 0.8em) + + show math.equation.where(block: true): set block(breakable: true) + + show heading.where(level: 1): it => { + v(1.2em, weak: true) + block( + width: 100%, + below: 0.7em, + stroke: (bottom: 0.8pt + luma(160)), + inset: (bottom: 4pt), + )[ + #text(size: 13pt, weight: "bold")[#it.body] + ] + } + show heading.where(level: 2): it => { + v(0.8em, weak: true) + text(size: 11pt, weight: "bold", fill: luma(50))[#it.body] + v(0.3em, weak: true) + } + + show raw.where(block: true): block.with( + width: 100%, + fill: luma(247), + stroke: 0.5pt + luma(220), + inset: 8pt, + radius: 3pt, + breakable: true, + ) + + align(center)[ + #text(size: 18pt, weight: "bold")[#subject] \ + #v(0.2em) + #text(size: 10pt, fill: luma(110))[#semester] + ] + v(0.8em) + + if show-outline { + outline(title: [Содержание билетов], depth: 1, indent: auto) + pagebreak() + } + + body +}