Friday, April 21, 2006

A USNA Companymate killed himself

I got some bad news this morning. One of my companymates and a member of my class at the Naval Academy killed himself.

We lived a couple of doors apart-- never really got along too well. He always seemed angry at me when I was around. At 18 I didn't understand that maybe that was more a sign of a deeper suffering.

I talked with one of my roommates from the Academy this morning for the first time since graduation (20 years ago in May!). It was good to hear from him, and get emails back and forth to another classmate.

It really made me think about those four years at Annapolis. There were some amazing people there. I always felt a little inadequate in comparison. I talked with a friend of mine this morning who pointed out the insanity of this. It's important to appreciate the gifts we are given.

No one understands what our classmate did. I hope his family is... I can't imagine that his family is okay.

Thursday, April 20, 2006

SQL Server: Error 9002, Log file is full

I got this error when I had backed up a database but neglected to truncate its log file and shrink the database. Normally you don't notice this because the default in SQL Server is to allow unlimited growth of data files. Here's the error message:




Name: Database log file is full. Back up the transaction log for the database to free up some log space.
Description: Error: 9002, Severity: 17, State: 6
The log file for database 'FOO' is full. Back up the transaction log for the database to free up some log space.


Here's the code to fix it:




use master

BACKUP LOG foo
with truncate_only

/*
* The second parameter is the percentage
* of free space you want to leave for
* further growth.
*/
DBCC SHRINKDATABASE (foo, 10)

Monday, April 17, 2006

Bikram Yoga: You better breathe!

This is my third week doing Bikram Yoga at Bikram's Yoga College of India in Philadelphia (http://www.bikramphiladelphia.com/). I'm going three times a week now.

On Friday I went with Sonia for our weekly yoga date. For some reason I lost control of my breathing about a quarter of the way through class. I just started panting. Considering that this is a 90 minute class, that's pretty serious. I had a solid core of pain right in the center of my body for the last hour of class. I didn't really catch my breath until about an hour after class. It wasn't pretty.

When I went into class this morning I promised myself to concentrate on my breathing, even if it meant I'd do less on the poses. I really watched it, controlled it, modified the pose if necessary to be able to control my breathing. When I finished class, I felt great. Oddly enough, I got even deeper into the poses than last time. I guess it *is* all about breathing.

Wednesday, April 12, 2006

Becoming accustomed to the presence of peace

On Monday I was having a tough day. I couldn't put my finger on what the trouble was. I was talking with a friend when we hit on the fact that I had not prayed or meditated in three days.

It's always bugged me when I've heard people say that they skipped a day's prayer or meditation and had a bad day. It smacks of magic to me: that a prayer to the "cosmic concierge" affords me a good day, and if I don't pray, I am punished with a bad day.

But I think I'm beginning to understand it: when I pray and meditate on a regular basis, I accustom myself to the presence of peace.

This is important: people are not always right or easy to deal with. Sometimes people will come with aggression where none is necessary. Sometimes they will act out of despair. If I am not accustomed to the presence of peace, I have nowhere to go in that situation but towards more aggression. But if I let myself experience peace on a regular basis, I can meet aggression with peace. Aggression plus aggression escalates. Aggression met with peace: that's something we can work with.

One of my set prayers is the Prayer of St. Francis. It gives a formula for what is basically unfamiliar to me by nature: peace in my daily relations. The prayer asks that when there is hatred I may bring love, that where there is wrong I may bring the spirit of forgiveness. As a male, I have been taught that my basic tools in most cases are aggression and comic deflection. Learning something new here for me is essential. If someone near me makes an obvious error, becoming aggressive to that person hurts everyone. Forgiveness of an error is a path towards peace.

It seems easier to think about this in terms of people I already love: my wife, my coworkers. But it gets tougher with people I have not learned to love yet-- for example, when President Bush makes what I believe to be an error, if I aggressively condemn him, I actually cause less peace in the world. If I can somehow find the spirit of forgiveness for one of his errors, I channel more peace.

This is a difficult concept for me. Neither do I think I am supposed to blindly follow my president down a hate-based path of aggression towards all. I think I'll have to think about this aspect of my spirituality some more.

Friday, April 7, 2006

Bikram Yoga: Week one

As I mentioned last week, I found a couple of Yoga places here in Center City, Philadelphia (Yoga Classes in Philadelphia). I had done one Bikram Yoga class in New Orleans before we evacuated, and I had been happy with it. The schedule was right. And I'm a little bit of a masochist (really-- I have the T-shirt and everything.)

So I signed up for Bikram Yoga at Bikram Yoga of Philadelphia. I've done four classes in the last week, including a date with Sònia last Friday. She's gotten into it too.

Bikram is hard. I've decided that Bikram is the fisting of Yoga. On Wednesday I did a class after getting only four hours of sleep. My balance was all messed up. I was trying to do this head to knee pose where the goal is to touch your forehead to your toes-- I thought, yeah, right. But I really pushed it, and I actually felt my hair touch my toes! Right then, it was like someone turned on a big switch-- for a moment, I was completely awake. I had complete consciousness. I heard the theme music to "Bonanza". It was cool.

Then I went out of the pose and it was gone. Guess I'll have to go back next week.

Tuesday, March 28, 2006

SQL: Calculating the geometric mean (GEOMEAN)

I had a user at the last place I worked who needed to calculate the geometric mean of a column in a table. The geometric mean is like a regular mean, but has the practical effect of throwing out outliers (unusual spikes in the data). This is a standard function in Excel, but not in most databases.

The standard method of calculating the geometric mean is by multiplying all of the terms together, then taking the n-th root of the product, where n is the number of terms. So if you had 5, 7, 55, 6, and 3 as terms, you would take the fifth root of 34,650, giving you 8.0899. Notice how the final result is not very much affected by the outlier (55).

This technique won't work in most databases for non-trivial datasets. Why? Because if you take 100 terms and multiply them, it will likely overflow even the largest column type. In fact, calculating the geometric mean this way with a calculator can quickly become impossible for large data sets.

There is a solution. If you take advantage of the magic of logarithms, you can calculate the geometric mean for very large data sets without overloading a standard relational database data type.

For a given set of terms, sum the log (I will use the natural log) of all terms. Then divide this sum by the number of terms. Finally, take the anti-log of the result (since I use a natural log, this means raising e to the result). Using our example:

ln( 5) =  1.6094
ln( 7) =  1.9459
ln(55) =  4.0073
ln( 6) =  1.7918
ln( 3) =  1.0986
         -------
         10.4531

10.4531/5 = 2.0906

e^2.0906 = 8.0899

which is what we got using the standard technique. This can be translated into SQL this way:

select exp(sum(log(sample)) / count(*))
  from sample_table

-- or, depending on your flavor of SQL...
select exp(sum(ln(sample)) / count(*))
  from sample_table
UPDATE: Isabelle pointed out that there is a neater way to do this. Since the sum(FOO)/count(*) is an average, the expression can be simplified to this:

SQL Server

select exp(avg(log(sample)))
  from sample_table

Oracle, PostGreSQL, MySQL

select exp(avg(ln(sample)))
  from sample_table

Nicely figured out, Isabelle.

As far as I can tell, this will work in Oracle, SQL Server, and Access, and I can't think of why it would not work in MySQL or PosgreSQL.

MS Access: FIX: Left function doesn't work

I have an old Access database. I found that a lot of scalar functions didn't work in it. I tried something simple like this:




select left(l_name, 15)
from test_table


and got this error:




Undefined function 'left' in expression.


I hit alt-F11 to bring up the Visual Basic for Applications (VBA) IDE, and immediately got this error message:




Your Microsoft Office Access dataabse or project contains a missing or broken reference to the file 'MSOWC.DLL' version 1.0


I check my references (tools->references) and saw an entry: "MISSING: Microsoft Office Web Components" which referenced the file "C:/Program Files/Microsoft Office/OFFICE10/MSOWC.DLL"



I went looking for the file-- the first thing I found out was that, althought I have an OFFICE10 directory, I'm running Office 2003 out of OFFICE11. There was no corresponding DLL in the OFFICE11 directory.



I simply unclicked the MISSING reference, saved the file, and it all works fine now. I suspect that the missing file is unneeded in 2003.

Yoga classes in Philadelphia

Since the search for lunchtime kung fu/tai chi classes didn't work out (see No Lunchtime Kung Fu in Center City), I'm looking for yoga classes now. You say flaky, I say eclectic. Anyway, I've turned up two likely studios.

The first one is Bikram-- I went to one Bikram class in New Orleans before we evacuated, and it was cool. Or rather, not, it was done in a 100 degree room. It truly kicked my ass, but in a way that I liked.

Bikram Yoga of Philadelphia
http://www.bikramphiladelphia.com/schedule.shtml
M-F - 06:15 - 7:45, 12:00 - 13:30, 19:30 - 21:00
$20 first week,
10 classes - $120, month unlimited $150

The second one does Ashtanga yoga, which I don't know anything about. However, I like that they do a 12:00 - 12:45 class. That's realistic. One thing I picked up in my Kung Fu search was that studios sometimes take the attitude that if you can't bend your life around the class, you aren't dedicated enough. I guess I'm not very dedicated, but I *would* like to get in some form of exercise.

The Yoga Loft
http://www.theyogaloftphilly.com/schedule.html
M-F 07:00-08:00
M,W,F 12-12:45

By the way, the info I have here is only for classes that worked for my schedule. Go to the websites listed to see the entire schedule.

Thursday, March 23, 2006

39:45 South Philadelphia Loop - Chelsea Williams

It's been a while since my last run, and o lord could I feel it. I was about to go microwave some couscous when a tiny voice in my mind reminded me that I am 41 and will quickly become a tremendous lard-ass if I just eat and never exercise.



I found Chelsea Williams through a friend of a friend. She's a busker in Los Angeles. Man, busking must be tough in Los Angeles if this is the level of quality. I busked quite a lot in Barcelona, and I always thought I was pretty good, but I suck by comparison.



Unfortunately, I wasn't able to download more than two of Chelsea Williams's songs, so I filled out the rest with standbys. Here was my playlist:




  1. Undecided - Chelsea Williams

  2. This Will Be - Chelsea Williams

  3. Te Recuerdo Amanda (I remember you Amanda) - Jose Mercé

  4. La autoradio canta (The car radio sings) - Miguel Bosé

  5. Dime quién soy yo (Tell me who I am) - Niña Pastori

  6. I'm Digging Your Scene - Dr. Robert

  7. Springtime for the World - Dr. Robert

  8. Telephone - Zap Mama



I got into some flamenco today (Jose Mercé & Niña Pastori). And the Miguel Bosé song was a favorite from 1996.



The Dr. Robert songs are from a new acoustic album coming out from the former singer of "The Blow Monkeys".



The run itself was very hard-- I got really tired about halfway through. Not out of breath, oddly enough, just generally worn out. My god I'm an old fart.

Tuesday, March 21, 2006

Microsoft Paint (PBRUSH) Text Toolbar Disappears

I use Microsoft Paint (pbrush) a lot. I recently had the problem that my Text Toolbar just disappeared. I tried selecting and unselecting "Text Toolbar" from the view menu, but nothing worked.



You can fix this from Regedit. The keys are:




My Computer/HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Applets/Paint/Text/PositionX

and PositionY


From Regedit you can set both of these to 0 and the text toolbar will show up on screen again.