Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
2 total  XML / RSS feed 

pdftotext


# pdftotext is a command line program that converts PDF files into text files
# first get the pdftotext installer package from http://www.bluem.net/downloads/pdftotext_en/
# pdftotext code written by Glyph & Cog, LLC: http://www.glyphandcog.com/Xpdf.html

which pdftotext     # /usr/local/bin/pdftotext

pdftotext -h
pdftotext example.pdf
pdftotext example.pdf example.txt
pdftotext example.pdf -
pdftotext -layout -eol unix -enc UTF-8 /path/to/file.pdf /path/to/file.txt


snippet

Download code snippets (http://textsnippets.com) from the command line and convert them to text files using man textutil (on Mac OS X 10.4).

Usage:
snippet 345
snippet 1268
snippet 1281



# $ cat $HOME/.bash_login

function snippet() {
   mkdir -p $HOME/Desktop/Snippets
   OPWD="$PWD"
   cd $HOME/Desktop/Snippets
   curl -L -O -s --max-time 25 http://textsnippets.com/posts/show/"$1" || exit 1
   file="$HOME/Desktop/Snippets/$(basename $_)"
   textutil -convert txt "$file"
   rm "$file"
   new_file="$file.txt"
   sed -i "" -e '1,5d' -e 's/.See related posts.//' "$new_file"  # delete first 5 lines of file
   sed -i "" -e :a -e '1,6!{P;N;D;};N;ba' "$new_file"            # delete last 6 lines of file
   cd "$OPWD"
   return 0
}


« Newer Snippets
Older Snippets »
2 total  XML / RSS feed