Moving a window that's off screen or otherwise hidden.

When using Windows, you may run into the problem of trying to access a window that is not visible because it is far off the screen or hidden under something. This is not a bad trick to remember, from Raymond Chen:

http://blogs.msdn.com/b/oldnewthing/archive/2009/05/11/9601136.aspx

The basic idea is select the window in the taskbar, then hit Alt-Space, M, hit an arrow key, and then move the mouse.

Unfortunately, it doesn't seem to work in the case where the window is hidden under a VMWare Player window, which occasionally commandeers my entire secondary monitor.

Multiple paths in a grant codebase block in a Java security policy file.

The documentation doesn't say this, but you can grant codebase "path" multiple paths by separating the paths with a colon (":"). For example,


grant codebase "/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext:/usr/java/packages/lib/ext" {
...
}

How to add a class to an existing JAR file.

Say we have a jar file start.jar and want to add a class to it.


$ mkdir jarbuild
$ cp start.jar jarbuild
$ cd jarbuild
$ jar -xf start.jar
$ rm start.jar
$ cp -r ~/secmgr .
$ find secmgr/
secmgr/
secmgr/manager
secmgr/manager/ProfilingSecurityManager.class
$ jar cmf META-INF/MANIFEST.MF mystart.jar *

Now you have a new jarfile that's the same as start.jar but with the ProfilingSecurityManager class in it. If you want, you can:


$ mv mystart.jar ../start.jar

Numbers everyone should know.

I reproduce below Slide 24 from Jeff Dean's keynote (PDF) at LADIS 2009.

L1 cache reference0.5 ns
Branch mispredict5 ns
L2 cache reference7 ns
Mutex lock/unlock25 ns
Main memory reference100 ns
Compress 1K bytes with Zippy3,000 ns
Send 2K bytes over 1 Gbps network20,000 ns
Read 1 MB sequentially from memory250,000 ns
Round trip within same datacenter500,000 ns
Disk seek10,000,000 ns
Read 1 MB sequentially from disk20,000,000 ns
Send packet CA->Netherlands->CA150,000,000 ns

Installing rubygems on CentOS 5.5

Here is how to get rubygems working on CentOS 5.5.

  1. Remove the old Ruby packaged with CentOS.
    $ sudo yum erase ruby
  2. Make sure you have zlib and zlib-devel installed.
    $ sudo yum install zlib zlib-devel
  3. Install a newer Ruby like 1.8.7-p299.

    $ wget http://core.ring.gr.jp/archives/lang/ruby/1.8/ruby-1.8.7-p299.tar.bz2
    $ bunzip2 ruby-1.8.7-p299.tar.bz2
    $ tar xf ruby-1.8.7-p299.tar
  4. The following is probably not optimal, but I do it anyway. In the ruby directory, edit ext/Setup and uncomment out the packages that interest you. I like iconv, openssl, socket, syslog, and zlib. Make sure you have zlib. The alternative (probably recommended) method is to not statically link this modules and instead compile and install the packages individually, but I forget how to do that and didn't have time to learn.

  5. Install ruby.

    $ make
    $ make test
    $ sudo make install
  6. Ensure ruby is in the path. ruby likes to install itself in /usr/local/bin, which CentOS usually doesn't have in the path.
    $ which ruby     # Not found?  Add /usr/local/bin to your $PATH.
  7. Ensure ruby is installed.
    $ ruby -v
  8. Install rubygems.

    $ wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
    $ sudo ruby setup.rb
  9. Ensure rubygems works.

    $ gem list # Doesn't work? Error about zlib? Make sure you have zlib-devel installed (see step 2)! Then make; make install ruby again.