Sunday, December 6, 2015

PDF to Images and Text

For a while now I have extracted text from financial statements and imported it into Excel for further accounting. The statements are PDF documents and until recently it was relatively easy to use the Adobe Reader "Save as Text..." feature to save the text content.  For my latest statement this didn't work. It appears the PDF documents no longer contain "text", but rather vector paths are to render the text instead. I have no idea why they decided to change the format?!

Anyway, to deal with this new format I had to change my approach for getting the data into Excel. With the help of this page Tutorial: Command-line OCR on a Mac I was able to build a process to do the following:
  1. Use pdftk to burst the multi-page PDF into single-page files.
  2. Use inkscape to convert each page into a PNG file.
  3. Use Tesseract to OCR these image files into text.
  4. Extract and format the text files for import into Excel.
Note that at the time of writing there are some issues running pdftk the latest version of OS X. Fortunately this has been fixed as detailed in this post: PDFtk Server on OS X 10.11.

Saturday, November 21, 2015

GPS Maps from Windows to Mac

GPS maps may come as windows ".exe" file that can be used to install the maps on a Windows OS. Once installed it's quite easy to convert them to the ".gmapi" format needed for Mac OS.

So, here is how I converted the ".exe" maps to ".gmapi" file for Mac OS:

- Using a Virtual Box with a Windows XP image, run the maps.exe file to install the BaseCamp/MapSource maps. Note that MapSource/BaseCamp don't actually need to be installed.

- Download and install the Garmin MapConverter from: http://www8.garmin.com/support/download_details.jsp?id=3897. Note that to run the MapConverter, I also needed to install MS Visual C++ from: http://www.microsoft.com/en-us/download/details.aspx?id=5638

- Run MapConverter to generate the maps.gmapi file/folder. Copy the folder to the Mac and double click to open it in MapManager and install the maps.

The maps should now be accessible in  BaseCamp and available to MapManager. This is especially useful when you want to load and SD card with a specific set of maps.

Note that  GPS maps often come as a single Garmin ".img" file that is intended to be loaded directly onto a GPS device. While BaseCamp can read these files from a mounted SD card, disk image, or GPS device, only maps that you have "installed" on your computer will show up in MapManager and be accessible to MapInstall. I have found no easy way to convert or load ".img" files to "installed" maps.

Friday, November 20, 2015

Raspberry Pi Camera Commands

Useful commands to get started:

To take a photo:

raspistill -o cam.jpg

From the documentation.

To save a 5 second raw h264 encoded video file:

raspivid -o vid.h264

From RASPICAM Commands.

To wrap it in an mp4 from easier playback:

sudo apt-get install gpac MP4Box -add vid.h264 vid.mp4 

From this post.

Sunday, November 1, 2015

Raspberry Pi SD Card Not Booting

If you connect the power and the red power light turns on, but the green activity light does not flash it means the SD card isn't booting. If the card if setup correctly, it maybe a bad connection between the card and the holder. Try applying pressure to the card while reconnecting the power to see if the activity light flashes green.

If your SD card is loose, try applying a few layers of tape to the top of the card and carefully reinserting it into the slot. The tape may add enough pressure to improve the SD card connection.

Saturday, July 25, 2015

Mac Color Syntax in Vi

Add the following to your ~/.vimrc file:

type plugin indent on 
syntax on 
 
Next time you open a file using vi, syntax colors will be used.

 

Thursday, May 7, 2015

Search bash History for All Users

To search bash history for all users, for a given command:

find /home/ -name .bash_history -type f -exec grep -H $cmd {} \; | more 

Thursday, April 9, 2015

Firefox Console XPath Query

To find a page element using an xpath from the Firefox (Firebug) console, use:

$x("//your/path/here")

Sunday, March 22, 2015

Windows 7 Custom Text Size

To set a Custom text size in Windows 7, open Control Panel -> Display -> Set custom text size (DPI), and drag the scale.


Sunday, March 15, 2015

CT30 Thermostat Wifi Setup

This was harder than it should be. The process that finally worked was something like this:

- Disable cellular data on iPhone
- Forget wireless network on iPhone
- Press the Menu button on thermostat, press Mate twice, ensure yellow light is flashing
- Connect to thermostat wifi network on iPhone
- Go to http://192.168.10.1/ in browser on iPhone
- Follow the 5 steps and enter requested details: wifi network, wifi password, provisioning code
- If you're lucky, the thermostat chirps and then green light flashes

It seemed like the iPhone had trouble staying on the thermostats network and the provisioning process kept timing out.

I had a lot of trouble getting the browser to connect, for more details, see this FAQ:


Tuesday, February 17, 2015

Convert Tokenized BBC Basic to Plain Text

Use the BBCBasicToText python script from https://github.com/tom-seddon/beeb

For example, to convert a directory of files:
for file in `ls $dir`
do
 txt=`echo $file | sed 's/,ffb/.txt/g' `
 if [[ $txt == *".txt"* ]]; then
  echo $txt
  python BBCBasicToText.py $dir/$file > out/$txt
 fi
done