From ef85917a7157b7580ef148256433306c511299d3 Mon Sep 17 00:00:00 2001 From: "taha@mkem" Date: Wed, 21 May 2014 17:01:12 +0200 Subject: [PATCH] Mainly updates to the way chertex.sh handles Shiny. --- chertex.sh | 16 ++++++++-------- findlines.sh | 14 ++++++++++++++ shiny-matrix.sh | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100755 findlines.sh diff --git a/chertex.sh b/chertex.sh index 3ae34bc..1d4102c 100755 --- a/chertex.sh +++ b/chertex.sh @@ -64,19 +64,19 @@ if [ $# -eq 1 ]; then #### Special treatment for sample-matrix.Rnw - # If $jobname is sample-matrix, run only knitr and markdown, then exit + # If $jobname is sample-matrix, restart Shiny and term this script if [[ $jobname == "sample-matrix" ]]; then - echo " -----------------------------------------------------------" - echo " sample-matrix: update SHINY, run knit() + markdownToHTML()" - echo " -----------------------------------------------------------" + echo " -------------------------------" + echo " sample-matrix: restarting Shiny" + echo " -------------------------------" - # Before starting new shiny process, kill any previous instances + # kill Shiny pkill -f "shiny::runApp" + # start Shiny bash -c "/home/taha/chepec/chetex/common/bash/shiny-matrix.sh" & - Rscript -e "library(knitr); knit(input='$jobname.Rmd', output='$jobname.md')" - Rscript -e "library(markdown); markdownToHTML('$jobname.md', '$jobname.html', stylesheet = 'custom.css')" + # terminate this script echo " Terminating..." - /home/taha/chepec/chetex/common/bash/simpledelay.sh 14 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 4 exit 1 fi diff --git a/findlines.sh b/findlines.sh new file mode 100755 index 0000000..b4abc79 --- /dev/null +++ b/findlines.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# http://tex.stackexchange.com/a/18776 +# The "holy imagemagick batman" answer :-) +# run this script like this: +# findlines.sh # without specifying file extension +# works for two-column pages, not so well for single-column + + +convert $1.pdf -crop 50x100% png:$1 + +for f in $1-*; do +convert $f -flatten -resize 1X1000! -black-threshold 99% -white-threshold 10% -negate -morphology Erode Diamond -morphology Thinning:-1 Skeleton -black-threshold 50% txt:-| \ +sed -e '1d' -e '/black/d' -e 's/^[^,]*,//' -e 's/[(]//g' -e 's/:.*//' -e 's/,/ /g' > $f.txt; +done diff --git a/shiny-matrix.sh b/shiny-matrix.sh index 8444926..06ea49f 100755 --- a/shiny-matrix.sh +++ b/shiny-matrix.sh @@ -21,7 +21,7 @@ echo $PORT > /home/taha/chepec/chetex/sample-matrix/shinyapp/shiny.port # Run R Shiny app at localhost port # Note: this process does not return control to bash... -nohup R -e "shiny::runApp('~/chepec/chetex/sample-matrix/shinyapp', port = $PORT)" +nohup R -e "shiny::runApp('/home/taha/chepec/chetex/sample-matrix/shinyapp', port = $PORT)"