About ReferURL

ReferURL.net is a link shorting service I created. You paste in a long URL (say to an eBay auction or newpaper article) and it gives you a short URL to use (http://referurl.net/123). You also have the option of picking an alias for a referurl, something like http://referurl.net/r/xxx. Also, a common usage pattern is a bookmarklet that you drag from the page to the toolbar. Whenever you click on the bookmarklet, it runs a bit of javascript code that submits the page you are currently looking at to ReferURL.

URL shortening services are great for emailing URLs to friends. Recently they are even more important for posting URLs on twitter (with only 140 characters, every character saved counts).

A service that does similar things called TinyURL.com has been around for a long time. Personally, I do not like tinyurl.com. I think it is ugly. There is another reason I remember disliking them, but it is possible that I have two services confused, so I won’t mention it. They also didn’t offer aliases when I wrote ReferURL.

I used to use another service, but it broke repeatedly, then when it had several months of downtime I decided to write my own. That service also didn’t support aliases.

At this point when I look around the new services that are similar, I see three things that may be better than ReferURL.

  1. Some services are prettier (of course, extra graphics means slower load times).
  2. Some services put the new shorter url into your clipboard buffer so that you don’t have to copy it yourself. I would love to add this, but as far as I can tell it is implemented with Flash, which I don’t own.
  3. With twitter, every character counts. There are now some services with names much shorter than referurl.net. TinyURL.com is one character shorter. Bit.ly is six characters shorter. If any one has an good idea for a name that is shorter than referurl.net, I would love to steal it. In my own twitter usage, I haven’t had trouble with the length of ReferURL yet though.

Anyway, those are my comments on the creation of ReferURL.net. For the time being, I plan to keep looking for ways to improve it and will keep working on it.

Also, I will be releasing the code for people who want to run/write their own service in the future. I had previously released some code, but now that it is several months old, I took it down until I had time to clean the current code for re-release. If someone were to email me asking about that, it would probably get me to do it sooner.  It is a Python project build on mod_python and PostgreSQL.

SunPCI on Solaris 9

I just imported this page because I don’t want to forget the information. If you don’t know why you need to read this, then feel free to ignore it.


The SunPCI is a 400mhz AMD k62 card for running Windows in a PCI
Sun. Never versions of the card are the SunPCI-II and the SunPCI-III,
both of which use higher speed Celerons.


The original SunPCI was dropped after version 1.3 of the SunPCI
software (both 1.3 and newer versions are obtainable from Sun’s web
site, registration required). Version 1.3 of the SunPCI software isn’t
supported on Solaris’ newer than 8. Thus this page on making it work on
Solaris 9.

I doubt that it is possible to use this card with Solaris 10.

Important Requirement (that wasn’t immediately obvious to me)

One requirement that the software has is that it can only display on
the Sun X server. This means that you need to either need a framebuffer
in the same machine as the SunPCI, or you need to be remotely displaying
the software on another Solaris machine running the Sun X server.
Thankfully, framebuffers for almost every machine are rather cheap.

Presumably if you still want remote display on a different X server
(say, Xsgi, which is what I want), you could use VNC or Remote Desktop
on the Windows system. You still would need a graphical console to
run the SunPCI, but this could be a case of attaching a monitor to a
Sun in the basement to start the software, then using RDesktop from
your office to operate the Windows session.

When I started trying to set this up, I had only headless Sun machines, and I thought I could run this on one of them.  Oops.


Install the software as normal. It will fail trying to run the
postinstall script, complaining about “/etc/devlink.tab not updated
correctly”. The first thing to do is to:

  • cd /opt/SUNWspci/drivers/solaris
  • ln -s /opt/SUNWspci/drivers/solaris/sunpcidrv.280 sunpcidrv.290
  • ln -s /opt/SUNWspci/drivers/solaris/sunpcidrv.280.64 sunpcidrv.290.64

You will also need to make sure your OBP is new enough. I don’t know
what is required exactly. Perhaps 3.11. 3.9 seems to be rather common
and is too old. 3.27 seems to be the latest, and likely last version.
New versions can be downloaded from sunsolve.

Additional notes

Google Groups article with some additional notes that I didn’t require.

Also, from a german site, I got this:

d) If SunPCi still gives you trouble, edit:
and add...

I haven’t needed it either.

Poached Egg on Risotto with Spinach and Bacon

The goal was to have something more than frozen pizza, or reheated spaghetti and meatballs, using only stuff on hand.  Using up the spinache before it went bad was a nice benefit.  I bought a lot of vegatables at the beginning of the week and haven’t been using them as quickly as planned.  Now, I still need to use up the beans (uncooked, from the pack bought for the maple salmon) in the near future.

Once again, I cooked after dark.  This time it was indoors, but natural sun light would have helped the pictures I think.  I ended up not using any but one final.


  • 3/4 cups chicken broth or stock
  • 1/4 cup dry white wine
  • 1 cup parmesan broth
  • 1 tablespoons butter
  • 1/2 cups Arborio Rice
  • wilted spinach
  • crumbled bacon
  • 4 eggs
  • water
  • vinegar
  • 2 tablespoons grated parmesan

Note on order:

Both poached eggs and risotto are best served immediately.  I feel
that is slightly more important for the eggs, so I start the risotto
first, then do the eggs about 10 minutes into the stirring in the
liquid stage of the risotto.  Finished eggs are store in a covered
bowl in the microwave to preserve their warth.  Since the risotto
should finish first, I leave it covered off the burner to keep it warn.

The parmesan broth:

Boil 1 cup water.  Add parmesan rind and a few pepper corns, simmer
for a few minutes.  Strain.

To wilt the spinach, I use a minimal amount of olive oil in a pan,
then add the spinach and toss some salt and pepper on top.


Contrary to popular reports, you don’t have to stir constantly.  You
do need to stir alot though, and you also need to watch constantly.

Mix liquids together and warm them.

In a heavy sauce pan, melt butter.  Add the rice, add stir with spoon
until grains are coated.  At this point you will start adding liquid
to the rice a few tablespoons at a time.  After each addition, keep
stirring the rice until the liquid is completely absorbed.  Expect
this process to take about 18 minutes.  Stop when rice is al-dente.  I
like the risotto to be soft enough that they don’t resist biting, but
not so soft that you can’t feel the grains in your mouth.

Salt and pepper to taste.

When the risotto is complete, stir in the spinach and bacon.

Poached Egg (If you know how, skip this):

First, you need a pan that will allow you to have 5 inches of water
while staying at least 1.5 inches from the top of the pan.  Fill the
pan so that you have 5 inches of water.  Add a tablespoon of white
vinegar.  Bring the water to a simmer (200 degrees).

Spin the water with a ladle handle.  Drop an egg in the center.  Leave
it for 3-4 minutes.  It will look messy until you remove the egg.  You
might consider watching a few tutorial videos on youtube.  That’s what
I had to do.  No amount of reading explanations made me realize that I
just needed to wait long enough before removing the egg, then trust
that it would look OK when served.

Also, be prepared to waste a few eggs practicing.  They aren’t that


Put risotto in individual bowls, then place eggs on top and sprinkle
with a dash of salt, parmesan, and ground pepper.

Must have Emacs Mode

If you ever edit javascript code, the only emacs mode to consider is Steve Yegge’s JS2 mode.  The official page for it is here.  The annoucement page is here.  This javascript mode is an example of what more modes should aspire to.  It parses your buffer into a javascript AST and uses that for syntax highlighting, and also to check for syntactic correctness, helping to prevent you from having bugs caused by typos.  This is a lot faster than having to load the code into a web browser to find out that you missed a ‘;’.

It also provides Javascript code navigation.  Some other modes have this, like python mode (but not C-mode, at least not by default), but I wish all modes had it.

I wish someone would copy this strategy for a new C mode or Python mode.

Making Soy Maple Salmon with Sauted Green Beans

I had planned to make teriyaki shark tonight because shark was advertised on sale.  I bought the beans yesterday.  When I tried to buy the shark today, I found that they were sold out for the day (but might have more tomorrow, even though technically this was yesterday based on what the clock reads), so I bought Salmon instead since I didn’t want to give up plans of having fish.

I then proceeded to cook and attempt to take pictures after dark.  And this was actually a somewhat early time.  I had to pick my car up from the shop, so I used that as an excuse to leave work early.

For the recipe, look here.

Final dish, plated on our picnic table.

Green beans, blanched and coated in oil and soy sauce.

Salmon, salted and peppered.

Green beans on the side burner of my grill.  Deb was trying to capture dramatic flames from the oil spritzing over the side as I shook the pan.

Salmon on the upper rack of the grill.

Soy-maple Glazed Salmon, with Sauted Green Beans, Recipe

Soy-maple Glazed Salmon, with Sauted Green Beans. Including photos.


  • 2 boneless salmon fillet, serving size (could be a good bit more)
  • Salt + pepper


  • 2 tablespoons maple syrup
  • 1 tablespoons soy sauce + extra for beans
  • 1 tablespoons melted butter
  • 1 tablespoons fresh lime juice
  • 1/2 teaspoon lime zest
  • chopped fresh chives
  • lemon wedges


  • Green beans, enough to serve the number of people eating.
  • 1 tablespoon sesame oil
  • 1 tablespoon vegetable oil
  • 1 tablespoon soy sauce


Remove the tips and stems.  Cut into 3 in. sections.  Blanch them (1 minute or less in boiling water).  This probably takes long enough that you might as well do it before preheating anything.

Preheat the grill for medium-high heat and lightly oil grate (I used the upper rack, but if you don’t have an upper rack, then lower the temperature).  Also preheat your bean pan (cast iron is great, heavy stainless steal is also good, a non-stick pan is bad because they break down at high heat) on high.  This works nicely if you have a cook side burner next to your grill.

Whisk together the maple syrup, soy sauce, butter, lime juice, and lime zest.

Season the salmon fillet with salt and pepper, and put a spoon full of sauce over it to marinate for a few minutes.

Dry beans, then oil lightly with equal parts sesame oil and vegetable oil.  Drizzle with soy sauce.

Place skin-side down on either the upper shelf, or reduce the grill temperature.  Close the lid on the grill for 5 minutes.  Baste the salmon and close again.  While waiting on the salmon, reduce the glaze lightly, until it coats the back of a spoon.  Continue cooking until the salmon flakes easily with a fork and is 140 deg.   Just before removing, add a bit more glaze.

In the very hot preheated pan , toss the beans in, and shake frequently to prevent sticking.  Beans will cook very quickly.  However, they can be warmed if you want to complete them before the salmon is completed.
Serve  the salmon, lightly drizzled with thickened glaze. Place beans next to salmon.  Garnish with chopped fresh chives and lemon wedges.

If you are wondering about the non-stick pans, DuPont (according to Google) says their maximum recommended use is only about 500 degrees Fahrenheit.  They also say they will suffer significant decomposition above 660.  Cooks Illustrated (sometime in 2005, but I didn’t dig up the issue to quote), the Environmental Working Group, and I believe Alton Brown, independently say that a pan can overheat (700 deg according to the EWG) in as little as 5 minutes when used on high heat, and that toxic and carcinogenic gasses can be detected at those temperatures.

Mail Configuration with Postfix and Dovecot

(NOTE in 2011: This one post attracts enormous amounts of spam comments, so I’m closing comments on it, while still leaving comments on elsewhere.)

Notes on configuring a SMTP/IMAP server with TLS, SSL, and SMTP AUTH, the least pain possible.

The platform used was Solaris 10 with SunStudio 11. The notes should apply to any reasonably recent unix-like operating system, although Linux users in particular may find it easier to just install the setup from their prefered package management system. I will note any place that is likely to contain Solaris specific stuff.

The main pieces used are Postfix and Dovecot.

A quick note: TLS is basically SSL

About SASL

Postfix requires an external SASL library to use for SMTP AUTH. The normal choice is Cyrus SASL, which has been around for some time. Cyrus SASL is difficult to build on Solaris with SunStudio, and is generally a much hated library.

Starting with Dovecot 1.0, Dovecot now has it’s own SASL library. This is much easier to use. The only downside is that when doing Postfix to Postfix SMTP AUTH connections, the client copy of Postfix can’t use Dovecot SASL. If your installation of Postfix is always going to be a SMTP AUTH server and never a client, then please use Dovecot SASL.


Compile with:

./configure --prefix=/opt/dovecot --with-pgsql --with-gssapi \
          --with-ssl=openssl --with-gc

gssapi still doesn’t seem to work for me, and I’m not actually using pgsql, so I could have left it off as well.


At this point, all you have to do is edit the dovecot.conf file. I don’t have anything but plain authentication working correctly. I can get CRAM-MD5 working, but then plain won’t work, at least with mutt. I make up for this by requiring the non-localhost imap connections use SSL, and by later setting postfix to only allow SMTP AUTH over TLS. I accomplish the imap/SSL requirement with a firewall rule.

Find the commented protocols line and uncomment, set to “protocols = imap imaps”. This disables POP usage. Add pop and pops if you wish.

Set the ssl_cert_file and ssl_key_file lines in your dovecot.conf file. Search elsewhere for a guide on creating the key. I reused the same key that I created for apache/ssl usage.

Set the mail_location line to “mail_location = maildir:~/Maildir”.

Adjust the first_valid_uid line, if needed. I set mine to: “first_valid_uid = 100”.

Find the “auth default” section. Change the mechanisms line to: “mechanisms = plain login”. In the passwd pam { second, find the commented out args line, and change it to “args = /etc/pam.conf”.

Still in the auth default section, find the commented out “socket listen” section. Uncomment the first line to: “socket listen {“. Then scroll down to the client section, and uncomment the non-descriptive lines and change to:

    client {
      # The client socket is generally safe to export to everyone. Typical use
      # is to export it to your SMTP server so it can do SMTP AUTH lookups     
      # using it.                                                              
      path = /var/spool/postfix/private/auth
      user = postfix
      group = postfix
      mode = 0660


Start up dovecot. Under Solaris 9 or linux, I added it to the rc.local file (on some systems I had to create a rc.local system to do so). On Solaris 10, find a manifest and method here and here.. To install these files, copy the manifest to /var/svc/manifest/site and the method to /lib/svc/method and install them into SMF with the command:

svccfg import /var/svc/manifest/site/imap-dovecot.xml



Very simple. In the expanded source directory, “./configure && make && sudo make install”.


To build:

   -I/usr/local/ssl/include' \
   AUXLIBS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib -lssl -lcrypto" \

Non-solaris users can omit the -R option, and the CC option.


The primary options that need set are to append to the end:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/your.crt
smtpd_tls_key_file = /etc/ssl/your.key
smtpd_tls_loglevel  = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may


Additionally, find the mailbox_command section and set:

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/ssl/your.crt
smtpd_tls_key_file = /etc/ssl/your.key
smtpd_tls_loglevel  = 1
smtpd_tls_received_header = yes
smtpd_tls_security_level = may

smtpd_recipient_restrictions =


Additionally, find the mailbox_command section, and set:

mailbox_command = /usr/bin/procmail -a "$EXTENSION" DEFAULT=$HOME/Maildir/ MAILDIR=$HOME/Maildir


Also set: myhostname, mydomain, mydestination.

Follow other guides for setting up things like spam checking, or mailman.

PostgreSQL Notes

I don’t use Postgres quite heavily enough to remeber how to do certain administrative tasks. Having gotten sick of flipping back and forth between various sections in the manual, I’m making a page of notes here.

Anything here is probably permenantly burned in the brains of heavier users, but perhaps this will be useful to other light users.


Postgres generally runs as a dedicated user, and that dedicated user probably has complete control over adding roles and dbs.

To use postgres as a specific user, “psql -U username” is easier than su’ing to that user (and the postgres user you want may not be a system user anyway.

Creating a DB

createdb -U postgresuser newdbname

Adding a User

Users are just roles that can login.

createuser -P newusername

The -P flag is to tell it to set a password. It is possible to have accounts without passwords.

To see the users, from inside psql, do \du.

Assigning the DB to a user

This is night the same as granting rights to users (see the GRANT command), although the DB owner does have full rights in the DB.

alter database dbname owner to username;


I often want to calculate something quickly then stick it into the buffer I am currently editing. Previously, I would do something like type (+ 3 5) into the buffer, Type C-x C-e, see the result in the minibuffer at the bottom of the screen (are re-evaluate repeatedly if I didn’t quite catch it, say for a long result), type the result into the buffer, then delete the expression (although sometimes in C code, I might leave the expression in a comment).

Eventually, I realized that Esc-: brought up an eval prompt in the minibuffer and that I could use it instead of the above. But I still had to be fast at reading the result before it was taken of the screen, and now I had to retype the expression to re-evaluate it. Sometimes this was an improvement, but not always.

Alternatively, sometimes I would type (insert (format “%s” (+ 3 5))), and evaluate it, but that was quite a lot of typing, and so I’d only use that when I wanted a long result to be pasted into my buffer. And then I still had to delete that long expression.

That led me to do the following in my .emacs files:

(defun eval-exp-insert (EVAL-EXPRESSION-ARG)
  "Evaluate EVAL-EXPRESSION-ARG and insert the result into the current buffer."
  (interactive "xEval: \n")
  (insert (format "%s" (eval EVAL-EXPRESSION-ARG))))

(global-set-key "\M-:" 'eval-exp-insert)

With that, when I type Esc-:, and then enter (+ 3 5), 8 is inserted into the buffer at the current cursor position.