Plain Old Java Queries on java.net

POJQ: Plain Old Java Queries project approved by java.net. This is an open source implementation of Safe/Native queries, launched by Wes Biggs.
Object Database Management Systems portal announced, which features Native Query paper.

Creating EPS on windows

I have had lots of problems clipping pictures. I am surprised that you have not been having problems with your pictures being inside a large white border (the size of the powerpoint slide).
I didn't know you could use EMF. How do you convert it to PS?
What I do is print the picture to a postscript printer but use the "save as file" option. This produces a PS file. THen run this through Ghostview and save as EPS (with automatic cropping). I get the best results when I have a PowerPoint slide embedded inside a Word document!

Native Queries for Persistent Objects, A Design White Paper

Released Native Queries for Persistent Objects, A Design White Paper with Carl Rosenberger

Rapid Technology Transfer

When I defined Safe Queries for Java I thought that it might be an idea that could be applied relatively soon to solving real needs of industry... but I didn't think it would be shipping so quickly. Then I found out about db4objects. They are implementing the idea as a key component of their next product release this fall. We have made some improvements to the idea, described in a new white paper, Native Queries for Persistent Objects written with Carl Rosenberger.

Let me know what you think.

ODBMS.ORG

ODBMS.ORG Launches Educational Portal on Object Databases High-Profile Experts Help Meet Growing Demand for Free Educational Resources on OO Database Technology
We have released a preliminary interpreter for Orc, an Orchestration Language.

A long search

In trying to solve the problem mentioned in the previous post, I did a lot of Google searching. Some things are hard to find, because they can be described a lot of ways but use words that also have many other uses. The ideas "currently running script" and "directory of something" are quite common and can be combined in lots of ways. But I wanted just one partcular meaning, and it took me a while. Eventually I found enough pieces of the answers to put together my solution. Here are the queries I ran:
Google QueryTime
shell-command csh directory-of-shell3:22:15 PM
shell-command csh directory3:22:21 PM
shell directory-of-command3:23:09 PM
shell directory-of-the-command3:23:41 PM
sh unix3:28:06 PM
sh script3:28:29 PM
csh "path to command"3:29:32 PM
csh "path to the command"3:29:57 PM
csh "path of the command"3:31:36 PM
csh "path of the current"3:32:04 PM
csh "path of the current command"3:32:18 PM
csh "path of the current shell"3:32:24 PM
csh "path of the current batch"3:32:32 PM
csh "path of current command"3:32:39 PM
sh path command that is running3:32:52 PM
unix path command "that is running"3:33:14 PM
unix path "file that is running"3:33:36 PM
csh "file that is running"3:34:39 PM
bash "file that is running"3:35:50 PM
shell directory-of-the-command3:36:12 PM
csh jar files3:36:48 PM
csh locate-jar files3:39:43 PM
csh locate-jar3:39:47 PM
csh find-jar3:39:51 PM
csh find-jar same-directory3:40:07 PM
csh jar same-directory3:40:10 PM
bin/sh same-directory3:41:20 PM
unix csh3:44:02 PM
unix csh reference3:44:14 PM
directory-where the command3:51:51 PM
directory-where the command csh3:52:02 PM
csh "path the current command"3:53:51 PM
csh "path to the current command"3:54:00 PM
unix "path to the current command"3:54:07 PM
unix "path to the executing command"3:54:11 PM
unix "path to the executing"3:54:15 PM
sh "path to the executing"3:56:22 PM
path to the executing3:57:06 PM
path to the executing unix3:58:08 PM
unix current process4:00:16 PM
shell current-process4:00:31 PM
shell "path to the executing"4:04:19 PM
shell "to the executing"4:06:06 PM
shell "of the executing"4:06:20 PM
shell "path of the executing"4:08:49 PM
shell "path of the running"4:10:51 PM
shell "path of the running" unix4:10:58 PM
shell "path of the running scriopt" unix4:12:24 PM
shell "path of the running script" unix4:12:26 PM
path "running shell"4:15:39 PM
path-of "running shell"4:15:53 PM
path-of running shell4:16:46 PM
path-to running shell4:16:50 PM
path to running shell4:16:52 PM
path of running shell4:16:55 PM
path of running4:16:59 PM
java relative-to-shell4:17:27 PM
java shell same-directory4:17:44 PM
bash "running shell"4:18:53 PM
bash "path of running"4:19:31 PM
bash "path to running"4:19:45 PM
bash path to shell4:20:06 PM
bash "path to script"4:21:40 PM
bash "path of script"4:22:00 PM
script to identify it's location4:25:29 PM
$0 alias lookup path4:30:54 PM
$0 alias path4:33:04 PM
csh scripting4:37:57 PM
csh scripting first word4:38:22 PM
dirname $04:41:14 PM
fletcher mattox4:43:47 PM
sh shell command files if4:50:20 PM
sh shell command files "if ("4:51:41 PM
sh shell command "if ("4:51:52 PM
introduction shell4:52:23 PM
introduction shell sh4:52:26 PM
introduction shell csh4:53:44 PM
tsh4:54:40 PM
tsh shell scripting4:54:59 PM
sh shell scripting4:55:02 PM
sh builtin variables5:00:50 PM
shell standard variables5:01:37 PM
determin unix os5:02:18 PM
determine unix os5:02:20 PM
command to find unix os5:02:42 PM
command to find unix os version5:02:46 PM
command unix os version5:02:51 PM
command unix os-version5:03:00 PM
sh substring5:04:09 PM
directory of a batch file5:09:48 PM
directory "running batch file"5:09:56 PM
directory "running batch file" -pid5:10:29 PM
directory of running batch file5:10:58 PM
cmd file directory5:11:07 PM
directory "running command" cmd5:11:24 PM
directory "running command"5:11:28 PM
directory "running command" windwos5:11:30 PM
directory "running command" windows5:11:32 PM
directory "of running" command windows5:11:53 PM
command arguments batch files5:12:20 PM
dspx5:15:51 PM
dspx batch5:15:55 PM
windows batch varialbes5:16:17 PM
windows batch variables5:16:19 PM
windows batch variables "~"5:16:32 PM
windows batch no echo off5:19:49 PM
bash variable substring replacement8:11:44 PM
windows shell command8:19:06 PM
location of batch file8:27:11 PM
location of current batch file8:27:25 PM
location of running batch file8:27:28 PM
directory "running batch file"8:27:35 PM
directory "running batch file" -pid8:27:42 PM
find directory "running batch file" -pid8:31:29 PM

How to find the directory of a running shell command

I want to distribute some Java software in a way that is easy to use. The software depends upon some libraries, so I need to set the class path before running Java. I created a simple command ile (for Unix and Windows) to launch the application. I assume the libraries are in the same irectory as the command file, but had a hard time finding out what directory the command file is in. I didn't want the user to have to set up a path or do anything to install: just expand a ZIP file and go.

Eventually I found an answer. Here are the two versions. I have tried it on debian, windows and cygwin. These commands run the class foo.Foo from the foo.Jar, which also uses lib/mail.jar.

-----------------foo.bat for Windows -------------

@ECHO OFF
set dir=%~dp0%
java -cp "%dir%/foo.jar;%dir%/lib/mail.jar" foo.Foo %1
---------------------------------------------------

I out to know what %~dp0% means, but I have to admit I don't. I'll look it up later.


------------------ foo.sh for Unix -------------------

#!/bin/bash
dir=`dirname $0`
os=`uname`
if test ${os:0:6} = "CYGWIN"
then
if test ${dir:1:8} = "cygdrive"
then
dir="${dir:10:1}:/${dir:12}"
fi
java -cp "$dir/foo.jar;$dir/lib/mail.jar" foo.Foo $*
else
java -cp "$dir/foo.jar:$dir/lib/mail.jar" foo.Foo $*
fi
---------------------------------------------------------

Make sure the line endings are correct, and the file has execute access.


Note that java has two kinds of separators for the class path depending on whether it is unix or windows. This by itself is pretty annoying, but it gets worse: when you run cygwin it is a unix OS but it uses the windows separator. Since dirname can return \cygdrive\c\... but this is not understood by Java, I have to change it to c:\... But Java seems to understand / or \ as the separator, which is good. Lots of fun!

I am not sure that these will work everywhere. But it is a start.
They work in these cases:

  • executing the command from an absolute path
  • executing the command via an alias
  • putting the directory on into your system PATH
Shouldn't this be easier?
I will be attending OOPSLA this fall (as always). Let me know if you want to meet there.

AppleScript

I'm working on an article on the history of AppleScript for HOPL III. I led the team that designed and implemented the language, but then we all left Apple. That was during the bad times when Jobs was away.

AARRRGGGGHHHHH

I can't stand it any more. Why does is it so difficult to install experimental software???? Granted, a lot of the stuff I want to try out is academic/experimental, but IT SHOULD NOT BE THIS DIFFICULT! The next time I download a package like this I'm going to tear my hair out:
* A README file that doesn't say what the software does!
* An INSTALL file that goes on for pages and page about cofiguration settings, tweaks to make files, editing this and that...
* After trying to complete the 20 steps correctly, the thing doesn't work!
* A few hours of trying to debug makefiles, configuration files, etc
Give up....

Oh well. I'm going to keep a list of the things I try that I can't get to work:
YAMPA I'm sorry this one has to be first. But the link to the install file (SOE.msi) is broken. I peeked in the folder and found one, then downloaded lots of other stuff, but couldn't get it to work.

ACL2, Emacs and Eclipse

I will not say anything too negative about Emacs here. I suspect my peers might think badly of me simply because I don't use Emacs. But I've been living the the world where text selections should be visible, status bars are drawn by the GUI, and cut/copy/paste are control x/c/v for too long. I just can't handle Emacs.

But I've always liked being able to run a command in an editor window. An editor I wrote in college for VMS, a derivative of Z from Yale, had this features. And of course Emacs does too.

This is a problem, because using ACL2 effectively pretty much requires a good shell window. So I've been hunting around for a solution. Then I thought of Eclipse.

Eclipse has External Tools to run processes. I thought they always ran in batch mode. But I found a trick to run the process in an interactive mode, just like Emacs.

To set it up, just do this:
  1. From the Run/External Tools/External Tools... menu, create a new tool
  2. Set the program location to be the path to the ACL2 executable
  3. Set the working directory to be your directory (I use a variable representing the current project)
  4. Set the arguments to "-". This is the key to make the process take interactive input from the console.
  5. Then just run the tool and ACL2 appears inside a window in eclipse.
I put my input file and the ACL2 window side-by-side and then copy/paste my text.

If you use the Scheme plugin and associate the Scheme Editor with .lisp files (using Preferences/File Assocations), then you will also get paren balancing, syntax coloring and formatting. You have to define some custom settings for ACL2, but this is easy to do. Send me a note and I'll give you my config file.

Oh, and here's what it looks like in action.

ACL2 newbie

I'm learning ACL2: after spending a day understanding what most people feel when they try to program a computer (why the *#@* doesn't it accept my program?), I seem to have a breakthrough that at least allows me to write some functions and make a little progress. Mostly this involves learning "The Method", and becoming a lot more sensitive to all those nagging little corner cases that don't normally ever happen. But of course, the proof system doesn't know they can't happen..

I've gotten it to accept a dozen or so functions, which for me was non-trivial. I'm having trouble now because I need to define a custom :measure on my last function, and I don't understand enough about how ACL2 does rationals (rationalp, natp, numberp, o-p, o<, etc). I assume it will make sense if I read the doc...

It's fun, in a strange way, to be a newbie... I started programming so long ago I have forgotten what it is like to not know how. But ACL2 is letting me remember!

My Vonage Disaster

Last August I decided to sign up for Vonage, to try it out. I made a few calls and it seemed to work. So I requested that my home number be converted to a Vonage number. I waited and waited. Nothing happened. I called them every month or so for the next six months to check the status, but nothing happened. Perhaps SBC was not willing to make the transfer. Perhaps Vonage dropped the ball.
Updated Date: Number Transfer Progress History
August 15, 2004: Awaiting Letter of Authorization
November 24, 2004: Letter of Authorization (LOA) Received
November 24, 2004: Transfer Sent to Carrier
November 24, 2004: Transfer Sent to Carrier
April 18, 2005: LNP Transfer Cancelled
All this time I was paying service charges for a service that didn't work. The gave me a months credit when I asked for it. Finally I was annoyed and asked them to cancel the service. But I couldn't find the original box to send the equipment back, so they charged me for that. $386 later I have nothing but a useless Vonage box.

I guess that is one way to make money...
I've noticed that all my posts so far have been tips, tricks and annoyances. There are several reasons for this:

1) I have a backlog of useful bits that I feel I should post.
2) I feel guilty that I've been using solutions to problems I find on the internet, but haven't been posting my own.
3) Perhaps I'm still getting used to the medium.

Eventually I will start writing about higher-level issues....

Windows backups

I had a disk completely die, and my backups are not as good as they should have been. Fortunately, the data recovery people know their job.

This motivated me to figure out Windows backups. I am not sure that this is the greatest backup script, but it works for me. Here is what it does:
* creates a full backup every week (on monday)
* creates differential backups (with changes from the full backup) every day
* cycles N different backups so you have several weeks/days of backup
* copies the files from one backup media to another, MASTER to SECOND
* just requires one scheduled job
* uses a single selection of files for all backups

To set this up:
* create MASTER and SECOND directories and set the paths in the script
* use NTBackup.exe to create the file "backupList.bks" which lists what files to back up
* put the script into the MASTER directory
* schedule a job to run it every day

This script is provided as is, with no guarantee that it will work for you. Let me know if you have improvements.

set MASTER=K:\Backups
set SECOND=L:\Backups
set keepWeekly=2
set keepDaily=2

REM set test=echo to test the script
set test=

rem echo Backup# %x%

IF "%DATE:~0,3%" == "Mon" GOTO WEEKLY

ECHO Running Daily backup
for /F %%m in (%MASTER%\dailyNumber.txt) do set /a x="%%m"
set type=differential
set file=Daily%x%
set /a x="( %x% + 1) %% (%keepDaily%)"
echo %x% > %MASTER%\dailyNumber.txt

goto DONE
:WEEKLY

ECHO Running Weekly backup
for /F %%m in (%MASTER%\weeklyNumber.txt) do set /a x="%%m"
set type=normal
set file=Weekly%x%
set /a x="( %x% + 1) %% (%keepWeekly%)"
echo %x% > %MASTER%\weeklyNumber.txt

:DONE

%test% ntbackup.exe backup "@%MASTER%\backupList.bks" ^
/n "%file%" /d "%DATE%" ^
/v:no /r:no /rs:no /hc:off ^
/m %type% /j "%file%" /l:s /f ^
"%MASTER%\%file%.bkf"

%test% copy /Y /B "%MASTER%\%file%.bkf" ^
"%SECOND%\%file%.bkf"

set local=%USERPROFILE%\Local Settings
set data=%local%\Application Data\Microsoft
move "%data%\Windows NT\NTBackup\data"\*.log ^
"%MASTER%"

Bad Signature formatting in outlook

Do you have trouble with your signature having the wrong format in Outlook? Mine had the "paragraph" style instead of "normal", so it looked different from the rest of my messages.

Well, I figured out that you can edit the HTML in the files where the signatures are stored. Just take out the paragraph marks and everything works much better!

I found the files in
C:\Documents and Settings\\Application Data\Microsoft\Signatures

Example Application

I recently wanted to get some data to select program committee members for a conference. I decided to estimate which authors had the most impact with papers published at the conference in the past. After some experimentation, here is what I wanted to do:

Use Google to estimate how many pages refer to each paper published at the conference, then analyze this data to find the most cited authors.

Here's what I did:

1) First I needed a list of papers. First I thought of scraping HTML from DBLP. Then I noticed that DBLP contains bibtex items, so I used WinHTTrack Website Copier to download bibtex files from DBLP for that conference. This was not too hard, but I did have to play with the configuration a fair bit to get it to work. This is because the bibtex files are stored on a different server.

2) I had to get the bibtex out of the HTML pages. I decided to write an XSLT script to do this, but had a problem because HTML is not valid XML. After a few false starts, I was able to download, compile and run the .NET Html Agility Pack to clean up the HTML. Then I concatenated all the files and ran this XSLT script over them:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="ascii" method="text">
<xsl:template match="/">
<xsl:for-each select="//pre">
<xsl:value-of select=".">
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

3) I then had a bunch of bibtex files. I needed to extra the titles and authors. So I decided to the bibtex to XML. After a few false tries, I found bib2XML and converted my files to XML. However, I later found that bib2XML does not properly translate special characters (accented characters, superscirpts, trademark symbols). Rather than fix the code, I fixed the files by hand using a few regular expression substitutions.

4) Then I wrote a .NET application to drive the Google web services API. This was fairly straightforward, except that the Google server for registering to use the API was down for a few days. Also, when I passed null for a default parameter, the call failed without a useful explanation. I tried using empty strings instead and it works.

5) My program created a tab-delimited file (TSV) with a line for each author of a paper, which I then loaded into Excel for analysis. I used the data anlysis wizard to count and sum the number of hits for publications. But now I want to do some more sophisticated analysis.

You might say this is overkill for the purpose I had in mind (or even that it is irrelevant). But I sometimes try to automate processes like this just to find out how hard it is. This one was pretty difficult.

Batched Futures

Here is an older paper that is a real gem:

Reducing cross domain call overhead using batched futures
Phillip Bogle and Barbara Liskov
OOPSLA '94
http://portal.acm.org/citation.cfm?id=191133

Techniques that reduce the cost of latency are becoming increasingly important. This approach is quite simple, but it doesn't eliminate all the latency from a program. It can only delay sends based on the history of calls, it cannot base the call pattern on calls that have not been made yet. Some more global analysis is needed for that.