From 59e38ea466931f77a77a2c1bb3d72fa75fe1a1a1 Mon Sep 17 00:00:00 2001 From: "taha@mkem" Date: Fri, 6 Dec 2013 17:36:29 +0100 Subject: [PATCH] Added date information to end of chertex.sh output. --- .gitignore | 2 ++ chertex.sh | 19 ++++++++----- chrome-with-tabs.sh | 12 +++++++++ pdf2pocket.sh | 33 +++++++++++++++++++++++ pdf2readability.sh | 30 +++++++++++++++++++++ sendfromgmail.py | 66 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 156 insertions(+), 6 deletions(-) create mode 100755 chrome-with-tabs.sh create mode 100755 pdf2pocket.sh create mode 100755 pdf2readability.sh create mode 100644 sendfromgmail.py diff --git a/.gitignore b/.gitignore index 4af854e..9289c15 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ pdfcrop unborn/ documentation/ PlotDigitizer.jar +jpeglib.h +nbconvert/ diff --git a/chertex.sh b/chertex.sh index f081ab1..34d6a13 100755 --- a/chertex.sh +++ b/chertex.sh @@ -57,7 +57,7 @@ if [ $# -eq 1 ]; then fi # Introducing a short delay to enable on-screen reading of previous echo - simpledelay.sh 2 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 2 echo "Delay completed" ## Handle knitr or pgfSweave jobs separately @@ -81,7 +81,7 @@ if [ $# -eq 1 ]; then echo " -----------------------" echo " Rscript knitr completed" echo " -----------------------" - simpledelay.sh 4 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 4 else # Run pgfSweave commands echo " ---------------------------" @@ -99,7 +99,7 @@ if [ $# -eq 1 ]; then echo " -------------------------" echo " R CMD pgfsweave completed" echo " -------------------------" - simpledelay.sh 4 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 4 fi # Run vc script if vc exists in working directory @@ -111,11 +111,11 @@ if [ $# -eq 1 ]; then # Run pdflatex, bibtex, and company if $ltxmkrc; then echo " Calling LaTeXMK with RC file" - simpledelay.sh 2 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 2 latexmk -r .latexmkrc -pdf -bibtex $jobname else echo " Calling LaTeXMK" - simpledelay.sh 2 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 2 latexmk -pdf -bibtex $jobname fi @@ -173,7 +173,7 @@ else for tikzfiles in "$tikzfiles"; do tikzfilenumber=${#tikzfiles}; done echo "cheRTeX detected $tikzfilenumber TikZ files for processing" echo "Starting TikZ file processing..." - simpledelay.sh 2 + /home/taha/chepec/chetex/common/bash/simpledelay.sh 2 for tikzfilename in $tikzfiles; do # Call tikz2pdf @@ -253,4 +253,11 @@ else exit 1 fi + +echo "------------------------------------" +echo "=== sample-matrix.sh completed ===" +echo "=== $(date) ===" +echo "------------------------------------" +/home/taha/chepec/chetex/common/bash/simpledelay.sh 10 + exit 1 diff --git a/chrome-with-tabs.sh b/chrome-with-tabs.sh new file mode 100755 index 0000000..c0c5a0e --- /dev/null +++ b/chrome-with-tabs.sh @@ -0,0 +1,12 @@ +#!/bin/bash +## Start Chrome with multiple tabs (Gmail, RTM, etc.) +## Written Oct 12, 2013 +## Taha Ahmed + +a="https://mail.google.com" +b="https://rememberthemilk.com" +c="https://chepec.timetask.com" + +google-chrome $a $b $c + +exit 1 diff --git a/pdf2pocket.sh b/pdf2pocket.sh new file mode 100755 index 0000000..026baa5 --- /dev/null +++ b/pdf2pocket.sh @@ -0,0 +1,33 @@ +#!/bin/bash +## Convert PDF to text and send to Pocket +## Written Nov 24, 2013 +## Taha Ahmed + +# Usage: +# pdf2pocket.sh worthreading.pdf +# Note: requires python and the python script "sendfromgmail.py" + + +pdffile=$1 +# Filename without extension part +jobname=${pdffile%.*} +txtfile=$jobname.txt +htmlfile=$jobname.html + + +# convert PDF to txt (saved in the current directory) +# it seems txt works better than HTML (Pocket cannot reformat HTML files for reasons unknown to me...) +pdftotext $pdffile + + +# copy the created file to my Dropbox public folder +cp $txtfile /home/taha/Dropbox/Public/$txtfile + + +# construct the corresponding Dropbox public URL +htmlurl="https://dl.dropboxusercontent.com/u/47462551/$txtfile" + + +# email url of htmlfile in public Dropbox to Pocket +python ~/chepec/chetex/common/bash/sendfromgmail.py "add@getpocket.com" "dropbox2pocket" "$htmlurl" + diff --git a/pdf2readability.sh b/pdf2readability.sh new file mode 100755 index 0000000..ae14766 --- /dev/null +++ b/pdf2readability.sh @@ -0,0 +1,30 @@ +#!/bin/bash +## Convert PDF to text and send to Readability +## Written Nov 6, 2013 +## Taha Ahmed + + +pdffile=$1 +# Filename without extension part +jobname=${pdffile%.*} +txtfile=$jobname.txt +htmlfile=$jobname.html +#outfile=$jobname + +# saves a HTML file in the current directory +pdftotext -htmlmeta $pdffile + +# remove newlines from txtfile +#tr -d "\n" < $txtfile > + +# copy the created txtfile to dropbox public folder +# and rename it to *.HTML +cp $htmlfile /home/taha/Dropbox/Public/$htmlfile + +# construct the corresponding Dropbox public URL +htmlurl="https://dl.dropboxusercontent.com/u/47462551/$htmlfile" + +# email url of htmlfile on dropbox to readability +#mail -s "dropbox2readability" chepec+simms@inbox.readability.com <<< $txturl +mail -t "chepec+simms@inbox.readability.com" -s "dropbox2readability" <<< $htmlurl + diff --git a/sendfromgmail.py b/sendfromgmail.py new file mode 100644 index 0000000..e0500ab --- /dev/null +++ b/sendfromgmail.py @@ -0,0 +1,66 @@ +#!/usr/bin/python +import os, re +import sys +import smtplib + +# I have commented out the parts that allow sending of attachments... +# I got this code from user hakermania at http://ubuntuforums.org/showthread.php?t=1472520 + +#from email.mime.image import MIMEImage +from email import encoders +from email.mime.multipart import MIMEMultipart +from email.mime.base import MIMEBase +from email.MIMEText import MIMEText + + +SMTP_SERVER = 'smtp.gmail.com' +SMTP_PORT = 587 + + +sender = 'taha.sol@gmail.com' +password = "OKWS:pled2XO" +recipient = sys.argv[1] +subject = '' +message = sys.argv[3] + +def main(): + msg = MIMEMultipart() + msg['Subject'] = sys.argv[2] + msg['To'] = recipient + msg['From'] = sender + + + part = MIMEText('text', "plain") + part.set_payload(message) + msg.attach(part) + + session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) + + session.ehlo() + session.starttls() + session.ehlo + + session.login(sender, password) + + #fp = open(sys.argv[4], 'rb') + #msgq = MIMEBase('audio', 'audio') + #msgq.set_payload(fp.read()) + #fp.close() + # Encode the payload using Base64 + #encoders.encode_base64(msgq) + # Set the filename parameter + #filename=sys.argv[4] + #msgq.add_header('Content-Disposition', 'attachment', filename=filename) + #msg.attach(msgq) + # Now send or store the message + qwertyuiop = msg.as_string() + + + + session.sendmail(sender, recipient, qwertyuiop) + + session.quit() + os.system('notify-send "Email sent"') + +if __name__ == '__main__': + main()