Hacking on Empty

eat something, you'll feel better

Archive for the ‘tricks’ Category

Background OCR with ScanSnap / ABBYY FineReader on Mac

with one comment

I got a Fujitsu ScanSnap 1500M in an attempt to take control of the paper in my life.  The software it comes with is tolerable.  However, the biggest annoyance is if you set it for automatic OCR, you have to wait for the OCR to finish before you can continue scanning.  The scanner is much faster than the OCR, which only uses a single core even on a multi-page document.

It is easy to setup a Finder Folder Action to have the OCR happen automatically in the background so you can continue scanning.  The downsides: you must setup a folder action for every folder and you can’t move the PDF until the OCR process is done.  Also, the UI for setting up folder actions is crap.

Put the following AppleScript into a file called “OCR.scpt” and put it in “~/Library/Scripts/Folder Action Scripts.” Then right click a folder in the Finder and choose “Folder Actions Setup” and assign this script to any folder which you want incoming PDFs to get OCR’d.

Written by hackingonempty

2011/04/13 at 4:13 pm

Posted in tricks

BitTorrent InfoHash to Magnet URI Service on OSX

leave a comment »

Some public torrent sites display on a torrent detail page an “infohash,” a SHA1 hash that uniquely identifies a Torrent, in hex format. An example would be “ffcbc1ea9ec0bc557f8fa42e673cdda0aea4d7e7.” Some sites provide a “magnet” URI that lets you download the torrent without a torrent file, possibly without a tracker. Magnet URIs for BitTorrent simply contain the infohash in a different encoding and look like this: “magnet:?xt=urn:btih:77F4D2U6YC6FK74PUQXGOPG5UCXKJV7H”

The cool thing about a magnet URI is it will let you download a torrent without using any trackers or conveniently send a torrent to someone else in a tweet or email. The client will go to the DHT and download the torrent file from other peers and not use a tracker.  Some sites don’t publish the magnet URI but do show the infohash.  For those you can convert the infohash to a magnet URI.  It won’t work for “private” torrents because most clients won’t announce their contact information to the DHT for those.

If you’re on a Mac, it’s easy to use Automator to create a Service menu item that will take an infohash selected in any application, turn it into a magnet URI, and put it back on the pasteboard. Then you just have to go to your favorite BT client and open it.  Some clients will automatically grab whats on the pasteboard for you.

  1. Open Automator and use the Service template.
  2. Add a “Run Shell Script” action from Library > Utilities
  3. Make sure “Shell: /bin/bash” and “Pass Input: to stdin” is set
  4. Paste in this code:

    python -c "import sys;import base64;sys.stdout.write('magnet:?xt=urn:btih:%s' % base64.b32encode(sys.argv[1].decode('hex')))" $@ | pbcopy

  5. Save as “To Magnet” or whatever

Now you can select an infohash in a browser or wherever (copy is not necessary,) go to the Services menu, and hit “To Magnet.”  Then just paste your magnet URI into your torrent client or wherever necessary!

    Written by hackingonempty

    2011/04/07 at 1:02 am

    Posted in tricks

    Tagged with , , , ,

    Design a site like this with WordPress.com
    Get started