Archive for the General Category

Ubuntu on Lenovo S12 NetBook

Posted in General on August 22, 2010 by jkiparsky

I’ve just installed Ubuntu 10.4 (Lecherous Lemur, or whatever it’s called) on a Lenovo S12 netbook graciously donated by Chris, who’s buggering off to Oregon and leaving all his stuff behind him. The install was not difficult, but since I had to look for the steps of the procedure, I record them here in case anyone else has trouble.
There are no great discoveries here, you should only read on in case you’re having trouble getting Ubuntu onto one of these machines. This may also be applicable to other distributions, but I don’t know enough about them to say. Feel free to try, and let me know if I need to add anything here!

The trouble with installing on the netbook is that there isn’t a CD drive, so you have to install from a USB stick or an external CD drive. I went with the USB stick, since it’s what I had lying around.

1) I emptied the USB drive (copied the contents to my Mac hard drive for safekeeping). I don’t know if clearing off the drive makes a difference, but it doesn’t seem to have hurt at all.

2) Making the USB drive bootable: I turned on the Lenovo, which was running XP, and went to, downloaded and ran the unetbootin program, which magically makes a USB stick into a bootable device with the install of your choice on it. I selected 10.4 (Leperous Limpet) from the menu, and poured a cup of coffee while it fetched the disk image. When it was done, it suggested that I could now restart the machine.

Here’s where I missed a step, and where you will likely miss a step, unless you’ve done this before:
I said, sure, restart, and then I continued drinking my coffee. When I looked up, it had booted into XP, as before. This is because I had failed to change the BIOS settings when I restarted the machine.

3) Change the BIOS settings to boot from the USB drive. When the machine begins to set up, you have about a second to hit the F2 key, which lets you into the BIOS setup. If you miss it, you have to restart and pay attention next time. It’ll bring you to a screenful of options. Arrow your way over to “Boot” and arrow down to the name of your USB stick. Now, you’ll assume that you can just select this and save changes and restart, but this is wrong. You have to use the F5 key to move the entry for this device up to the first position in the list, otherwise it’ll start from the first item on the list that it finds. Now you can save and restart (F10).

From here, it’s pretty easy: you’ll see a desktop with an icon labelled “Install Linux”. Start that up, and follow the instructions, then reboot.
You may want to go back into the bios and re-set the boot order, but it won’t make a lot of difference unless you plan on powering up the machine with a flash drive in the USB port.

This got Linux up and running, but I haven’t yet got the drivers for the wireless card. When I find those, I will make a posting about it and link from here.


I never did get the drivers onto that install, because it wound up having trouble even spotting the ethernet cord, so I managed to get some coding tools on it and used it to learn some lisp.
However, I’ve since put Mint 8 on it, and that was able to find and install some drivers at least. Unfortunately, it’s not finding my home network, so there’s more to be done, but there’s something to try. It might just be that drivers are newly available, and if I redo the Ubuntu install, everything will work fine. If that happens, I will update. For the moment, if you’re having trouble with wireless drivers on your netbook, try Mint and see if that works better for you.

Later Still:
installed slackware over the Christmas weekend – thanks Ryan! – but was unable to get anywhere with the configuration, so I installed the netbook remix of 10.04 on a separate partition. This time, it was able to find and install the b43 drivers: I have a netbook that talks to the world. Huzzah.

If you’re reading this to try to find out how to get a working linux intstall on an ideapad, my advice is: try 10.04. I don’t much like the “netbook edition” but it’s working. I haven’t checked whether the “real” edition has also got the trick of finding those drivers (it didn’t a few months ago), but I don’t know if I’m going to try to find out. If anyone has any luck with finding the drivers under 10.04 standard, please drop me a note so I can include it here.

Command-line audio switcher for Mac OS

Posted in General on August 8, 2010 by jkiparsky

Found this tonight, and it’s rather handy if you set it up right, so I figured I’d pass it along.

In one of my jobs, I spend a certain amount of time talking to people via a headset, but I don’t want to be on the headset all the time, because I like my ears and I want to keep them. So I switch back and forth between headset and speakers for a few hours, but digging up a System Preferences window and clicking down to audio can be a bit of a nuisance when you’re doing it over and over. So I was looking for a way to do this through the command line, like a civilized human being. (I do believe that the only really good use for a mouse is feeding snakes)

I found something that I like.
SwitchAudioSource is an open source C program that allows you to display and change your audio device settings from the terminal window. If you simply download it and install it, it’s not hard to figure out, but the name of the program is long and the names of the devices are long, and typos mean you start over, so it’s not very useful straight out of the box.
Fortunately, it’s pretty simple to make aliases for the devices that you use often, so after a very small amount of configuring this ends up being a very useful piece of work. For example, I now type “headset” to switch to the headset and “spkr” to go to the on-board speakers when I’m done with a call. If you’re doing sound mixing or some other task that requires switching among various inputs or outputs, this might be a handy tool for you.

I haven’t included set-up instructions here because it’s all pretty simple, but if anyone asks I’ll explain the process that I used. It involves putting the file in the right place, making a symbolic link, and defining two aliases. It’s not difficult stuff, and it’s stuff that a Mac user should know how to do, because it’s nice to be able to customize your machine.

A very short science fiction story

Posted in General on July 9, 2010 by jkiparsky

I got in my time machine and visited Arthur next week – wasn’t he surprised, since I died next Sunday on my twenty-ninth birthday at the age of eighty-one!

“Procrastinating Pleasure” (NYT, 12/29)

Posted in General on January 20, 2010 by jkiparsky

A pretty interesting article from the Times. Yes, it’s two weeks old. I’ve been meaning to get around to reading the Science section, but they just pile up…

The article reminded me of a lovely old story by Robert Bloch, which always creeped me out, much more than his regular old horror stuff. The story was call, I think, “The Hell-Bound Train”, or something very similar. If you find it in a collection that also includes “Yours Truly, Jack the Ripper”, the two are probably worth the price of the collection.

The gift of prophecy

Posted in General on January 9, 2010 by jkiparsky

“There are some who complain of a man for doing nothing; there are some, still more mysterious and amazing, who complain of having nothing to do. When actually presented with some beautiful blank hours or days, they will grumble at their blankness. When given the gift of loneliness, which is a gift of liberty, they will cast it away; they will destroy it deliberately with some dreadful game with cards or a little ball.”
-G. K. Chesterton

Who knew that Chesterton, of all people, would have anticipated social networking sites?

A logic puzzle

Posted in General on November 27, 2009 by jkiparsky

A conversation over coffee and pie yesterday led me back, once again, to the logic puzzles of Raymond Smullyan, probably my favorite logician ever. This one comes out of “The Lady or the Tiger”, one of several collections of puzzles he put together, but he calls it an old one – you may have come across it.
He claims this puzzle is great for starting arguments, in that there are a number of wrong answers that people will defend vigorously. I’ll put the puzzle here, so you can have a nice argument with someone. If there’s any call for the answer, I’ll supply it…

A salesman buys a widget in the morning for $7, and sells it before lunch for $8. After lunch, he buys it back for $9, and before the end of the day he sells it again for $10. How much profit did he make on this widget?

Unexpected variable interactions in C

Posted in General on October 16, 2009 by jkiparsky

And now for something completely different…

Doing an assignment for CS240 (C Programming), I wrote myself the sort of error that you have to tell the world about. So I’ll do the next best thing: I’ll make a note of it here, so I know where it is if I ever need it.
It’s actually a pretty cool example of how a piece of C can misfire so subtly that you have to really work to find it.

The assignment is pretty simple: converting an int to hex, and back – the hex, of course, being a char string. Totally useless, since C will do this for you for free, but good practice, and something that I hadn’t actually written before. So here’s what I wrote:

main: call the two functions and report the output

#include the usual stuff
char hexstring[ENOUGH_SPACE];
int n=0, m=0;
while (scanf(“%d”, &n)!=EOF)
m = xtoi(hexstring);
printf(“n=%12d %s m=%12d\n”,n, hexstring, m);

itox: convert integer to hexadecimal

char hex[]={‘0′,’1′,’2′,’3′,’4′,’5′,’6’, ‘7’,
‘8’,’9′,’A’,’B’,’C’,’D’,’E’, ‘F’};

/* function represents the int n as a hexstring which it places in the hexstring array */
void itox( char hexstring[], int n)
hexstring[i]=’\ 0′;
while (i>=0)
// 0/16=0, so leading zeros will be filled in automatically

xtoi: convert hex to integer:

/* function converts hexstring array to equivalent integer value */

int xtoi( char hexstring[])
int n = 0; //return integer
int i = 0; //index
long int p = 1; //decimal placeholder

while (hexstring[i]!=’\ 0′)
while (i>=0)
while (i>=0)
if ((hexstring[i]>=’0′)&&(hexstring[i]=’A’)&&(hexstring[i]<='F') )
n+= ((hexstring[i] – 'A' + 10)*p);


return n;

I got all of this, cleaned up the usual typos (you always lose a semicolon along the way, that sort of thing) and ran it. Worked great, except it always reported out the input value – n, in main(), the one that is the target of the scanf() and then is never written to again – as 48.
Can’t find any place where I’ve changed that value, let’s see where it changes. I start putting in printf() statements. It’s fine all the way through main, and then it comes back from xtoi and it’s 48. Okay, that’s easy: it’s impossible. Everyone knows you can’t change a variable in main while you’re in a function, right? Not unless you use pointers and I didn’t use… oh.
Oh. (people with some experience in C are nodding their heads at this point, they’re going back and looking at the code, and they’ve just seen it)
Okay, for the rest of you, here’s what happened:
I passed the itox function an array of char to hold the text string representing a hex value. Since I have the length of the string defined in a global header, I use that as the length of the string, and set the last char in it to ‘\ 0′, the string delimiter. Then I just divide by sixteen repeatedly, putting the remainders into the array in positions of increasing significance. Worked great, as you’d expect: nothing very difficult about this.

So how does this change the value of a variable in main?

The trouble is in the loop control. As usual, I rolled back down the string from i (length of string, least significant digit, the right side) to 0 (first character in string, most significant digit, the left side). This would be fine, except I put the decrement at the start of the loop body. So if i==0, we go sailing merrily into the loop, and the first thing that happens is i- -, so i is now -1. Now the next thing that happens is we assign hexstring[i] a value. That value is pretty much guaranteed – due to the conditions of the program – to be zero, or rather, the ASCII value of zero. Which, you will not be surprised to learn, is 48.
What’s happening is that the piece of memory just “below” hexstring[0], that is, hexstring[-1], is in fact my original n. So when I overshot the end of the string (harmless, right?) – I ended up using a pointer (arrays and pointers are mostly different ways of doing the same thing) to directly access a piece of memory that I had no idea I was accessing.
This created a bug that took me half an hour to track down, because it was the sort of thing I’d been taught to think just couldn’t happen.

Three things to learn from this. One, of course, is that C is a tricky language, and even the simplest things can creep up and bite you. The second: be careful of your loop counters. Don’t assume that what you meant to do is what you did, and don’t assume that just because it should work fine, it will.
And third: there’s a good reason to know the ASCII values, or at least the rough locations of a-z, A-Z, and 0-9. This would probably have saved me twenty minutes’ debugging, and allowed me to get that cup of coffee I needed before class.

Recording Skype on Mac OS X

Posted in General on September 21, 2009 by jkiparsky

As part of the journalistic part of my life, I’ve found myself needing to record phone conversations. Here’s what I’ve done to make this work on Mac OS X.
This is a method I hacked together this afternoon, using a few pieces of free software.
The recording is done in Audacity, and I’m using Soundflower, SoundSource and LineIn as well. Since there is no documentation to speak of for any of these programs, it’s hard for me to say what’s doing what, so here’s a configuration that got good sound:
In SoundSource, output and input, and system are all set to SoundFlower 2ch.
In lineIn, input from my headset (USB VoIP device) is out to Soundflower. “Pass through” is selected – this is key!
In SoundFlowerBed, both 2ch and 16 ch are set to “off” (???)

In Audacity, I’ve set the preferences as follows:
Playback: USB VoIP Device
Recording: Soundflower (2ch) (2 channels)
I’ve checked all four options – play other tracks while recording, hardware playthrough, software playthrough, do not modify audio device settings.

In Skype, I’ve got audio output set to Soundflower (2ch) and input to USP VoIP Device.

Under System Preferences, both input and output are set to SoundFlower 2 ch, which may be an effect of one of the other programs’ settings.

Other configurations I’ve tried have given me useless results – massive volume differential between my line and the voice on the other end, for example – or only recorded one side of the conversation.
This one gets both, with pretty good balance of voices, although sound quality is only as good as you can expect from Skype.
I’m posting this mostly for my own use, to save myself a lot of work resetting this for my next interview. With any luck, it’ll be useful to others, who might even be able to offer some streamlining.

A scrap of irony

Posted in General on May 25, 2009 by jkiparsky

Bill Joy, quoted in “UNIX Today” magazine, August, 1984.

The trouble is that UNIX is not accessible, not transparent in the way that Interleaf is, where you sit down and start poking around in the menu and explore the whole system. Someone I know sat down with a Macintosh and a Lisa and was disappointed because, in a half hour, he explored the whole system and there wasn’t as much as he thought. That’s true, but the point is in half an hour, almost without a manual you can know which button to push and you can find nearly everything. Things don’t get lost. I think that’s the key.

Systems are going to get a lot more sophisticated. Things will tend to get lost unless the interfaces are done in the Macintosh style. People who use these machines may run applications but won’t necessarily be skilled at putting applications together. A lot of these people won’t even have access to the underlying UNIX system.

Some thoughts on market failures and society

Posted in General on May 21, 2009 by jkiparsky

Reading a recent column by Joe Nocera, (read it here) it struck me that while he’s right as far as he goes, he fails to take an important next step in his logic. I wrote this after reading the column, and when I came across it, I thought it was actually worth reading again, so here it is.

Roughly speaking, Nocera draws on the classic principle that markets are driven by risk, and attempting to eliminate the risk from markets will eliminate the virtues that markets bring – economic activity, jobs, houses, and iPhones, to name a few. So far, so good. And in this case, he observes that the impulse to rescue the victims of a Bernard Madoff from the results of his actions, while a fine and virtuous impulse, will only have the effect of encouraging poor investment decisions in the future. If you know that someone will bail you out if you lose it all, you don’t necessarily worry so much about losing it all. (If you’re smart, you’ll be more worried about losing a little or breaking even than losing big, because nobody will bail you out for breaking even.) So giving in to that impulse, laudable as it may be is ultimately a bad move for society as a whole, meaning for the people in that society. So far, I’m in agreement, but there is a further thought to think.

While risk is important in a market, and insulating investors from specific risk is a bad idea, a market in which the penalty for failure is destitution is a market which will also be insulated from risk. Just as there is no risk in a market where your losses are made good, nobody will take a risk in a market where failure has you selling pencils on the street. One must be able to take reasonable risks and survive a reasonable failure in order to have a climate where investment will flourish. (Other things are also necesary: for example, if a worker’s pay goes entirely towards their bills, they will invest nothing because there is nothing to invest)

This is to say that while a strictly market-based understanding of the current situation argues against a specific bailout of the Madoff investors (I’ll avoid the word victims- perhaps “survivors” would be better?) it also argues against the rigid individualist “I’ve got mine, Jack” capitalism of the Anarchist Republican Club, and for a safety-net capitalism of the New Deal style.

Given that most people who have some money to invest don’t have degrees in economics or finance or the time, inclination, and skills required for careful analysis of a particular investment vehicle, we can assume that people like Madoff will always exist, and that they will always be geniuses on the up side and caught out in the downturn. (Anyone reading the Times’ business section recently will note that there are a number of smaller cases very similar to Madoff’s turning up recently, like fish flopping in a drying tidepool as the tide recedes) Nocera is right: the suckers who put their money in the hands of the wrong slick-talking capitalist should not be “made whole” any more than the sucker who loses fifty bucks to a three card monte artist. But what he doesn’t say is this: there is a role for society as a whole in cushioning each of us from financial disaster. That role serves all of us, particularly those who will never rely on it directly, in that it frees up capital for investment and thus gives the people with bigger boats a deeper sea to fish in. Just as it is criminally insane to leave health care as an optional expense, impoverishing people, destroying their lives, and wrecking the economy (yes, folks, let’s say it together: stop the anarchist republicans before they destroy America!) it is also gross foolishness at best to allow the economy to be dragged down by the inevitable failures of some investors. Not just the failures that happen, and make for good photographs, but the ones that don’t happen, because the people who would have invested their money fail to do so, out of fear of becoming a good photograph of a real failure.