Shallow Thoughts : : Jul

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Sat, 30 Jul 2011

Beginning Python, Lesson 7: Object-oriented programming

Lesson 7 in my online Python course is up: Lesson 7: Object-oriented programming.

This is the last formal lesson in the Beginning Python class. But I will be posting a few more "tips and tricks" lessons, little things that didn't fit in other lessons plus suggestions for useful Python packages students may want to check out as they continue their Python hacking.

Tags: , ,
[ 10:28 Jul 30, 2011    More education | permalink to this entry | comments ]

Tue, 26 Jul 2011

Nook Touch: the good, the bad, and the crazy

I've been dying to play with an ebook reader, and this week my mother got a new Nook Touch. That's not its official name, but since Barnes & Noble doesn't seem interested in giving it a model name to tell it apart from the two older Nooks, that's the name the internet seems to have chosen for this new small model with the 6-inch touchscreen.

Here's a preliminary review, based on a few days of playing with it.

Nice size, nice screen

The Nook Touch feels very light. It's a little heavier than a paperback, but it's easy to hold, and the rubbery back feels nice in the hand. The touchscreen works well enough for book reading, though you wouldn't want to try to play video games or draw pictures on it.

It's very easy to turn pages, either with the hardware buttons on the bezel or a tap on the edges of the screen. Page changes are much faster than with older e-ink readers like the original Nook or the Sony Pocket: the screen still flashes black with each page change, but only very briefly.

I'd wondered how a non-backlit e-ink display would work in dim light, since that's one thing you can't test in stores. It turns out it's not as good as a paper book -- neither as sharp nor as contrasty -- but still readable with my normal dim bedside lighting.

Changing fonts, line spacing and margins is easy once you figure out that you need to tap on the screen to get to that menu. Navigating within a book is also via that tap-on-page menu -- it gives you a progress meter you can drag, or a "jump to page" option. Which is a good thing. This is sadly very important (see below).

Searching within books isn't terribly convenient. I wanted to figure out from the user manual how to set a bookmark, and I couldn't find anything that looked helpful in the user manual's table of contents, so I tried searching for "bookmark". The search results don't show much context, so I had to try them one at a time, and there's no easy way to go back and try the next match. (Turns out you set a bookmark by tapping in the upper right corner, and then the bookmark applies to the next several pages.)

Plan to spend some quality time reading the full-length manual (provided as a pre-installed ebook, naturally) learning tricks like this: a lot of the UI isn't very discoverable (though it's simple enough once you learn it) so you'll miss a lot if you rely on what you can figure out by tapping around.

Off to a tricky start with minor Wi-fi issues

When we first powered up, we hit a couple of problems right off with wireless setup.

First, it had no way to set a static IP address. The only way we could get the Nook connected was to enable DHCP on the router.

But even then it wouldn't connect. We'd re-type the network password and hit "Connect"; the "Connect" button would flash a couple of times, leaving an "incorrect password" message at the top of the screen. This error message never went away, even after going back to the screen with the list of networks available, so it wasn't clear whether it was retrying the connection or not.

Finally through trial and error we found the answer: to clear a failed connection, you have to "Forget" the network and start over. So go back to the list of wireless networks, choose the right network, then tap the "Forget" button. Then go back and choose the network again and proceed to the connect screen.

Connecting to a computer

The Nook Touch doesn't come with much in the way of starter books -- just two public-domain titles, plus its own documentation -- so the first task was to download a couple of Project Gutenberg books that Mom had been reading on her Treo.

The Nook uses a standard micro-USB cable for both charging and its USB connection. Curiously, it shows up as a USB device with no partitions -- you have to mount sdb, not sdb1. Gnome handled that and mounted it without drama. Copying epub books to the Nook was just a matter of cp or drag-and-drop -- easy.

Getting library books may be moot

One big goal for this device is reading ebooks from the public library, and I had hoped to report on that. But it turns out to be a more difficult proposition than expected. There are all the expected DRM issues to surmount, but before that, there's the task of finding an ebook that's actually available to check out, getting the library's online credentials straightened out, and so forth. So that will be a separate article.

The fatal flaw: forgetting its position

Alas, the review is not all good news. While poking around, reading a page here and there, I started to notice that I kept getting reset back to the beginning of a book I'd already started. What was up?

For a while I thought it was my imagination. Surely remembering one's place in a book you're reading is fundamental to a device designed from the ground up as a book reader. But no -- it clearly was forgetting where I'd left off. How could that be?

It turns out this is a known and well reported problem with what B&N calls "side-loaded" content -- i.e. anything you load from your computer rather than download from their bookstore. With side-loaded books, apparently connecting the Nook to a PC causes it to lose its place in the book you're reading! (also discussed here and here).

There's no word from Barnes & Noble about this on any of the threads, but people writing about it speculate that when the Nook makes a USB connection, it internally unmounts its filesystems -- and forgets anything it knew about what was on those filesystems.

I know B&N wants to drive you to their site to buy all your books ... and I know they want to keep you online checking in with their store at every opportunity. But some people really do read free books, magazines and other "side loaded" content. An ebook reader that can't handle that properly isn't much of a reader.

It's too bad. The Nook Touch is a nice little piece of hardware. I love the size and light weight, the daylight-readable touchscreen, the fast page flips. Mom is being tolerant about her new toy, since she likes it otherwise -- "I'll just try to remember what page I was on." But come on, Barnes & Noble: a dedicated ebook reader that can't remember where you left off reading your book? Seriously?

Tags: , ,
[ 20:46 Jul 26, 2011    More tech | permalink to this entry | comments ]

Fri, 22 Jul 2011

Beginning Python, Lesson 6: Functions and Dictionaries

Lesson 6 in my online Python course is up: Lesson 6: Functions and Dictionaries.

We're getting near the end of the course -- partly because I think students may be saturated, though I may post one more lesson. I'll post on the list and see what the students think about it.

This afternoon, though, is pretty much booked up trying to get my mother's new Nook Touch e-book reader working with Linux. Would be easy ... except that she wants to be able to check out books from her local public library, which of course uses proprietary software from Adobe and other companies to do DRM. It remains to be seen if this will be possible ... of course, I'll post the results once we know.

Tags: , ,
[ 17:49 Jul 22, 2011    More education | permalink to this entry | comments ]

Fri, 15 Jul 2011

Beginning Python, Lesson 5

Lesson 5 in my online Python course is up: Infinite loops, modulo, and random numbers.

It's a motley mix of topics, mostly because I wanted to have a fun homework project that actually did something interesting. I hope everyone enjoys it!

Tags: , ,
[ 16:44 Jul 15, 2011    More education | permalink to this entry | comments ]

Thu, 14 Jul 2011

Using default-frame-alist to specify Emacs window size, position and font

Seems like every few years I need to change the way I specify my preferred emacs fonts and window sizes.

Historically this all used to happen from one file, ~/.Xdefaults, where you set up your defaults for all X programs. In a way that was nice, since you could set up defaults and see the same font everywhere. On the other hand, it made for a huge, somewhat hard to read file, and it's increasingly out of favor on modern desktops, with modern toolkits like GTK just ignoring it.

Emacs still reads Xdefaults -- but only sort of. A lot of the values I used to set there no longer work properly. Some time ago I commented out my various attempts at setting emacs font, like

Emacs*font: -*-clean-bold-*-*-*-13-*-*-*-c-*-*-*
Emacs*font: DejaVu Sans Mono-10:bold
Emacs*font: clean-13:bold
Wmacs*font: Liberation Mono-10:bold
Emacs.font: 7x13bold
Emacs.faceName: Dejavu-10:style=bold
since none of them worked, and worked out a way of setting fonts inside my .emacs file:
(set-face-attribute 'default nil :font "Terminus-12:bold")

That worked to set the font, but it had another annoying attribute: it doesn't happen at startup, so it messed up my window size. See, emacs would start up, see the size I specified in .Xdefaults:

Emacs*geometry: 80x45
and try to set that. But it hadn't read .emacs yet, so it was still using whatever its default font and size is, and that's huge -- so 45 lines made a window too tall to fit on my laptop screen. Emacs would then shrink its window to fit the screen (41 lines). Only then would it open .emacs, whereupon it would see the set-face-attribute, change the font, and resize the window again, much, smaller, still 41 lines.

What a pain!

The emacs manual, in addition to talking about these various Xdefaults properties and command-line options, does mention a couple of variables, set-screen-height and set-screen-width, that looked promising. I tried putting (set-screen-height 45) in my .emacs right after I set the font -- no dice. Apparently that doesn't work because by the time those are read, emacs has already decided that 41 lines is as big as the window can possibly be.

Here's the answer: another variable that goes inside .emacs, default-frame-alist, but this one can override that maximum-height decision that emacs has already made. Here's an example of it in some useful defaults for emacs, and based on that, I was able to come up with this:

(setq default-frame-alist
      '((top . 10) (left . 2)
        (width . 80) (height . 53)
        (font . "terminus-iso8859-1-bold-14")
        ))

Curiously, that height setting, 53, needs to be 3 more than what I actually want according to the size emacs reports to the window manager. So don't take the number too seriously; just try numbers a little bigger than what you actually want until you get the size you're after. The font setting is the X font specifier: I ran xlsfonts | grep -i terminus | grep 14 then picked one of the simpler of the lines it printed out, but you can use a full specifier like -xos4-terminus-bold-r-normal--14-140-72-72-c-80-iso8859-1 like you get from xfontsel, if you prefer.

Startup still isn't pretty -- emacs still shows a big window at one place on the screen, resizes it several times then jumps it over to the top/left coordinates I specified. Of course, I could tell my window manager to start it in the right place so the jumping-around would be minimized; but that wouldn't help the visible resizing. Just a minor irritation.

I'm sure there's lots more useful stuff buried in that sample emacs config file (it was suggested to me when I asked about this on the #emacs IRC channel), so I'll be reading it to see what else I can glean.

Tags: , ,
[ 12:24 Jul 14, 2011    More linux/editors | permalink to this entry | comments ]

Sun, 10 Jul 2011

Newt larvae at Sanborn

It's always fun to look for newts when we go on walks in the woods. We're always reading that amphibians are in mortal danger -- they're more susceptible to environmental toxins than other vertebrates, and they're dying off at frighteningly high rates. So seeing newts, salamanders or frogs always makes me happy ... and seeing a new generation of them makes me even happier.

[ Newt tadpole ] [ Newt tadpole ]

Therefore, in spring and early summer, I always check the ponds for tadpoles and newt larvae. Usually I don't find any. But this year I got lucky: the little decorative pond at Sanborn county park had newt tadpoles when we checked last month (June 18), and yesterday we saw one in that pond and two in the lower pond.

[ Adult and larval newt ] Photographing tadpoles is tougher than photographing adult newts. Of course, they're always under water, so there are reflections and refraction to deal with; and it's usually mossy stagnant water, so you have to wait for them to come out from under the moss. They're also shy, and dart away if they see motion above them -- not surprising for something so small and defenseless. (Adult newts are pretty casual and it's easy to get fairly close to them ... maybe because they're poisonous.) [ Detail of larval newt from previous photo ]

So, okay, not exactly National Geographic material. But I was excited to get any photos at all that show both legs and gills, as well as one showing an adult newt with a larva right next to it. Coincidence, of course: newts don't care for their young. But it's fun to see the difference in size and shape between adult and youngster, and equally fun to see how much the larvae changed in three weeks' time from the first shots to the second.

Tags: , ,
[ 13:42 Jul 10, 2011    More nature | permalink to this entry | comments ]

Fri, 08 Jul 2011

Beginning Python, Lesson 4

Lesson 4 in my online Python course is up: Modules and command-line arguments.

This lesson is a little longer than previous lessons, but that's partly because of a couple of digressions at the beginning. Hope I didn't overdo it! The homework includes an optional debugging problem for folks who want to dive a little deeper into this stuff.

Tags: , ,
[ 20:20 Jul 08, 2011    More education | permalink to this entry | comments ]

Tue, 05 Jul 2011

Bitlbee: How to re-authenticate with Twitter

I've been using Bitlbee for Twitter for quite a while now, and like it a lot.

But I guess Twitter recently changed something in their authentication, so I had to upgrade Bitlbee to the latest development version, 3.0.3, on each machine where I use it. Then on each machine, I got prompted to re-authenticate with Twitter -- except on one, my home desktop. There, all I saw was "Authentication failure" and "Logging out".

My normal procedure for setting up a Twitter account in Bitlbee didn't apply, because Bitlbee saw there was already an authenticated account, and didn't see any need to start over.

Here's the solution, courtesy of a helpful person on IRC: go to the Bitlbee channel where the authentication failed and type

acc 0 set password my-irc-passwd
-- substitute other account numbers for 0 as appropriate, and use the nickserv password you use for your bitlbee IRC account.

Then activate the account again:

account on
and it should contact Twitter and give you a URL to re-authenticate.

Tags: ,
[ 20:05 Jul 05, 2011    More tech | permalink to this entry | comments ]

Sun, 03 Jul 2011

Beginning Python, Lesson 3: Strings and Lists

Lesson 3 in my online Python course is up: Fun with Strings and Lists.

There may be some backlog on the mailing list -- my first attempt to post the lesson didn't show up at all, but my second try made it. Mail seems to be flowing now, but if you try to post something and it doesn't show up, let me know or tell us on irc.linuxchix.org, so we know if there's a continuing problem that needs to be fixed, not just a one-time glitch.

Meanwhile, I'm having some trouble getting new blog entries posted. Due to some network glitches, I had to migrate shallowsky.com to a different ISP, and it turns out the PyBlosxom 1.4 I'd been using doesn't work with more recent versions of Python; but none of my PyBlosxom plug-ins work in 1.5. Aren't software upgrades a joy? So I'm getting lots of practice debugging other people's Python code trying to get the plug-ins updated, and there probably won't be many blog entries until I've figured that out.

Once that's all straightened out, I should have a cool new PyTopo feature to report on, as well as some Arduino hacks I've had on the back burner for a while.

Tags: , ,
[ 11:57 Jul 03, 2011    More education | permalink to this entry | comments ]