diff --git a/dotfiles/scripts.org b/dotfiles/scripts.org index 97b8bbf..d0155aa 100644 --- a/dotfiles/scripts.org +++ b/dotfiles/scripts.org @@ -38,6 +38,8 @@ Then take a screenshot and process it. #+begin_src bash temp_file="/tmp/screen.png" + rm -f $temp_file + scrot $temp_file convert $temp_file -scale 10% -scale 1000% $temp_file #+end_src @@ -92,7 +94,8 @@ The requirement is to have =pdftk= installed. #+begin_src bash if [[ -f $1 && $1 == *.pdf ]]; then # Argument if a file - pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1" + # pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1" + stapler del "$1" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1" fi #+end_src @@ -137,7 +140,7 @@ Things to do: - [ ] Display the not found figures #+begin_src bash :results output - latexpath="$HOME/MEGA/These/LaTeX/ressources/Figures"; + latexpath="$HOME/Cloud/thesis/latex/ressources/Figures"; figures=`awk 'match($0, /(fig.*\.(png|svg|pdf))/, a) {print a[1];}' $1 \ | awk '{ print gensub(/\s*\]\]\s*\|\s*\[\[\s*\.?\/?/, "\n", "g") }'`; @@ -172,31 +175,7 @@ Things to do: #+end_src #+RESULTS: -#+begin_example -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_alt.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_2dof_alt.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_sep.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_bis.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_names.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_plant_weights.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Mdelta.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_stability.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/classical_feedback_meas.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_output_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set_feedback.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inverse_uncertainty_set.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_delta.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Ndelta.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/general_control_Mdelta.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/additive_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/output_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_additive_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_input_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/inv_output_uncertainty.pdf -/home/tdehaeze/MEGA/These/LaTeX/ressources/Figures/input_uncertainty_set_feedback_weight.pdf -#+end_example + * NAS ** Mount :PROPERTIES: @@ -315,3 +294,209 @@ else setsid nohup youtube-dl --add-metadata -ic $1 &> /dev/null & fi #+end_src +* Org-Protocol-Capture-HTML +:PROPERTIES: +:header-args: :tangle ~/scripts/org-protocol-capture-html.sh +:header-args+: :comments both :mkdirp yes +:header-args+: :shebang "#!/usr/bin/env bash" +:END: + +Defaults +#+begin_src bash + heading="link" + template="pu" + url="https://google.com/" +#+end_src + +Functions +#+begin_src bash + function debug { + if [[ -n $debug ]] + then + function debug { + echo "DEBUG: $@" >&2 + } + debug "$@" + else + function debug { + true + } + fi + } + function die { + echo "$@" >&2 + exit 1 + } + function urlencode { + python -c " + from __future__ import print_function + try: + from urllib import quote # Python 2 + except ImportError: + from urllib.parse import quote # Python 3 + import sys + print(quote(sys.stdin.read()[:-1], safe=''))" + } +#+end_src + +Documentation +#+begin_src bash + function usage { + cat <&2 + cp "$1" "$2" + fi + } + + usage () + { + echo "Reduces PDF filesize by lossy recompressing with Ghostscript." + echo "Not guaranteed to succeed, but usually works." + echo " Usage: $1 infile [outfile] [resolution_in_dpi]" + } + + IFILE="$1" + + # Need an input file: + if [ -z "$IFILE" ]; then + usage "$0" + exit 1 + fi + + # Output filename defaults to "-" (stdout) unless given: + if [ ! -z "$2" ]; then + OFILE="$2" + else + OFILE="-" + fi + + # Output resolution defaults to 72 unless given: + if [ ! -z "$3" ]; then + res="$3" + else + res="90" + fi + + shrink "$IFILE" "$OFILE" "$res" || exit $? + + check_smaller "$IFILE" "$OFILE" +#+end_src