Severe Weather Alert — Need to Raid Local Stores

winter-storm-advisoryWe are under a severe weather alert for our area of East Tennessee. We could get several inches of snow this week. Certainly nothing like the north eastern United States has gotten over the last couple of weeks. But, this is our first potential bad weather for the year.

The main problem is that we haven’t been to all the local stores and raided them of the essential supplies. Today is the day after Valentine’s Day and I know all the candy is on sale for half price. We haven’t made it to Walmart to stock up on these needed supplies.

If East Tennessee is anything like Florida where I lived for several years, then as soon as the advisory started hitting everyone’s weather apps on their phones they rushed out and bought all the milk and bread the stores had on the shelves. Likely they forgot the important complementary items to the milk and bread such as peanut butter. But as long as they leave the candy alone until I get a chance to buy my six-month supply, then I am OK with that. November 1 is when we buy the next 6 month’s worth of candy to round out our year.

[It is nice to know that there is a Red Cross Shelter in Columbus, OH in case we need immediate help. “Pile into the van kids. We are going to drive 6 hours through a winter storm to go to the closest Red Cross shelter for help!”]

2014 Reading Summary: Fiction

I am not much of a fiction reader. In fact, I was surprised to find out that I read 4 fiction books this year. Then I remembered the reading challenge we have at our library each year. Two of the fiction books I read this year were for the library contest. The other two were more research type books for me. I had read about Will Eisner’s book, Comics and Sequential Art, and wanted to know more about him. I was not impressed with his subject matter, but he did a good job with communicating through pictures and text. One thing about his work that I was impressed with was his use of text as pictures.

Fiction:

Genesis Force is a book from the Star Trek universe.

Understanding ComicsGoing Postal was clever and weird. The book was mostly good. It seemed that the author did a good job of not using profanity (which seems to bother me much more when I read it than when I hear it) in the first part of the book. He got around profanity by making up his own humorous words that conveyed a strong emotion but didn’t mean anything. But towards the end of the book he let it all out. Because of this, I’m not interested in reading another book by him.

I hate that participating in the library reading contest requires reading fiction. But I got a nice coffee mug out of it. 🙂

The Last Knight by Eisner was a retelling of Don Quixote.

The Contract With God (also by Eisner) was not worth flipping through. Because of the content I can’t recommend it in any way. And, furthermore, I am never interested in looking at another Eisner book. I did read Comics and Sequential Art later in the year. I should have just stuck with the two excellent Scott McCloud books about visual communication (Understanding Comics and Making Comics). He said everything Eisner said in a much more understandable and less offensive way. I did a review of the book Making Comics a few years ago.

2014 Reading Summary: Biographies

I probably won’t do a detailed review of many of the books I read last year, but I did want to at least list them in some way. This is the first in a series of 6 or 8 posts about the different categories of books I read.

In my book summary I said that I read 3 books in the Biography category. Here they are in the order that I read them.

Biographies:

The Mark Inside: A Perfect Swindle, a Cunning Revenge, and a Small History of the Big Con. This book by Amy Reading is about J. Frank Norfleet who was swindled by a con man in 1919 in a stock market scam. Not learning his lesson the first time, he got taken again. But, then he wised up and spent the next few years hunting down the gang that had taken his money. He did this by learning how the con worked and conning other con men to give him the information he needed to get his money back and put the perpetrators in jail.

Though I like biographies, I really like ones that teach about the business the protagonist is involved with. In this case it was about con artists and the police and detective work that went into catching the criminals. I really enjoyed the book and was glad to serendipitously run across it at the library new book shelf (which is where many of the books I read come from).

If you want to know a bit more about this story, there was an NPR story about it. The host interviewed author Amy Reading.


My Life on the Run: The Wit, Wisdom, and Insights of a Road Racing Icon by Bart Yasso. As expected, this book was well written. The reason I expected this is Mr. Yasso works for Runner’s World magazine. Even if he didn’t know how to write, Runner’s World has a great team of editors.

This book is a chronicle of his running life up to this point. He has run over 1000 races and competed on all seven continents of the world. Like many people who take up running as an adult, he was prompted to better his life and health due to poor choices made as a younger person. Running changed his life and has given him a purpose and a job for the last few decades.


Ghost in the Wires: My Adventures as the World’s Most Wanted Hacker. I have read another book by Mitnick, The Art of Deception, which was about how social engineering works and how he used it to his advantage to hack into many companies. This newer book, Ghost in the Wires, is more about his exploits of escaping the authorities during the manhunt for him.

I am not necessarily a fan of Mitnick or his choice of occupation, but like the book about the con artist ring from 100 years ago, I love learning the tricks of the trade. Mitnick is a con artist extraordinaire.

Mitnick did the majority of his illegal hacking in the days before the Internet and Windows computers as we know them. Much of what he does is social engineering where he convinces people to give him sensitive information by posing as a friendly co-worker. However, today, instead of doing this for illegal purposes, he is paid by the companies he is hacking into for the purpose of testing their internal security protocols.

PDF to TIFF to TXT: Bash Script Automation

A few weeks ago I started into a project to take a scanned PDF image and turn it into text. At the time I was doing this manually by taking the PDF file and converting it to a TIFF (image file) and then running that through tesseract-OCR engine to output a TXT file. Then I would do some regular expressions on the file to pull out manual line breaks that the OCR process stuck into the file.

Since I was taking a class in Python at the time I thought I would do this using Python. But when I actually started coding the steps, I realized that a bash script would do everything I needed and I already knew how to do most of it. So that is what I ended up with.

#!/bin/bash
if [ $# -lt 1 ]; then
        echo "Useage: $0 {file in.pdf}"
        exit
fi
if [ ! -f $1 ];then
        echo "Filename given $1 doesn't exist."
        exit
fi
convert -density 300 $1 -depth 8 $1.tiff
tesseract $1.tiff $1
cat $1.txt | tr '\n' '*'| sed 's/\*\*/^^/g'| sed 's/\*/ /g'| sed 's/\^\^/\n\n/g' > $1.converted.txt
rm $1.tiff
rm $1.txt

I will walk you through what I understand about it. I did get help with the regular expression (line 12) and mostly understand it. But here is a stab at helping you see what is going on. And, I am certainly willing for anyone to offer suggestions to make the script better.

To use the script you invoke it with the name of the script and then the name of the PDF like this: pdf2tiff2txt.sh filename.pdf

  • Line 1: This says that the script is a bash script.
  • Lines 2-5: A failsafe to tell the user that they need to type in the command for the script (my script is called pdf2tiff2txt.sh) and then the location of the PDF that is to be converted.
  • Lines 6-9: A failsafe that if a non-existent file name is given then the user knows the file does not exist in the location they indicated.
  • Line 10: Converts the input file into a TIFF with a resolution of 300 dpi and an 8-bit color depth. It also outputs the original file name with a .tiff extension.
  • Line 11: Uses the tesseract OCR engine to convert the file from an image to a text file. The .txt file extension is automatically added by tesseract.
  • Line 12: The magical regex line. All carriage returns are converted to asterisks. Then double asterisks are converted to double beginning lines. Single asterisks are converted to spaces. The double beginning lines are converted to double carriage returns. Finally the new file is output as the original file name plus .converted.txt.
  • Lines 13 and 14: Deletes the intermediary files that were created. I don’t ever have need for these so I can safely delete them. This is the section where I think my script could be improved. I would guess there is a way to create the intermediary files as temporary files that get automatically deleted as soon as they are used.

I am currently using this in production and it does exactly what I need. I am very pleased with the output and want to thank my friend Brett for his help with the regex and the failsafe lines.