Compare commits
3 commits
f94b0ab07e
...
e39b3dac30
Author | SHA1 | Date | |
---|---|---|---|
Simon Bruder | e39b3dac30 | ||
Simon Bruder | f8cf89b532 | ||
Simon Bruder | 7791a46986 |
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
||||||
wordclock_credentials.py
|
/.pre-commit-config.yaml
|
||||||
__pycache__
|
__pycache__
|
||||||
|
wordclock_credentials.py
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
repos:
|
|
||||||
- repo: https://github.com/psf/black
|
|
||||||
rev: stable
|
|
||||||
hooks:
|
|
||||||
- id: black
|
|
||||||
language_version: python3
|
|
11
default.nix
Normal file
11
default.nix
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
let
|
||||||
|
nix-pre-commit-hooks = import (builtins.fetchTarball "https://github.com/cachix/pre-commit-hooks.nix/tarball/master");
|
||||||
|
in
|
||||||
|
{
|
||||||
|
pre-commit-check = nix-pre-commit-hooks.run {
|
||||||
|
src = ./.;
|
||||||
|
hooks = {
|
||||||
|
black.enable = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,4 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
# shellception since nix-shell and shebang does not work with combining texlive
|
||||||
|
if ! command -v xelatex >> /dev/null; then
|
||||||
|
nix-shell -p 'texlive.combine { inherit (pkgs.texlive) scheme-small chemfig simplekv siunitx standalone varwidth; }' --run "$0 $@"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
tmpdir=$(mktemp -d)
|
tmpdir=$(mktemp -d)
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
|
|
||||||
|
@ -19,7 +25,7 @@ $(cat $OLDPWD/$1)
|
||||||
\end{document}
|
\end{document}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
lualatex doc.tex
|
xelatex doc.tex
|
||||||
mutool draw -o doc.svg doc.pdf
|
mutool draw -o doc.svg doc.pdf
|
||||||
inkscape -D -A doc.pdf doc.svg
|
inkscape -D -A doc.pdf doc.svg
|
||||||
mutool draw -r 600 -o $OLDPWD/${1}.png doc.pdf
|
mutool draw -r 600 -o $OLDPWD/${1}.png doc.pdf
|
||||||
|
|
24
quizlet2anki.py
Executable file
24
quizlet2anki.py
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i python3 -p python3
|
||||||
|
# I want to use Anki instead of Quizlet. However, Quizlet only provides a very
|
||||||
|
# limited “export” functionality, that exports something like csv, but does nut
|
||||||
|
# support quoting. So it will fail if your separation character is either your
|
||||||
|
# column or row separator (e.g. if you have multiple lines in one field).
|
||||||
|
|
||||||
|
# This script takes unquoted data with uncommon separators (|||||| for columns,
|
||||||
|
# \n------\n for rows) and exports it as a more usable csv (quoted, cols
|
||||||
|
# separated by \t, rows separated by \n)
|
||||||
|
import sys
|
||||||
|
|
||||||
|
outfile = sys.argv[1]
|
||||||
|
|
||||||
|
quizlet_output = sys.stdin.read()
|
||||||
|
|
||||||
|
maybe_tsv = (
|
||||||
|
'"' + quizlet_output.replace("||||||", '"\t"').replace("\n------\n", '"\n"') + '"'
|
||||||
|
)
|
||||||
|
|
||||||
|
maybe_tsv = maybe_tsv[:-2]
|
||||||
|
|
||||||
|
with open(outfile, "w") as f:
|
||||||
|
f.write(maybe_tsv)
|
|
@ -2,13 +2,9 @@
|
||||||
|
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [
|
nativeBuildInputs = with pkgs; [
|
||||||
gitAndTools.pre-commit
|
nixpkgs-fmt
|
||||||
(python3.withPackages(ps: [ ps.virtualenv ]))
|
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# black’s pre-commit hook builds a wheel (zip file) for black and fails
|
${(import ./default.nix).pre-commit-check.shellHook}
|
||||||
# when the timestamp is lower than 1980 (due to zip limitations)
|
|
||||||
export SOURCE_DATE_EPOCH=315532800
|
|
||||||
pre-commit install -f >/dev/null
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue