Wednesday, April 20, 2016

Mac OS vs Emacs: Getting on the right (exec) PATH

One of the minor annoyances about using Emacs on Mac OS is that the PATH environment variable isn't set properly when you launch Emacs from the GUI (that is, the way we always do it). This is because the Mac OS GUI doesn't really care about the shell as a way to launch things, but if you are using brew, or other packages that install command line tools, you do.

Apple has changed the way that the PATH is set over the years, and the old environment.plist method doesn't actually work anymore, for security reasons. For the past few releases, the official way to properly set up the PATH is to use the path_helper utility program. But again, that only really works if your shell profile or rc file is run before you launch Emacs.

So, we need to put a bit of code into Emacs' site_start.el file to get things set up for us:

(when (file-executable-p "/usr/libexec/path_helper")
  (let ((path (shell-command-to-string
        "eval `/usr/libexec/path_helper -s`;
echo -n \"$PATH\"")))
    (setenv "PATH" path)
    (setq exec-path (append (parse-colon-path path)
                    (list exec-directory)))))

This code runs the path_helper utility, saves the output into a string, and then uses the string to set both the PATH environment variable and the Emacs exec-path lisp variable, which Emacs uses to run subprocesses when it doesn't need to launch a shell.

If you are using the brew version of Emacs, put this code in /usr/local/share/emacs/site-lisp/site-start.el and restart Emacs.

Tuesday, January 20, 2015

Finding ISBNs in the the digits of π

For some reason, a blog post from 2010 about searching for ISBNs in the first fifty million digits of π suddenly became popular on the net again at the end of last week (mid-January 2015). The only problem is that Geoff, the author, only looks for ISBN-13s, which all start with the sequence "978". There aren't many occurrences of "978" in even the first fifty million digits of π, so it's not hard to check them all to see if they are the beginning of a potential ISBN, and then find out if that potential ISBN was ever assigned to a book. But he completely ignores all of the ISBN-10s that might be hidden in π. So, since I already have code to validate ISBN checksums and to look up ISBNs in OCLC WorldCat, I decided to check for ISBN-10s myself.

I don't have easy access to the first fifty million digits of π, but I did manage to find the first million digits online without too much difficulty.

An ISBN-10 is a ten character long string that uniquely identifies a book. An example is "0-13-152414-3". The dashes are optional and exist mostly to make it easier for humans, just like the dashes in a phone number. The first character of an ISBN-10 indicate the language in which the book is published: 0 and 1 are for English, 2 is for French, and so on. The last character of the ISBN is a "check digit", which is supposed to help systems figure out if the ISBN is correct or not. It will catch many common types of errors, like swapping two characters in the ISBN: "0-13-125414-3" is invalid.

Here are the first one hundred digits of π:

3.141592653589793238462643383279502884197169399375
105820974944592307816406286208998628034825342117067
To search for "potential (English) ISBN-10s", all one needs to do is search for every 0 or 1 in the first 999,990 digits of π (there is a "1" three digits from the end, but then there aren't enough digits left over to find a full ISBN, so we can stop early) and check to see if the ten digit sequence of characters starting with that 0 or 1 has a valid check digit at the end. The sequence "1415926535", highlighted in red, fails the test, because "5" is not the correct check digit; but the sequence "0781640628" highlighted in green is a potential ISBN.

There are approximately 200,000 zeros and ones in the first million digits of π, but "only" 18,273 of them appear at the beginning of a potential ISBN-10. Checking those 18,273 potentials against the WorldCat bibliographic database results in 1,168 valid ISBNs. The first one is at position 3,102: ISBN 0306803844, for the book The evolution of weapons and warfare by Trevor N. Dupuy. The last one is at position 996,919: ISBN 0415597234 for the book Exploring language assessment and testing : language in action by Anthony Green.

Here's the full dataset.

Saturday, March 10, 2012

Software Upgrades and The Parable of the Windows

A librarian friend of mine recently expressed some surprise at the fact that a library system would spend almost $140,000 to upgrade their ILS software, when the vendor is known to be hostile to its customers and not actually very good with new development on their products. The short answer is that it's easier to upgrade than to think. Especially when an "upgrade" will be seen as easier than a "migration" to a different vendor's system (note: open ILS platforms like Evergreen and Koha may be read as being different vendors for the sake of convenience). In fact, when an ILS vendor discontinues support for a product and tells its customers that they have to migrate to another product if they want to continue to purchase support, it is the rare library that will take this opportunity to re-examine all its options and decide to migrate to a different vendor's product.

A simple demonstration of this thinking, on a scale that most of us can imagine, is what happened when my partner and I decided that it was time to replace the windows in our house several years ago. There are a couple of things you need to know about replacing the windows in your house, if you've never done this before:

  1. Most normal folks replace the windows in their house over the course of several years, doing two or three windows every year or two. If one is replacing the huge bay window in the living room, then that might be the only window that one does that year. Windows are expensive enough that one can't really afford to do them all at once.
  2. Windows are fungible. For the most part, one company's windows look exactly like another company's. Unless you're working hard at getting a particular colour of flashing on the outside of the window, nobody looking at your house from the sidewalk would notice that the master bedroom window and the livingroom window were made by different companies.

Like any responsible homeowners, we called several local window places, got quotations from three or four of them for the windows we wanted replaced that year, made our decision about which vendor we were going to use for the first round of window replacements, and placed an order. A month or so later, on a day that the weather was going to be good, a crew from the company arrived, knocked big holes in the front of our house to take out the old windows and install the new ones.

A couple of years went by, and we decided it was time to do the next couple of windows, so my partner, who was always far more organized about this sort of thing that me, called three or four window companies and asked them to come out to get quotations for the work.

At least one of the vendors declined, and another vendor did come out and give us a quote but he was very surprised that we were going through this process again, because normally, once a householder has gone through the process once, they tend to use the same window company for all the windows, even if several years have passed, or if the type of work is very different from the earlier work (such as replacing the living room bay window after a couple of rounds of replacing bedroom windows).

In general, once a decision has been made, people tend to stick with that plan. I think it's a matter of, "Well, I made this decision last year, and at the time, this company was good, so they're probably still good," combined, perhaps, with a bit of thinking that changing vendors in mid-stream implies that I didn't make a good decision earlier.

And there is, of course, always the thought that it's better to stick with the devil you know that the one you don't.

Sunday, January 02, 2011

Using QR Codes in the Library

This started out as a set of internal guidelines for the staff at MPOW, but some friends expressed interest in it, and it seems to have struck a nerve, so I'm posting it here, so it is easier for people to find and to link to.

Using QR Codes in the Library

QR codes are new to North American, but have been around for a while in Japan, where they originated, and where everybody has a cellphone that can read the codes. They make it simpler to take information from the real world and load it into your phone. As such, they should only be used when the information will be useful for somebody on the go, and shouldn't normally be used if the person accessing the information will probably be on a computer to begin with.

Do Use QR Codes:

  • On posters and display projectors to guide users to mobile-friendly websites.
  • To share your contact information on posters, display projectors, or your business card. This makes it simpler for users to add you to their addressbook without having to type it all in.
  • In display cabinets or art exhibits to link to supplementary information about the items on display.

Don't use QR Codes:

  • to record your contact information in your email signature. Somebody reading your email can easily copy the information from your signature to their addressbook.
  • to share URLs for rich, or full-sized, websites. The only URLs you should be sharing via QR codes for are mobile-friendly sites.

When Using QR Codes:

  • Make sure to include a human readable URL, preferably one that's easy to remember, near the QR code for people without QR Code scanners to use.

Monday, April 06, 2009

A Manifesto for the Library

Last week John Blyberg, Kathryn Greenhill, and Cindi Trainor spent some time together thinking about what the library is for and what its future might hold. The result of that deep thinking has now been published on John's blog under the title "The Darien Statements on the Library and Librarians."

Opening with the ringing statement that

The purpose of the Library is to preserve the integrity of civilization

they then provide their own gloss on what this means for individual libraries, and for librarians.

There is a lively discussion going on in the comments on John's blog, as well as less thoughtful sniping going on in more "annoying" blogs. I think that this is something that will engender quite a bit of conversation in the month's to come.

Sunday, April 05, 2009

I'm a Shover and Maker!

Since only a few people can be named "Movers and Shakers" by Library Journal, Joshua Neff and Steven Lawson created the "Shovers and Makers" awards "for the rest of us," under the auspices of the not entirely serious Library Society of the World. I'm very pleased to report that I have been named a 2009 Shover and Maker (by myself, as are all the winners).

The Shovers and Makers awards are a fun way to share what we've done over the past year or two and they're definitely a lot simpler than writing the annual performance review that HR wants. Think of this as practice for writing the speaker's bio for the conference keynote you dream of being invited to give.

Sunday, January 25, 2009

LITA Tears Down the Walls

At ALA Midwinter 2009, Jason Griffey and the LITA folks took advantage of the conference center's wireless network to provide quick and easy access to the Top Tech Trends panel for those of us that couldn't be there in person. The low-bandwidth option was a CoverItLive live-blogging feed of comments from attending that also included photos by Cindi Trainor, and a feed of twitters from attendees. The high-bandwidth option was a live (and recorded) video stream of the event that Jason captured using the webcam built into his laptop.

Aside from the LITA planned events, the fact that we could all sit in meant that there were lots of virtual conversations in chat rooms and other forums that sprung up as people joined in from afar. Unfortunately, because my Sunday morning is filled with laundry and other domestic pleasures, I wasn't able to join in on the "live" chatter going on in parallel with the video or livebloggin.

Owing to funding constraints and my own priorities, my participation at ALA is limited. I've been to LITA Forum once, and might go again, but I focus more on the OLA other regional events. This virtual option from LITA let me get a peek at what's going on and hear what the "big thinkers" at LITA have to say. I hope they can keep it up, and will definitely be talking to local folks about how we might be able to emulate LITA in our own events.