github soundcloud
Going on a safari
Dec 9, 2018
4 minutes read

If you are working with computing and don’t have access to Safari Books Online, you are probably not going as fast as you can.

If you subscribe, you should change some habits.

  • Prefer it over Googling
  • Prefer it over StackOverflow and howdoi
  • Combine books with video courses
  • Search for libraries in (ie. pandas, urllib, argparse or logging) to see how professionals use them
  • Highlight and export your highlights
  • Work with your highlights in a Jupyter notebook and ultimately upload the notebooks to GitHub

There’s video courses. I always seem to understand the text better after I’ve seen a demonstration.

What’s a safari, anyway?

from Arabic safara “to travel”

Exporting

You can export your notes to a CSV file. A fun and easy way to browse a CSV file is to use xsv and fzf:

xsv table safari-annotations-export.csv | fzf

You can use something like browsercookie to help you download the CSV automatically:

from clint.textui import progress, puts
import blindspin
import browsercookie
import requests

jar = browsercookie.firefox()
url = 'https://www.safaribooksonline.com/a/export/csv/'

puts('\nWaiting for download to begin... (may take a while)')

with blindspin.spinner():
    r = requests.get(url, stream=True, cookies=jar)

total_size = int(r.headers.get('content-length', 0))

filename = 'safari.csv'

with open(filename, 'wb') as out_file:

    for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_size/1024) + 1):
        if chunk:
            out_file.write(chunk)
            out_file.flush()

puts(f'File saved to {filename}\n')

Maybe put this thing in a pex and run it in a cron job once in a while and send a push notification with ntfy just because you can.

safari.pex && ntfy send 'Downloaded Safari highlights CSV!'

Working with CSV data? My favourite tools are tad, xsv, csvkit, Pandas and SQLite.

Python

Here are some of my favourite Python resources. If you check these out, you will end up writing beautiful Python code.

Raymond Hettinger

Brett Slatkin

Luciano Ramalho

Kenneth Reitz

Kenneth Reitz' blog.

Kenneth Reitz wrote Requests and creates APIs for humans. README driven development.

Miguel Grinberg

Miguel Grinberg’s blog.

William Wesley McKinney

William Wesley McKinney is one of the creators of Pandas. Here is his blog.

Mahmoud Hashemi

Author of boltons and a very cool logging framework called lithoxyl. Also, more recently: glom.

Harry J.W. Percival

Other

More specific:

Linux

If man is getting you down, try a book instead. Soak in some extra knowledge. Then read the ArchWiki.

Programming philosophy

Operations and monitoring

I have not met anyone who has monitoring and alerting figured out. There is always some edge case that throw off all your dreams. Monitoring is tough!

Other

Alternatives?

Perhaps an open source HTML epub reader? You miss out on the discoverability though.

Let me know if you have any suggestions or have done something similar.

Benefits

It’s in your browser. That’s also a downside. The browser becomes a better source of knowledge.

Downsides

O’Reilly can data mine everything you read.


Back to posts