summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2024-06-04 15:40:40 +0200
committerAnton Luka Šijanec <anton@sijanec.eu>2024-06-04 15:40:40 +0200
commit1d0e0e54f663920a0992f1af5bd7d0b37eee537a (patch)
tree240a15da83a020bbd8b0ba294db20f45308a52c0
parentMerge branch 'master' of ssh://ni.4a.si/var/lib/git/sijanec/r (diff)
downloadr-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.gz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.bz2
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.lz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.xz
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.tar.zst
r-1d0e0e54f663920a0992f1af5bd7d0b37eee537a.zip
-rwxr-xr-xskripti/earhorn_m3u.sh7
-rw-r--r--skripti/rš_glasbena_oprema.py31
-rwxr-xr-xskripti/stream_archive.sh37
-rwxr-xr-xskripti/zone_axfr.py (renamed from skripti/zone/axfr.py)4
-rwxr-xr-xskripti/zone_update.py (renamed from skripti/zone/update.py)0
-rw-r--r--skripti/ž36
-rw-r--r--šola/ds2/teor.lyx24
-rw-r--r--šola/p2/dn/DN09b_63230317.c48
8 files changed, 169 insertions, 18 deletions
diff --git a/skripti/earhorn_m3u.sh b/skripti/earhorn_m3u.sh
index e89a151..4dae851 100755
--- a/skripti/earhorn_m3u.sh
+++ b/skripti/earhorn_m3u.sh
@@ -3,6 +3,7 @@ set -eo pipefail
# $1 je prefix
# $2 je prejšnji file (za caching dolžin)
# $3=1 forsira cache kljub version failu
+# zadnjega vnosa iz cache m3uja nikdar ne bom upošteval, ker je lahko nedokončan file (no, v earhornu ne, ampak v stream_archive.sh)
echo "#EXTM3U"
ver="#earhorn_m3u.sh različica 0"
echo $ver
@@ -23,9 +24,9 @@ do
s=${time:4:2}
dol=""
if [ $cache -eq 1 ]
- then
- grep -B2 ^$1$file$ $2 && continue
- fi
+ then # tu smatram, da vsaka datoteka zavzema 3 vrstice
+ head -n-3 $2 | grep -B2 ^$1$file$ && continue
+ fi # prvič v head ko rečem -n-3 in drugič v grep, ko rečem -B2
dol=`ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file | cut -d. -f1`
echo "#EXTINF:$dol,Radijski arhiv"
echo "#EXT-X-PROGRAM-DATE-TIME:${date}T$h:$m:${s}Z"
diff --git a/skripti/rš_glasbena_oprema.py b/skripti/rš_glasbena_oprema.py
new file mode 100644
index 0000000..8d53702
--- /dev/null
+++ b/skripti/rš_glasbena_oprema.py
@@ -0,0 +1,31 @@
+#!/usr/bin/python3
+import feedparser
+import yt_dlp
+from ollama import Client
+from bs4 import BeautifulSoup
+client = Client(host='http://splet.4a.si:80')
+model = "llama2:13b-chat-fp16"
+prompt = "The document below is text extracted from a Slovene radio station containing a tracklist. Extract the tracklist form the text below and output a CSV table in format \"artist,track name,album,duration,label\". Example output:\n\nThe Prodigy,Firestarter,The Fat of the Land,4:42,XL\nBJÖRK,LION SONG,,6:16,"
+def opreme():
+ r = []
+ for entry in feedparser.parse("https://radiostudent.si/taxonomy/term/589/*/feed").entries:
+ oprema = {"id": int(entry.id.split(" ")[0]), "title": entry.title, "link": entry.link, "published": entry.published_parsed, "authors": []}
+ for author in entry.authors:
+ oprema["authors"].append(author.name)
+ summary = BeautifulSoup(entry.summary, features="html.parser")
+ body = None
+ for i in summary.findAll("div"):
+ if "class" in i.attrs:
+ if "field-name-body" in i.attrs["class"]:
+ body = i
+ break
+ if ""
+ if body == None:
+ raise Exception("body is None in " + entry.link)
+ body = body.text.replace("\r", "")
+ while "\n\n" in body:
+ body = body.replace("\n\n", "\n")
+ r.append(oprema)
+ return r
+if __name__ == "__main__":
+ opreme() \ No newline at end of file
diff --git a/skripti/stream_archive.sh b/skripti/stream_archive.sh
new file mode 100755
index 0000000..b218246
--- /dev/null
+++ b/skripti/stream_archive.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# $1 naj bo icecast host kruljo.radiostudent.si
+# $2 naj bo icecast http port 8000
+# $3 naj bo icecast endpoint /ehiq
+# $4 naj bo končnica datotek .mp3
+# v CWD delam imenike in datoteke in sem glede tega kompatibilen z earhornom:
+# Posnetek 2024/06/03/202136.mp3 se začne 2024-06-03T20:21:36 vedno UTC.
+# Posnetkov ne splittam na uro. Posnetek se splitta le takrat, ko se zgodi napaka (stream crkne) -- takrat začnem pisati v novo datoteko
+# požvižgam se na vsebino datotek. zame so to le bajti. v tem nisem earhornski.
+# earhornski nisem tudi zato, ker se zadnja datoteka stalno veča, kar se ne dogaja pri earhornu. na to bodite pozorni. k sreči earhorn_m3u.sh ve za to obnašanje
+set -xeuo pipefail
+host=$1
+port=$2
+endpoint=$3
+kon=$4
+mistakes=0
+while :
+do
+ filename=`date --utc +%Y/%m/%d/%H%m%S$kon`
+ mkdir -p `cut -d/ -f1-3 <<<$filename`
+ start=$SECONDS
+ set +e
+ nc $host $port <<<"GET $endpoint HTTP/1.0"$'\r\n\r' > $filename
+ koda=$?
+ set -e
+ echo TCP PREKINJEN! ZAČENJAM NOV POSNETEK! IZHODNA KODA nc je $koda, datum je `date`
+ if [ $(($SECONDS-$start)) -lt 300 ]
+ then
+ mistakes=$(($mistakes+1))
+ if [ $mistakes -gt 3 ]
+ then
+ sleep $((2**($mistakes-3)))
+ fi
+ else
+ mistakes=0
+ fi
+done
diff --git a/skripti/zone/axfr.py b/skripti/zone_axfr.py
index 11eaad9..81460a6 100755
--- a/skripti/zone/axfr.py
+++ b/skripti/zone_axfr.py
@@ -29,8 +29,8 @@ if config == None:
berime = """; Dobrodošli v preprost urejevalnik DNS zapisov.
; Komentarji se shranijo v DNS strežnik in so javni. Morajo biti na samostojnih vrsticah.
; Te komentarje z navodili lahko izbrišete -- ne bodo se ponovno pojavili.
-; Nove zapise naložite na strežnik z ukazom zone/update.py zonefile.db
-; Zapise prenesete iz strežnika z ukazom zone/axfr.py domena > zonefile.db
+; Nove zapise naložite na strežnik z ukazom zone_update.py zonefile.db
+; Zapise prenesete iz strežnika z ukazom zone_axfr.py domena > zonefile.db
; Prva vrstica je konfiguracijski zapis v JSON obliki. Naslednje podatke lahko spremenite:
; "t": privzeti TTL, ki se uporabi, če zapis v datoteki nima TTLja
; "+": koliko naj prištejem serijski številki pred nalaganjem na strežnik
diff --git a/skripti/zone/update.py b/skripti/zone_update.py
index ead2c39..ead2c39 100755
--- a/skripti/zone/update.py
+++ b/skripti/zone_update.py
diff --git a/skripti/ž b/skripti/ž
new file mode 100644
index 0000000..d18de36
--- /dev/null
+++ b/skripti/ž
@@ -0,0 +1,36 @@
+#!/bin/bash
+# $1 naj bo icecast host kruljo.radiostudent.si
+# $2 naj bo icecast http port 8000
+# $3 naj bo icecast endpoint /ehiq
+# $4 naj bo končnica datotek .mp3
+# v CWD delam imenike in datoteke in sem glede tega kompatibilen z earhornom:
+# Posnetek 2024/06/03/202136.mp3 se začne 2024-06-03T20:21:36 vedno UTC.
+# Posnetkov ne splittam na uro. Posnetek se splitta le takrat, ko se zgodi napaka (stream crkne) -- takrat začnem pisati v novo datoteko
+# požvižgam se na vsebino datotek. zame so to le bajti. v tem nisem earhornski.
+host=$1
+port=$2
+endpoint=$3
+kon=$4
+mistakes=0
+set -xeuo pipefail
+while :
+do
+ filename=`date --utc +%Y/%m/%d/%H%m%S$kon`
+ mkdir -p `cut -d/ -f1-3 <<<$filename`
+ start=$SECONDS
+ set +e
+ nc $host $port <<<"GET $endpoint HTTP/1.0"$'\r\n\r' > $filename
+ koda=$?
+ set -e
+ echo TCP PREKINJEN! ZAČENJAM NOV POSNETEK! IZHODNA KODA nc je $koda, datum je `date`
+ if [ $(($SECONDS-$start)) -lt 300 ]
+ then
+ mistakes=$(($mistakes+1))
+ if [ $mistakes -gt 3 ]
+ then
+ sleep $((2**($mistakes-3)))
+ fi
+ else
+ mistakes=0
+ fi
+done
diff --git a/šola/ds2/teor.lyx b/šola/ds2/teor.lyx
index c0fe332..2d03ffc 100644
--- a/šola/ds2/teor.lyx
+++ b/šola/ds2/teor.lyx
@@ -431,13 +431,10 @@ S
, kot to naredi
\family typewriter
-bash
-\end_layout
-
-\end_inset
-
-.
- Nekateri bi
+bash.
+
+\family default
+Nekateri bi
\begin_inset Formula $\left\{ 1..n\right\} $
\end_inset
@@ -445,7 +442,12 @@ bash
\begin_inset Formula $\left[n\right]$
\end_inset
-..
+.
+\end_layout
+
+\end_inset
+
+.
Dolžina sprehoda je število prehojenih povezav.
Sprehod je
\series bold
@@ -7532,11 +7534,7 @@ Naj bo
\end_inset
in
-\begin_inset Formula $\left(a+I\right)\cdot$
-\end_inset
-
-'
-\begin_inset Formula $\left(b+I\right)=a\cdot b+I$
+\begin_inset Formula $\left(a+I\right)\cdot'\left(b+I\right)=a\cdot b+I$
\end_inset
.
diff --git a/šola/p2/dn/DN09b_63230317.c b/šola/p2/dn/DN09b_63230317.c
new file mode 100644
index 0000000..daca2bf
--- /dev/null
+++ b/šola/p2/dn/DN09b_63230317.c
@@ -0,0 +1,48 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+int next (bool * s, int l) {
+ bool hit0 = false;
+ bool hit1after0 = false;
+ int end1count = 0;
+ int end1 = l-1;
+ for (int i = l-1; i >= 0; i--) {
+ if (!s[end1])
+ end1--;
+ if (!hit0 && s[i] == 1)
+ end1count++;
+ if (!s[i])
+ hit0 = true;
+ if (hit0 && s[i])
+ hit1after0 = true;
+ }
+ if (end1 == -1) { // prazen vhod, sedaj 1 bit
+ for (int i = 0; i < l; i++)
+ s[i] = false;
+ s[0] = true;
+ return 1;
+ }
+ if (!hit0)
+ return len+1; // konec
+ if (!hif1after0) { // inc št enic
+ for (int i = 0; i < l; i++) {
+ s[i] = false;
+ if (i < end1count)
+ s[i] = true;
+ }
+ return end1count;
+ }
+}
+int main (void) {
+ int s, g, m;
+ scanf("%d", &s);
+ char * i[s];
+ char * r[s];
+ for (int i = 0; i < s; i++)
+ scanf("%ms %ms", &i[s], &r[s]);
+ scanf("%d", &g);
+ char * gl[g];
+ for (int i = 0; i < s; i++)
+ scanf("%ms", &gl[s]);
+ bool samost[s];
+}