These are good choices for book code:
These are bad, worse and terrible choices for book code:
LGPL
GPL
AGPL
Leanpub's position is that if you are writing a computer programming book, you should want the code in it to be helpful to as many people as possible. So, any license with onerous restrictions (with AGPL being the worst offender) is a bad choice.