From Google Books to PDF lickety-split!

So I got a Kindle for Xmas and wanted to start sticking some content on it. Google Books has some gems (some in full!) so i have just figure out this process of getting them into PDF format and then onto my Kindle. I use PDF as you get images from Google Books and not text. Somebody might wan to find a command line image-to-text converter (OSC) and stick this in at the end of this process (depending on how keen you are). There are some large text books i would consider doing it to, but for now…

  1. Use Firefox with the GreaseMonkey add-on and the Google Book Downloader script to generate a list of links to all the page images
  2. This will genarete a long list of links, one for each page, so you can then use the FireFox add-on DownThemAll! to… downlaod them all…
    • create a folder for them all to live in
    • under “Fast filter” I entered “‘books?id=” to select the book page links
    • Set the “Renaming Mask” to “*text*” (less the quotes)
  3. This should give you a folder with all the book pages as images. To convert these to PDF you will need imagemagick installed (on the Mac i recommend using Homebrew to get this installed quickly). Simply crack open the terminal/command-line:
    cd /folder/with/the/downloaded/images
    and then:
    convert *.png mynewbook.pdf

…and your done!

If you have a eBook reader them you might want to import the PDF with Calibre and upload to your respective device.

Mass renaming files

Nice little shell one-liner to mass rename foo*.jpg to bar*.jpg

ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh

Leave off the last pipe to get a preview of the output first ;)

Heres a variation I used to keep just the first part of a file name before the first space (i.e. when Finder makes a copy of a file say)

l -1 *.jpg | awk '{print("mv \""$0"\" "$1".jpg")}' | /bin/sh

Recursively remove .DS_Store files

If your working on a coding project and your submitting it to version control, heres how to remove the meta-schmeg that OS X leaves around:

find . -name '*.DS_Store' -type f -delete

If your using GIT as your versioning control system then I’d suggest making a .gitignore file in the root of the project after running this command and before you git init to save yourself some bother.

Ruby on Rails on Mac OS X in 5 minutes

So I just discovered that Leopard comes with a version of Ruby on Rails (RoR) pre-installed. The only problem is its a bit dated but there is a command-line one-liner to update it all no sweat with RubyGem (the Ruby package manager):
Continue reading “Ruby on Rails on Mac OS X in 5 minutes”