Wednesday, January 30, 2013

EBookDroid

For a while now, I've been trying not to print out copies of papers I'm using for class. I had a Kindle DX a while back, and I tried loading PDFs of papers into it. But the page rendering was so slow it was painful, and a real problem in class itself, since finding a particular passage would simply take too long.
More recently, I've acquired a Samsung Galaxy Tab 10.1, which makes for an excellent e-reader. It has a nice, bright screen, good resolution (1280x800), and lots of memory. Plus, I can access my course web site, or JSTOR, or whatever, directly from it (and with tools like AndFTP, I can even access my servers using SFTP and public key authentication).
But as I've mentioned elsewhere, a lot of the material I've scanned for my own use is in DjVu format, so I recently found myself needing to find a DjVu reader for Android.
It turns out (unsurprisingly, really) that there are several options, but the one on which I've settled for now is EBookDroid, a free and open source (GPL'd) ereader. Not only does it handle DjVu, it's got a lot of other nice features, such as the ability to set lots of named bookmarks (making particular passages easy to find). But one of the nicest things about it is that it will automatically split pages, if the file you are reading happens to have facing pages on a single page, like a photocopy. And it will automatically scale pages to the content area, not to mention wash your laundry and make your dinner. An excellent tool.
I've seen some people mention that EBookDroid "hijacks" PDF links from the browser, but I have not seen this issue myself. It does register itself as one possible PDF reader, but that is all.



Scan Tailor

For quite some time now, I've been putting all the readings (except books) for my various classes online, on my course websites (such as here or here). In the good cases, this just means downloading stuff from JSTOR or some equivalent, or linking directly to it, though I very often convert the PDFs I get that way to DjVu files, since (a) the DjVu files are often a lot smaller (like one tenth the size), and (b) I prefer to have files where two pages appear on a single page, so that when they are printed you don't waste so much paper.
I've developed a number of tools to make this easier to do. I'll blog about them later. (Some of them are already available here.) What I wanted to mention today is a really, really cool program I found last weekend, called "Scan Tailor". It's "free and open source" (GPLv3) and available for Linux, OSX, and Windoze.
I've found that the easiest way to scan stuff I need from books (e.g., Dummett's "Frege's Myth of the Third Realm", from Frege and Other Philosophers) is first to make a photocopy of the paper and then to scan that. (This is easiest with a sheet-fed scanner, such as the HP Scanjet 5590, which works fine with Linux.) You can simply make a PDF or DjVu from the result, but, if you just do that, it will usually look like crap. For one thing, you get big black marks along the sides and, often, down the middle (where the spine of the book is). And the pages can be hard to read on screen, since they are often not quite square. Even half a degree's rotation is easy to see, and very annoying.
So, in the past, I'd load the pages one by one into Gimp (an open source image editor) and fix them up. But this was time consuming, and hard to get right. That is where Scan Tailor comes to the rescue.
Here's how it works. You put all the page images into some directory, and then you open Scan Tailor and create a new "project", pointing the program at that directory. All the pages then get loaded up. You can then rotate them, if need be. But the really useful bit is that the program will then automatically (i) split the pages in half (which you need to do for the next step), (ii) deskew them (i.e., correct for rotation of the text), (iii) put a bounding box around the actual text (thus eliminating the black marks), (iv) put clean new margins around that text, (v) despeckle the images (remove stray black dots), and then (iv) output the resulting page images to a directory of your choosing, so you can assemble them into a PDF or a DjVu.
And at every one of those steps, you can intervene to make manual corrections, if need be. It totally, totally rocks.

The Grand Teaching Experiment

Over the last couple years, I've become very dissatisfied with the way I've always taught my non-logic classes, e.g., classes on philosophy of language. These tend to be fairly small classes, with enrolment in the range of 10-15, and the basic model has been this: I've lectured on Mondays and Wednesdays, and we have had discussion on Fridays, led by me.
But I've read several things recently suggesting that lecturing is not a very effective way to get students to learn things. So this semester, in my course on Theories of Truth (Phil 1890D), I'm trying something different. I propose to blog about it from time to time.
The first thing I'm doing is trying to make use of Brown's new online teaching framework, called "Canvas". It does quite a lot. For example, there is an integrated conferencing system that I may try to use later. And it has simpler stuff, like the ability to schedule assignments, which are then automatically entered into a "grade book". But the main thing I'm using is the discussion board. For each of the readings, I've set up a discussion thread, and I'm requiring everyone in the class to post to it prior to class.
Obviously, this is just taking the place of the "response papers" that lots of people use, anyway, but it has a few advantages.
  1. It's easy for me to comment on people's responses simply by replying in the discussion thread. As a result, they can get feedback before we meet for class. 
  2. The students' responses, and my comments, are visible to the other students, so there is some opportunity for them to learn from each other. So far, there has only been a little discussion among the students, but I'm hopeful that, as we get into the semester, and as we all adjust to this new system, there will be more. (I've set it up so they have to post before they can see what other people wrote, for the obvious sort of reason.)
  3. Since contributing to discussion is an "assignment", it is linked to the grade book, and I can enter grades (not much more than "did" or "didn't") very easily.
Much of this, of course, could be done with a Google Group, but the way Canvas automatically generates a syllabus from my discussion assignments is very nice. And I can add the other course assignments, too, so a calendar for the semester is automatically created.
The second thing I'm doing differently is I'm not lecturing. At all. I told the students this at the first meeting, and when I walked into the first "real" class, I had no lecture notes. I'm trying to run the entire class as discussion.
The days that would previously have been devoted to lecture are now devoted to discussion that is aimed at understanding the readings. The day that was previously devoted to discussion is now devoted to discussion aimed at evaluating and criticising the readings. We've had two of the former so far (on Austin's and Strawson's famous papers on truth), and I'm not sure yet how they are going. My strategy has been to identify topics from the papers that we should talk about. So, in the case of Strawson's paper, for example, these were: His criticisms of Austin's account of (i) statements, (ii) facts, and (iii) correspondence, and (iv) his own positive account of the use of "true". The first class seemed to go pretty well. The second one, a bit less so, and I ended up talking more. But that may simply have been because Strawson's paper is quite hard, and maybe that is a sign that I should do something else.

Friday, November 30, 2012

Extracting WAVs from VOB Files

The Station to Station box set contains a DVD with hi-resolution digital rips of the album, including one in 96/24. Since I play all of my digital stuff through a Logitech Transporter, I needed to rip those files to the media server. Here's how I did it.

First, I used mplayer to rip the VOB files from the DVD. These files have trivial video in them, so that has to be removed. The command to do that is:

ffmpeg -i <infile.vob> -acodec pcm_s24le <outfile.wav>

The audio codec here is the usual one for 24-bit audio, as you can see if look at a wav generated from a flac file. E.g.:

# ffmpeg -i 01-statesboro_blues.wav
...
Input #0, wav, from '01-statesboro_blues.wav':
Duration: 00:04:19.94, bitrate: 4608 kb/s
Stream #0.0: Audio: pcm_s24le, 96000 Hz, 2 channels, s32, 4608 kb/s
At least one output file must be specified


Note that this is independent of the sampling rate, so it works for 48/24 files, as well.

So now I had a bunch of 96/24 wavs, which I could convert to flac in the usual way.

Monday, November 19, 2012

Perl Filters

A nice trick for easily writing Perl filters:

perl -pe 's/a/b/g'

will do the substitution on each line of input and spit it back out. And:

perl -i bak -pe 's/a/b/g' file1 file2....

will do the same, except it will change the given files and back them up to file1.bak, etc, as it does so.


Thursday, July 19, 2012

How To Add to an LVM Drive

One of the great things about LVM is that you never run out of space. If it seems as if you are about to do so, you just add a new "physical volume" to your "volume group", add that to your "logical volume", and resize the file system. In effect, it's as if you have a partition that spans multiple drives.

It would of course be a good idea to back things up before you do this. But sometimes we don't have that option, do we?

I'll suppose our existing volume group is "vgroup", and our existing logical volume is "vvolume".

All of this of course needs to be done as root.

A little hint first: You can (and probably should) give the "-t" (test) option to each LVM command first, to make sure it's going to do what you want. Then I hit up arow (history) and delete the "-t" option, so I make sure I'm running that same command.
  1. Add the new disk to the machine, and format whatever space we want on it (all of it, if we wish) as type 8e (Linux LVM). I'll assume this is now /dev/sde1.
  2. Create a physical volume:
    # pvcreate /dev/sde1
  3. Add the physical volume to the volume group:
    # vgextend vgroup /dev/sde1
  4. Check your work:
    # vgdisplay vgroup
    You should now see something like:
    VG Name               vgroup
    System ID
    Format lvm2
    Metadata Areas 2
    Metadata Sequence No 5
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 0
    Max PV 0
    Cur PV 2
    Act PV 2
    VG Size 3.68 TiB
    PE Size 4.00 MiB
    Total PE 1192327
    Alloc PE / Size 476931 / 1.82 TiB
    Free PE / Size 476931 / 1.82 TiB
    VG UUID JitzBk-zFH0-vhzm-XhYk-V5Xi-Nt7d-87K9En
    Note the free space we now have.
  5. Extend the logical volume:
    # lvresize -l 100%VG /dev/vgroup/vvolume
    The "-l 100%VG" says to resize to use all of the space in the volume group assigned to this logical volume. The argument can be given many ways. See "man lvcreate".
  6. Check our work:
    # lvdisplay
  7. Now we are ready to resize the filesystem:
    # e2fsck -f /dev/vgroup/vvolume
    It made me do that first.
    # resize2fs /dev/vgroup/vvolume
The LVM HowTo covers all of this.

    Saturday, May 19, 2012

    Using Remember the Milk with Thunderbird

    I've been looking for a few days now for a good task list to use under KDE. The main requirement is that I want something that will be easily usable on many computers, and mobile devices, and without my having to worry a lot about sync'ing.

    Google Tasks look great, but I don't want to have to use Google all the time, just to see and manage my tasks, and there doesn't appear to be a decent API for Tasks. So you can't sync them to Thunderbird or anything else.

    KOrganizer looks nice, but I don't see any good sync options there, either.

    So I stumbled across Remember the Milk, which is also a web-based task manager, but with lots of other support. There's an Android app, and there's also an iCal URL you can use to view tasks in other places. The only downside is that the iCal support is read-only.

    But I found a way around that in Thunderbird. First, you just add the iCal service as a calendar. (Get that URL from Settings> Info, in Remember the Milk.) That'll at least let you see your tasks in Thunderbird.

    Now, how to add tasks? Answer: Use RTM's google gadget in a tab in Thunderbird. First, you'll need to download the WAT extension for Thunderbird. Among other things, this will give you a box in the upper right corner where you can enter a URL, which will then be opened in a new tab. The URL to enter is:
    • http://www.rememberthemilk.com/services/modules/googleig/
    You'll need to sign in the first time, of course. You can now bookmark the page and have easy access to it whenever you need to add or modify a task. And, of course, you can do the same with the main RTM URL.