Fixing a little VPN annoyance

I’m writing this in a coffee shop, and when I’m using a public wireless network, I like to secure my network traffic using a virtual private network (VPN) that I set up on my server at home. Without this, anyone else close by could spy on what I’m doing (including seeing passwords I’m sending to badly-secured web sites). Unfortunately, the connection appears to go bad after a short while, and it took me weeks to spend the minute it took to find a fix.
(more…)

11:54 am — Geekery, ToysComments (0)

The Android fonts on my desktop are beautiful

Droid family font sampleI’ve been tinkering with developing software for the Android phone platform (and loving my G1 phone that runs it)… the Android folks at Google hired Ascender to create a new font family for the phone, the only family that the phone comes with. Here’s a sample from Ascender’s press release.

It occurred to me that because the fonts were designed for legibility at small point sizes, Droid Mono might be a good replacement for the terminal font I do much of my programming in. It turns out that the whole family makes excellent replacements for the default fonts on my Ubuntu systems: they’re so legible that I’ve been able to reduce the default sizes as well, effectively giving me more screen real estate. Several times in the last couple of days, it’s occurred to me how much more beautiful my working environment is, now that I’m looking at a well-designed font.

You can get the fonts from within the Android SDK, but another helpful blogger has put them up as a separate download. (If you’re installing them on Linux like I did, put them in a folder in /usr/share/fonts, then do “sudo fc-cache -f -v” to get the system to notice them.)

11:15 am — GeekeryComments (0)

Android AIDL regeneration

I’m working on a couple of Android projects; one has an Android IDL file (.aidl) for a service, and for some reason, the development environment didn’t automatically generate the corresponding .java file from it. I wasn’t able to figure out what caused this, and recreating the .aidl file didn’t fool the IDE into doing it, nor was I able to find a solution to this with the usual Googling.

I did find that right-clicking the project in the hierarchy and choosing “Android Tools” -> “Fix Project Properties” fixed this. Subsequent changes to the .aidl file automatically regenerated the .java file, too, so that’s nice.

12:37 pm — GeekeryComments (0)

Clearing apt-cacher’s cache

I frequently reinstall Ubuntu from scratch, so I’ve set up apt-cacher on my fileserver to cache the packages I install - this not only reduces my impact on the mirrors, but also speeds up my installs.

Occasionally, though, I see strange problems during installs: apt-get install retrying the download of an apparently-cached package. I haven’t figured out what’s wrong, and frequently I just want to get the reinstall going again. In these situations, it seems optimal to just dump the cache and start over; I haven’t found clear documentation of how to do this, but in case it isn’t obvious, this works for me (my cache is in /var/cache/apt-cacher, and I run it as www-data):

# Stop the service
sudo /etc/init.d/apt-cacher stop
# Move the old cache out of the way, so we can delete it 
# in the background (it can take a while)
sudo mv /var/cache/apt-cacher /var/cache/apt-cacher.old
sudo rm -rf /var/cache/apt-cacher.old &
# Make the new cache hierarchy, and set its ownership properly
sudo mkdir -p /var/cache/apt-cacher/{headers,import,packages,private,temp}
sudo chown -R www-data:www-data /var/cache/apt-cacher
# Restart the service
sudo /etc/init.d/apt-cacher start

Update: I found this blog post helpful for manually removing troublesome packages from the cache.

11:25 am — GeekeryComments (0)

Rails script/performance/request needed a little help

While following another great Ryan Bates Railscast, I had a couple of problems on my Ubuntu 8.04 development machine:

  • Rails 2.1.0’s ActionController wants version 0.6.1 or later of the ruby-prof gem, but the usual gem repositories only have 0.6.0 now. I found suggestions to install Jeremy Kemper’s fork on Github, but though I’d added GitHub as a gem source, installing jeremy-ruby-prof didn’t work because that installed his version with that name, which didn’t help ActionController. What worked was:
    sudo gem uninstall jeremy-ruby-prof # be sure to uninstall old attempts!
    git clone git://github.com/jeremy/ruby-prof.git
    cd ruby-prof
    rake gem
    sudo gem install pkg/ruby-prof-0.6.1.gem
  • Then, script/performance/request ran, but generated several strange error messages instead of producing results:
    Couldnt get a file descriptor referring to the console
    Could not get a file descriptor referring to the console
    Couldnt get a file descriptor referring to the console
    Could not get a file descriptor referring to the console
    

    This turned out to be because script/performance/request wants to use ‘open’ to open its output files (a text file and an HTML document), but on Ubuntu, /usr/bin/open is a link to /usr/bin/openvt, which didn’t do what we want (and generated those error messages). I’m not sure what else uses ‘open’, but this did the right thing: it lets Firefox open the files:

    sudo ln -sf /usr/bin/firefox /usr/bin/open
10:29 am — GeekeryComments (1)

named_scope, joins, & includes

I used Rails 2.1’s named_scope to implement various ways to sort things on OsoEco. When I implemented “most discussed” on the Question model (questions have many comments), it involved joining in the comments table to count comments for each question. Initially, it looked something like:
named_scope :most_active, :joins => :comments, :group => "questions.id", order => "count(questions.id) desc"

That caused a problem, which the Pivotal Labs folks also commented on today:

When using named_scope, adding a :joins option will “mix-in” all of the attributes from that join table into your retrieved object, potentially overwriting any colliding attributes (including id … ouch!). There was consensus that this was a valuable feature, when used “properly”. Adding :select option can avoid this, or use :include.

Like they said, I fixed this with :select — the second try looked like this
named_scope :most_active, :select => "questions.*", :joins => :comments, :group => "questions.id", order => "count(questions.id) desc"

That worked (and fixed that problem), but it occurred to me that if my controller wanted to :include additional tables to add onto this scope (and that’s one of the cool things that named_scope enables), it wouldn’t work: Question.most_active.scoped(:include => :comments) raises a bad-SQL exception.

Fixing this required a bit of table aliasing, and led to this:
named_scope :most_active, :select => "questions.*", :joins => "left join comments as comments_for_count on comments_for_count.question_id = questions.id", :group => "questions.id", order => "count(questions.id) desc"

This worked, even with the :include added in a subsequent (anonymous) scope.

1:51 pm — GeekeryComments (1)

Hiding in plain sight

In writing my bio for Portland on Fire, I mentioned that I’d hidden my first name upside down in the “Read Me” file icon used on Macintosh during the late 1980’s: millions of people clicked on this icon to get help, and as far as I know, none of them noticed my name. The Wikipedia page for TeachText (the application I’d written which provides this icon) doesn’t mention this trivia (nor that I wrote it!).

After several years, TeachText was replaced by SimpleText, written by Tom Dowdy; Tom rightfully replaced my name with his; I’m just happy he kept the same style of icon. (I do rib Tom that TeachText was only 19K, where SimpleText was several times that in size.)

UPDATE: Sadly, I learned recently that Tom passed away. I’ll miss him: like many people I got to work with at Apple back then, he was smart and fun. I looked forward to seeing him every year at Apple’s developer conference, where we shared the distinction of being the only “Stump the Experts” experts who’d attended every session of that panel over the years.

1:43 pm — GeekeryComments (4)

Remote debugging with Wing

I just wrote up a bunch of notes on the Chandler wiki about remote debugging with Wing (the Python IDE), having just finished a session where I fixed a problem that only occurred on an automated-build machine hundreds of miles from here (with two firewalls between me and it).

The Wing docs treat remote debugging as an “advanced topic”, but it really works well once you get over the setup hurdles. Even if you’re just doing remote debugging from a different machine on your desk, it’s a real boon when working on UI code to not have your debugger’s mouse and keyboard interfering with the target’s mouse and keyboard… so give it a try.

1:27 pm — Geekery, WorkComments (0)

Twittering

I’ve given up and signed up at Twitter - you’ll find my stream of quotidian updates linked from the sidebar on the left, there, as well as here. (I also set up a stream forwarded from Celebrity Death Beeper - I won’t know if it’s working until someone famous dies, though.)

6:35 pm — GeekeryComments (0)

My Chumby transit widget

I just got a Chumby, primarily to let me create this widget to run on it: it’s a clock that displays predictions of when the Portland Streetcar will be passing the stops nearest my home. Green dots are northbound; red are southbound. Armed with this, I know exactly when I need to leave the house to avoid a long wait.

(I wrote this using OpenLaszlo - I started with a “clock” demo of theirs, and added some dots and a bit of data retrieval.)

12:47 pm — Around Here, GeekeryComments (3)
Next Page »