Goodbye, Laurie

Laurie Poulson taught the first linguistics class I ever took at the University of Washington. I remember her introduction, in which she told all her students to just call her Laurie, unless for some reason they absolutely could not, in which case she would reluctantly allow “Mrs. Poulson”. Being a college freshman and having grown up in a culture where all people of higher social status must be addressed by a title, I absolutely could not, and happily called her Mrs. Poulson. She was wonderfully cheerful, always took the time to explain things carefully and had a knack for distilling difficult concepts and making them easy to understand. It was a great class.

After the quarter ended, I would occasionally run into her on campus say, “Hi, Mrs. Poulson!” She would always turn around and sigh, with a cheerfully exasperated expression, saying that she knew it was me, because I was the only person that ever called her Mrs. Poulson and to please just call her Laurie. It was only after I started graduate school that I finally relented and called her Laurie instead.

I once saw her at one of the cafeterias on campus reading a paper and stopped by to say hi and ask her what she was working on. She was reading a paper on aspect, which was, at the time, a little over my head. But even so, she stopped reading for a couple minutes to explain what aspect was, and what she was reading.

In graduate school, I gave a talk on a research project I was working on. I was ill-prepared, stuttered throughout the whole talk, and was not able to field questions very well. It was a pretty spectacular train-wreck. After the talk, she pulled me aside and said, “Joshua, let me tell you a story.” She started telling me about a time she once gave a practice talk and similarly didn’t do as well as she had hoped. But then, she worked on her talk some more and by the time the conference rolled around, she was able to speak with confidence. It was just what I needed to hear.

Laurie passed away just a couple days ago.

Laurie, thank you for being a wonderful teacher, a colleague, and a friend. I’ll always remember your kindness and encouragement, and appreciate how you were always were genuinely interested in me and in how I was doing. I’ll miss you.

Posted in Random | 1 Comment

Survival Phrases

Screenshot of Survival Phrases app

I wrote an Android app called Survival Phrases for playing short survival phrases in different languages for travelers. It’s not very complicated (or comprehensive, for that matter), but it was fun to write. It currently only has English, Mandarin and Italian, but I may add more languages in the future. It’s actually been up on the Google Play store for awhile, but I just recently open sourced it. Check it out and let me know what you think! (Or better yet, fork and add more languages/features!)

Posted in Random | Leave a comment

Android and basic authentication

I’ve been trying to play with the Github API in an Android app, but a couple wrenches in the machine made it a lot more difficult than anticipated. Every request I was making returned a 404. At first I thought the Android keystore didn’t have Github’s SSL cert and tried to create my own keystore. Eventually I figured out that it was basic authentication that wasn’t working correctly, and not SSL. If only Github’s API returned a 401 Unauthorized instead of a 404 Not found.

Anyway, many many hours later, I finally found this Stackoverflow answer which gave me the magic incantation for submitting an http request with basic authentication in the header:

String username = ...
String password = ...
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);

HttpRequest request = ...
request.addHeader(new BasicScheme().authenticate(creds, request));

I’m blogging it so I remember how to do it later.

Posted in Java, Programming, Tech | 2 Comments

Folding in Haskell

Trying to learn Haskell, round 2.  The first time around, I had a lot of difficulty understanding the difference between the three different types of folds.  This time, for some reason, it’s a lot clearer.

  • foldl is left associative
  • foldr is right associative
  • foldl’ is left associative, but calculates the value of a thunk immediately instead of pushing it onto the stack.

This link was particularly helpful in understanding the difference between the three.

Understanding the difference in implementation between the three folds is good, but in daily usage, it’s much more useful to know when to use them. Shamelessly copied from this link, but properly attributed, the general rule of thumb is here:

  • foldr – Partial results, infinite lists, lazy operators
  • foldl’ – Finite lists with strict operators
  • foldl – Otherwise (like reverse)

Anything with partial results, infinite lists or lazy operators should be done with foldr, because recursive calls are on the tail of the list and you can get the initial values by lazily evaluating only part of the list with foldr.

foldl’ is used for finite lists with strict operators because it is tail-call optimized and doesn’t create large thunks.

foldl is used much less, for other functions like ‘reverse’.

Posted in Haskell, Programming, Tech | 3 Comments

Selecting audio output devices in ALSA

I’m beginning to appreciate how much Ubuntu does out of the box more and more as I find more little things in Crunchbang that require a non-trivial amount of internet scouring and trial/error to figure out.  Ubuntu by default uses pulseaudio as the Linux soundserver, and Ubuntu provides a pretty GUI for switching between output audio devices.  Crunchbang uses ALSA by default, and switching audio devices is slightly more difficult.

The default output device is set through the ~/.asoundrc file.  You list the devices typing “aplay -L” in terminal.  The output looks something like this:

front:CARD=PCH,DEV=0
    HDA Intel PCH, CONEXANT Analog
    Front speakers
front:CARD=Audio,DEV=0
    Display Audio, USB Audio
    Front speakers

The first entry is my laptop’s internal speakers. The second is the Apple Cinema Display connected to my laptop via the DisplayPort. My .asoundrc looks like this:

pcm.!default front:Audio # apple cinema display
# pcm.!default front:PCH # laptop

I switch devices by commenting and uncommenting out the relevant lines for selecting what device I want. Switching a default device by configuration file requires restarting the process that uses sound. For playing Youtube videos in your browser, this means restarting the browser whenever you switch an audio device. (There might be a better way to do this, I haven’t figured it out yet.)

The above method works for all processes that require sound that are started by me. However, I also use mpd/mpc as my music player, which is a background service that doesn’t consult ~/.asoundrc for sound settings. Output devices are specified in /etc/mpd.conf. The syntax for setting an output device in mpd.conf is “device “hw:x,y”, where x is the sound card and y is the output device. This is slightly different from the information you provide for ~/.asoundrc; you get this information from “aplay -l” (note the lower case L). The output of “aplay -l” looks like this:

**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CONEXANT Analog [CONEXANT Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: Audio [Display Audio], device 0: USB Audio [USB Audio]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

The chunk of my mpd.conf that is relevant to output devices looks like this:

audio_output {
  type		"alsa"
  name		"My ALSA Device"
#device		"hw:0,0"	# internal speakers 
  device		"hw:2,0"	# apple display
  format		"44100:16:2"	# optional
  mixer_device	"default"	# optional
  mixer_control	"PCM"		# optional
  mixer_index	"0"		# optional
}

Again, I comment and uncomment the device lines to switch audio devices. Switching audio devices for mpd requires a service restart, just like for the processes that consult ~/.asoundrc, which I do with “sudo service mpd restart”.

These links were useful in helping me figure out what settings to use:

Posted in Linux, Tech | Leave a comment

Two dots, three dots

Just so I don’t forget, in Ruby:

  => (1..4).to_a
  
[1, 2, 3, 4]
=> (1...4).to_a
[1, 2, 3]

Two dots is inclusive, three dots is exclusive. (“in” has two letters, “out” has three?)

Posted in Programming, Ruby, Tech | Leave a comment

Cursor sizes in GTK and X

I’ve been using Crunchbang Linux for the past week, a lightweight Debian offshoot that packages with OpenBox.  The transition from Ubuntu has been fairly seamless, considering I’m still using Awesome anyway.  I’m liking it a lot, I was able to get a more recent wifi driver compiled for my laptop which means I’m having a lot less problems with my wifi connection dropping all the time like it did in Ubuntu.  (To be fair, this new driver would have probably compiled in Ubuntu as well.)

One of the gotchas I ran across was that somehow my mouse cursor settings got screwy and my cursor would look huge in some windows and not in others.  At first, I thought it was only GTK windows that resulted in the absurdly large cursor, but it turned out to be certain cursors in X windows too.  The following forum links helped: 

I added the following line to my .Xresources and .gtkrc-2.0:

# .Xresources

Xcursor.size: 16
# .gtkrc-2.0

gtk-cursor-theme-size=16 

…and all was well.

Posted in Linux, Tech | Leave a comment