Compare commits

..

No commits in common. "e39b3dac309b340dfc716f85cbf4b2099228ba9d" and "f94b0ab07e9aa67c5969a055d766cac1636228f6" have entirely different histories.

6 changed files with 14 additions and 46 deletions

3
.gitignore vendored
View file

@ -1,3 +1,2 @@
/.pre-commit-config.yaml
__pycache__
wordclock_credentials.py
__pycache__

6
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
language_version: python3

View file

@ -1,11 +0,0 @@
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;
};
};
}

View file

@ -1,10 +1,4 @@
#!/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)
cd $tmpdir
@ -25,7 +19,7 @@ $(cat $OLDPWD/$1)
\end{document}
EOF
xelatex doc.tex
lualatex doc.tex
mutool draw -o doc.svg doc.pdf
inkscape -D -A doc.pdf doc.svg
mutool draw -r 600 -o $OLDPWD/${1}.png doc.pdf

View file

@ -1,24 +0,0 @@
#!/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)

View file

@ -2,9 +2,13 @@
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nixpkgs-fmt
gitAndTools.pre-commit
(python3.withPackages(ps: [ ps.virtualenv ]))
];
shellHook = ''
${(import ./default.nix).pre-commit-check.shellHook}
# blacks pre-commit hook builds a wheel (zip file) for black and fails
# when the timestamp is lower than 1980 (due to zip limitations)
export SOURCE_DATE_EPOCH=315532800
pre-commit install -f >/dev/null
'';
}