Spencer Bliven

Thoughts and Research

Java Interpreters

April 29, 2011 | Posted in Technology, Tagged , ,

I’m a big fan of the iPython interpreter. I like having an interpreter running while I develop for prototyping and debugging. Since I currently develop in java primarily, I thought I’d take a look at what java interpreters are available. I had three main features which I wanted. In order of importance:

  1. Basic history and command editing, at least as good as bash.
  2. Autocompletion. At a minimum, autocomplete built-in commands and previously seen code. Ideally, autocomplete instance methods from loaded libraries.
  3. Eclipse compatibility. Ideally, it should run as a eclipse plugin. Baring that, it should be able to find the most recently compiled version of class files (for instance, through a local maven repo).

Sadly, none of the solutions I found fulfilled all three of my requirements.

1. Groovy

Groovy is a dynamic language that runs on the JVM. Java code is valid Groovy code, but groovy includes a lot of nice dynamic features ala python or ruby, such as dynamic typing. The community feels very rails-like, with a popular agile web server (Grails) which holds most of the die-hard interest, and plenty of hip conferences.

Pros: Dynamic language, fully compatible with java. Comes with an interpreter. Active development, including a MacPorts installer. Strong community. Bash-like history feature.
Cons: Hard to configure correctly (classpaths, maven integration, etc). No autocompletion, no eclipse integration.

2. BeanShell

BeanShell is a java interpreter. It’s actually quite similar to Groovy, but positions itself as a dev tool rather than a new language. The documentation refers to autocompletion features, but they didn’t work for me. It only seems to have been developed for 6 months in 2005 by two developers, so that’s not surprising.

Pros: Bash-like history feature. Embeddable!!!! (<--this is useless to me.)
Cons: No development since 2005, no autocompletion, no eclipse integration, tricky to get classpath right.

No autocompletion? Did you try jLine, you ask? Yes, I did find and follow those arcane instructions for wrapping BeanShell with the java version of readline. It was a pain, and it didn’t even autocomplete words from my history. FAIL.

3. EclipseShell

The command-line tools didn’t seem to be cutting it, so I checked out EclipseShell, which is an eclipse wrapper for BeanShell. This one almost worked, but feels like a beta or first release. Screenshots show autocompletion, but it sure doesn’t work on current versions of eclipse. The interface tries to be this matlab-style cell format, but just looks like a text editor. In short, good idea but no followthrough.

Pros: Edit like a text file, eclipse integration, easy installation.
Cons: broken autocompletion, no recent development.

My location over the past year

April 22, 2011 | Posted in Technology, Tagged , ,

Recently there has been much ado over the discovery that the iPhone keeps a log of everywhere you’ve been. I choose to push my paranoia aside and focus on the benefits of this: a cool app that lets you visualize your travels.

Here’s my map, from last june through the present. You can see my route on 8/26-27/2010 when I drove from Seattle to San Diego. And there’s a video below! A few notes:

  • Observations are binned into rectangles of 1/100 of a degree. The size of the circles represents the number of observations in that square centidegree over the time period.
  • Location is calculated by cell towers rather than GPS, so it’s not very accurate. For instance, I have never been to Eureka, CA, despite a number of observations to the contrary.
  • The phone doesn’t seem to log locations unless you switch towers, so the movie skips over periods of time where I stayed in one place
  • I had to modify the source code slightly to get the movie below to progress in 1-hour intervals. The original showed 1-week timesteps in a half-hearted attempt to prevent housewives from using it to spy on their husbands.

Secure Synergy

April 15, 2011 | Posted in Technology, Tagged , ,

Synergy is a really cool little program that allows one to share a keyboard, mouse, and clipboard seamlessly between multiple computers. I have it set up at work so that I can use my desktop keyboard and mouse to control my laptop.

I’ve been happy with it, but this morning it occurred to me that anyone on my work network could theoretically view all my keystrokes. So today I implemented a script to securely connect to the synergy server from my laptop. It is based on a suggestion from the synergy FAQ.

#!/bin/bash
# Opens a secure synergyc connection
# 
# usage: synergyc_secure server [synergyc options]
#
# Author: Spencer Bliven

SERVER="${1:-desktop}"
shift
LPORT=24800
RPORT=24800

ssh -x -f -L $LPORT:localhost:$RPORT -o ExitOnForwardFailure=yes \
    "$SERVER" 'sleep 10' &&
synergyc "$@" localhost:$LPORT