commit 9669b1014cf1c40f5931b25e522c441fb06d14c1
parent 004e5010ab9af8874381b767ce68ef5a4263af3b
Author: Antoine Amarilli <a3nm@a3nm.net>
Date: Mon, 18 Jul 2016 11:53:39 +0200
Merge branch 'master' of a3nm.net:git/mybin
Diffstat:
7 files changed, 89 insertions(+), 15 deletions(-)
diff --git a/addmathjax b/addmathjax
@@ -2,29 +2,40 @@
TEMP=$(mktemp)
+CACHEDIR="$HOME/temp/addmathjax.cache"
+mkdir -p "$CACHEDIR"
+
# a3nm-mathjax-testing follows a base debian image and included config
# and a container must have been created with
# sudo docker run -di --name=a3nm-mathjax-testing \
# a3nm-mathjax-testing bash
-if ! sudo docker ps | grep '\sa3nm-mathjax-testing$' > /dev/null
-then
- sudo docker start a3nm-mathjax-testing >/dev/null || {
- echo "cannot start the mathjax container" >&2; exit 3;
- }
-fi
+#if ! sudo docker ps | grep '\sa3nm-mathjax-testing$' > /dev/null
+#then
+# sudo docker start a3nm-mathjax-testing >/dev/null || {
+# echo "cannot start the mathjax container" >&2; exit 3;
+# }
+#fi
cat > $TEMP
-
if grep -E "class=\"math\"|class=\"tex\"" $TEMP > /dev/null
then
# expensive processing
- TEMP2=$(mktemp)
- sudo docker exec -i a3nm-mathjax-testing node_modules/mathjax-node/bin/page2html \
- --fontURL "https://a3nm.net/mathjax/fonts/HTML-CSS" <$TEMP >$TEMP2 || \
- { echo "cannot run mathjax" >&2; exit 2;}
- sed 's,<style id="MathJax_CHTML_styles">undefined</style>,,g' "$TEMP2" |
- sed 's,<span class="mjx-char"></span>,,g'
- rm -f "$TEMP2"
+ SHA=$(sha1sum < $TEMP | cut -d ' ' -f1)
+ if [ -f "$CACHEDIR/$SHA" ]
+ then
+ # already cached
+ cat "$CACHEDIR/$SHA"
+ else
+ TEMP2=$(mktemp)
+ #sudo docker exec -i a3nm-mathjax-testing node_modules/mathjax-node/bin/page2html \
+ ~/apps/MathJax-node/bin/page2html \
+ --fontURL "https://a3nm.net/mathjax/fonts/HTML-CSS" <$TEMP >$TEMP2 || \
+ { echo "cannot run mathjax" >&2; exit 2;}
+ sed 's,<style id="MathJax_CHTML_styles">undefined</style>,,g' "$TEMP2" |
+ sed 's,<span class="mjx-char"></span>,,g' >$CACHEDIR/$SHA
+ cat "$CACHEDIR/$SHA"
+ rm -f "$TEMP2"
+ fi
else
cat "$TEMP"
fi
diff --git a/bluetooth_connect b/bluetooth_connect
@@ -0,0 +1,12 @@
+set -e
+set -x
+HW="$1"
+ID=$(rfkill list | grep -i hci0 | cut -d':' -f1)
+rfkill unblock 2
+echo "power on
+default-agent
+pairable on
+scan on
+pair $HW
+trust $HW
+connect $HW" | bluetoothctl -a
diff --git a/btrfs_incremental_send b/btrfs_incremental_send
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# send all subvolumes incrementally from SOURCE to DEST
+
+set -e
+
+SOURCE="$1"
+DEST="$2"
+
+paste <(ls "$SOURCE" ) <(ls "$SOURCE" | sed 1d) | sed '$d' |
+while read l; do
+ PARENT=$(echo "$l" | cut -f1);
+ VOLUME=$(echo "$l" | cut -f2);
+ if [ ! -d "$DEST/$VOLUME" ]
+ then
+ if [ ! -d "$DEST/$PARENT" ]
+ then
+ echo "putative parent $DEST/$PARENT does not exist on destination!"
+ exit 2
+ fi
+ echo "[($SOURCE/$PARENT) $SOURCE/$VOLUME => $DEST/$VOLUME]"
+ sudo btrfs send -p "$SOURCE/$PARENT" "$SOURCE/$VOLUME" |
+ pv | sudo btrfs receive "$DEST"
+ fi
+done
+
diff --git a/checkhtml5 b/checkhtml5
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+if ! sudo docker ps | grep '\sa3nm-tidy-html5-testing$' > /dev/null
+then
+ sudo docker start a3nm-tidy-html5-testing >/dev/null || {
+ echo "cannot start the tidy container" >&2; exit 3;
+ }
+fi
+
+docker exec -i a3nm-tidy-html5-testing /usr/local/bin/tidy \
+ --doctype html5 -utf8 -errors -quiet
+
diff --git a/clip b/clip
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# transfer selection to X clipboard
+
+xclip -o | xclip -i -selection clipboard
+
diff --git a/rsync-no-vanished b/rsync-no-vanished
@@ -3,13 +3,15 @@
# https://bugzilla.samba.org/show_bug.cgi?id=10356
# support/rsync-no-vanished
+# also disable controlmaster to silence warnings
+
IGNOREEXIT=24
IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'
set -o pipefail
-rsync "${@}" 2>&1 | (egrep -v "$IGNOREOUT" || true)
+rsync -e "ssh -o ControlPath=/nowhere -o ControlMaster=no" "${@}" 2>&1 | (egrep -v "$IGNOREOUT" || true)
ret=$?
if [[ $ret == $IGNOREEXIT ]]; then
diff --git a/startup b/startup
@@ -1,5 +1,7 @@
#!/bin/bash
+~/bin_private/fix_gamma
+
~/bin_private/proxy.sh
~/bin/notmuch-new.sh &
urxvtd &
@@ -10,6 +12,8 @@ nm-applet &
rm ~/temp/terminals
~/bin/layout
~/bin/kiwix
+# pulseaudio cannot start by itself due to the uncommon socket folder
+pulseaudio &
if [ `whoami` = a3nm ]
then
COLOR="#000000"
@@ -32,4 +36,5 @@ done
xhost +si:localuser:browser
xhost +si:localuser:browser2
xhost +si:localuser:bitcoin
+xhost +si:localuser:browser_tor