Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fa77291b6 | ||
|
|
6fefa2d561 | ||
|
|
27b8e7cdf1 | ||
|
|
58e2abfdca | ||
|
|
11e3ce8dcd | ||
|
|
9c7faa0006 | ||
|
|
2a06044973 | ||
|
|
5310ac5f2f | ||
|
|
2731ce32d3 | ||
|
|
3797119bb5 |
@@ -72,6 +72,16 @@ Questa repository contiene i seguenti script:
|
||||
|
||||
Comprime un PDF vettorizzato (ad esempio note scritte su un iPad) utilizzando poppler (file di ~100MB diventa tranquillamente di ~10MB)
|
||||
|
||||
- `pptx_to_pdf` — [@lukefleed](https://git.phc.dm.unipi.it/lukefleed)
|
||||
|
||||
Permette di convertire tutti i file .pptx dentro una cartella in file .pdf. Per utilizzarlo, basta eseguire lo script da terminale nella cartella dove sono presenti i file `.pptx`
|
||||
|
||||
I nuovi file `.pdf `verranno salvati nella cartella `pdf` (che verrà creata automaticamente se non esiste già). Per poter eseguire lo script, è necessario avere installati i seguenti pacchetti (ubuntu):
|
||||
|
||||
```bash
|
||||
sudo apt install libreoffice default-jre libreoffice-java-common
|
||||
```
|
||||
|
||||
- `removeproofs` — [@lukefleed](https://git.phc.dm.unipi.it/lukefleed)
|
||||
|
||||
Rimuove le dimostrazioni da un file `.tex`, utile per creare piccoli cheat sheet da portare agli esami dove è consentito portare materiale di studio.
|
||||
@@ -83,3 +93,37 @@ Questa repository contiene i seguenti script:
|
||||
```
|
||||
|
||||
Questo script è stato utilizzato per creare dei riassunti di Geometria 2 da delle dispense più complete: [G2-cheat-sheet](https://github.com/lukefleed/G2-cheat-sheet)
|
||||
|
||||
- `tex_to_md` — [@lukefleed](https://git.phc.dm.unipi.it/lukefleed)
|
||||
|
||||
Script che prende in input un file `.tex` da in output un file `.md` contenente un elenco puntato di tutte le definizioni, teoremi e proposizioni presenti nel file `.tex`. Utile per creare un riassunto degli argomenti di un corso da utilizzare per preparare l'orale.
|
||||
|
||||
Utilizzo:
|
||||
|
||||
```bash
|
||||
tex_to_md <input.tex> <output.md>
|
||||
```
|
||||
|
||||
Qui un esempio di utilizzo: [Argomenti di G2](https://git.phc.dm.unipi.it/lukefleed/domande-orali/src/branch/master/geoemtria-2)
|
||||
|
||||
- `parseunimap` — [@aziis98](https://git.phc.dm.unipi.it/aziis98) + [@alberto](https://git.phc.dm.unipi.it/alberto)
|
||||
|
||||
Script che converte il registro delle lezioni dell'Unipi in markdown
|
||||
|
||||
Installare:
|
||||
```bash
|
||||
bun init
|
||||
bun install jsdom
|
||||
bun install node-fetch
|
||||
```
|
||||
|
||||
Per eseguire:
|
||||
```bash
|
||||
bun run script.js <registro_link>
|
||||
```
|
||||
Una volta ottenuto in output il file markdown, è possibile convertirlo in pdf utilizzando ad
|
||||
esempio Pandoc tramite il comando
|
||||
|
||||
```bash
|
||||
pandoc fileregistro.md -o fileregistro.pdf
|
||||
```
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import {createWriteStream} from 'fs';
|
||||
import {JSDOM} from "jsdom";
|
||||
import fetch from "node-fetch";
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const url = process.argv[2];
|
||||
if (!url) {
|
||||
console.error("Usage: node script.js <registro_link>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const response =
|
||||
await fetch(url, {headers : {"User-Agent" : "Mozilla/5.0"}});
|
||||
const buffer = await response.arrayBuffer();
|
||||
const isoHtml = Buffer.from(buffer, "binary").toString("latin1");
|
||||
|
||||
const dom = new JSDOM(isoHtml);
|
||||
const document = dom.window.document;
|
||||
|
||||
let ol = document.querySelector("ol");
|
||||
if (!ol) {
|
||||
console.error("No <ol> found on the page");
|
||||
return;
|
||||
}
|
||||
|
||||
ol.querySelectorAll("a, i").forEach(el => el.remove());
|
||||
|
||||
const results = [...ol.children ]
|
||||
.map(li => li.textContent.match(/\w+:(.+)/sm))
|
||||
.filter(match => match)
|
||||
.map(match => match[1].trim())
|
||||
.map((x, index) => (index + 1) + ". " + x + " \n");
|
||||
|
||||
const writeStream = createWriteStream("registro.md")
|
||||
const pathName = writeStream.path;
|
||||
writeStream.on('error', function(err) { /* error handling */ });
|
||||
const head = "# Registro delle lezioni \n\n";
|
||||
writeStream.write(head)
|
||||
results.forEach(value => writeStream.write(`${value}`));
|
||||
// the finish event is emitted when all data has been flushed from the
|
||||
// stream
|
||||
writeStream.on(
|
||||
'finish',
|
||||
() => { console.log(`Registro salvato nel file ${pathName}`); });
|
||||
|
||||
// handle the errors on the write process
|
||||
writeStream.on(
|
||||
'error',
|
||||
(err) => {console.error(
|
||||
`There is an error writing the file ${pathName} => ${err}`)});
|
||||
|
||||
// close the stream
|
||||
writeStream.end();
|
||||
} catch (error) {
|
||||
console.error("Error fetching or processing page:", error);
|
||||
}
|
||||
})();
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create the pdf folder if it doesn't exist
|
||||
mkdir -p pdf
|
||||
|
||||
# Iterate through all .pptx files in the current folder
|
||||
for file in *.pptx; do
|
||||
if [ -f "$file" ]; then
|
||||
# Extract the base name (without extension) of the file
|
||||
base_name=$(basename "$file" .pptx)
|
||||
|
||||
# Convert the .pptx file to .pdf and save it in the pdf folder
|
||||
libreoffice --headless --convert-to pdf --outdir pdf "$file"
|
||||
|
||||
echo "Converted $file to pdf/$base_name.pdf"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Conversion complete!"
|
||||
|
||||
@@ -40,11 +40,11 @@ Opzioni disponibili:
|
||||
|
||||
Ad esempio:
|
||||
|
||||
$(basename "$0") ~/GAAL.pdf
|
||||
$(basename "$0") -u n.cognome ~/GAAL.pdf
|
||||
|
||||
$(basename "$0") alg2.pdf commRingTheory.pdf
|
||||
$(basename "$0") -u n.cognome alg2.pdf commRingTheory.pdf
|
||||
|
||||
$(basename "$0") --cli '-o sides=two-sided-short-edge' MR-impaginato.pdf
|
||||
$(basename "$0") -u n.cognome --cli '-o sides=two-sided-short-edge' MR-impaginato.pdf
|
||||
|
||||
N.B.: L'opzione --cli usa le opzioni necessarie per poter stampare un file
|
||||
creato con lo script "impagina", per rilegare le dispense a libretto in A5.
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ set -xeo pipefail
|
||||
# Variables
|
||||
APP=Steam-x86_64.AppImage
|
||||
NAME=steam
|
||||
URL="https://github.com/ivan-hc/Steam-appimage/releases/download/continuous/Steam-202401100234-x86_64.AppImage"
|
||||
URL="https://github.com/ivan-hc/Steam-appimage/releases/download/continuous/Steam-202402170551-x86_64.AppImage"
|
||||
LOCAL_BIN_DIR=$HOME/.local/bin
|
||||
DESKTOP_DIR=$HOME/.local/share/applications
|
||||
|
||||
@@ -17,13 +17,13 @@ fi
|
||||
|
||||
# Install Steam AppImage
|
||||
cd /tmp
|
||||
curl -LO $URL
|
||||
curl -L $URL -o $APP
|
||||
chmod +x $APP
|
||||
./$APP --appimage-extract
|
||||
mv squashfs-root $HOME/$NAME
|
||||
|
||||
# Create symbolic link to AppRun
|
||||
ln -sf $(realpath $HOME/$NAME/AppRun) $LOCAL_BIN_DIR/$NAME
|
||||
ln -sf "$(realpath $HOME/$NAME/AppRun)" $LOCAL_BIN_DIR/$NAME
|
||||
|
||||
# Install desktop entry
|
||||
desktop-file-install --dir="$DESKTOP_DIR" $HOME/$NAME/$NAME.desktop
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 input.tex output.md"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
input_file="$1"
|
||||
output_file="$2"
|
||||
|
||||
# Funzione per convertire le sezioni
|
||||
convert_section() {
|
||||
local level=$1
|
||||
local name=$2
|
||||
echo -e "$(printf '#%.0s' $(seq 1 $level)) $name\n" >> "$output_file"
|
||||
}
|
||||
|
||||
# Funzione per convertire definizioni, teoremi e proposizioni
|
||||
convert_definition_or_theorem_or_proposition() {
|
||||
local type=$1
|
||||
local name=$2
|
||||
if [[ $type == "teorema" || $type == "proposizione" ]]; then
|
||||
echo "* [ ] [**$type**] $name" >> "$output_file"
|
||||
else
|
||||
echo "* [ ] [$type] $name" >> "$output_file"
|
||||
fi
|
||||
}
|
||||
|
||||
# Inizializza il file di output
|
||||
> "$output_file"
|
||||
|
||||
# Leggi il file .tex e converti le sezioni, definizioni, teoremi e proposizioni
|
||||
while IFS= read -r line; do
|
||||
if [[ $line =~ \\section\{(.+)} ]]; then
|
||||
convert_section 1 "${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ \\subsection\{(.+)} ]]; then
|
||||
convert_section 2 "${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ \\subsubsection\{(.+)} ]]; then
|
||||
convert_section 3 "${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ \\begin\{definition\}\[(.+)\] ]]; then
|
||||
convert_definition_or_theorem_or_proposition "definizione" "${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ \\begin\{theorem\}\[(.+)\](\{.+})? ]]; then
|
||||
convert_definition_or_theorem_or_proposition "teorema" "${BASH_REMATCH[1]}"
|
||||
elif [[ $line =~ \\begin\{proposition\}\[(.+)\] ]]; then
|
||||
convert_definition_or_theorem_or_proposition "proposizione" "${BASH_REMATCH[1]}"
|
||||
fi
|
||||
done < "$input_file"
|
||||
Reference in New Issue
Block a user