Monday, June 28, 2004

Here's a non-technical post.

This weekend, I drove a van to Dallas for the Youth Evangelism Conference.  It was really fun.  I hadn't planned on going, but so many kids signed up that they needed some extra drivers.  In short, it was a blast.

Among the highlights were:

  • Audio Adrenaline - The last time I saw Audio A in concert, I had much more appropriate, shoulder-length hair to rock with.  It was a fantastic show.
  • Kirk Cameron (link to a pretty impressive flash site that I just stumbled across) - He had an incredible amount of insight.  Much more than I expected.  He ended up being a very impressive speaker.
  • Red Cloud (link to the only google hit with pictures) - He and his skinny white assistant (who looked an awful lot like Screech from “Saved by the Bell“) did some “freestyle“ rap which was pretty entertaining.  After a few songs, he had the crowd approach the stage and pull things out of their pockets.  He then made up a rap about all the things.  It would have been more impressive if it wasn't so easy to anticipate what was in people's pockets.  He became a favorite of mine just because it was fun to imitate him.
  • Grits - I had only heard of them because of a cameo on the first Out Of Eden album I got at the above mentioned previously attended AudioA concert.  It was a fun concert, but that's not really the style of music I'm into much anymore.
  • The van ride to and from - We had an absolute blast on the way and back. Lots of Homestar Runner references and impersonations and walkie-talkie fun.  It really took me back.  My parents got on one of the overpasses in Belton and waved as we drove past.  They are crazy.
  • Stephen Baldwin (link to a related article) - He was a very sincere goofball.  He definitely has a heart for youth.

There's so much more to write about this, but if I don't stop, I'll never finish this entry. Again, it was fun.

posted on Monday, June 28, 2004 5:41:19 PM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Thursday, June 24, 2004

A few months ago, a co-worker and I recieved an email from an overseas counterpart in another language.  We used Babelfish to translate it and also to translate our response.  This was an extremely handy tool.  While exploring it in more detail we found that some translations, especially to and from oriental languages whose sentence constructs are drastically different from English, can produce hilarious results when the results are “round-tripped” from English and then back again several times. For instance, the two round trip translation of this paragraph is:

In regard to the overseas equality of the E-mail of the sky of cooperator several months ago, recieved of another language. That translated that Babelfish is used in addition to the translation of our responses in regard to us. This was the device of convenience very. From the place where you understand the fact that decodement we insert the oriental language to in regard, go away in detail, having gotten together having explored while, the especially result and with this two time English " Empty the next; " of circle; You stumble or, either one; The fact that it differs from time English completely is in order to withstand the possible cheerful result. For example, as for translation of this paragraph as follows there is a thing:

Along those same lines, another co-worker ran across this little beauty today.  The results of a hotel's internet setup instructions English translation gone horribly wrong.

posted on Thursday, June 24, 2004 10:22:26 AM (Pacific Standard Time, UTC-08:00)  #    Comments [1]
 Wednesday, June 23, 2004

I had a request from Scott Hanselman (who has been vocal on the subject of ViewState on many occasions) to share my approach to file-based ViewState persistence that I mentioned in my previous post.  Feel free to comment on my approach.  I need to get code formatting set up.  Pasting from Visual Studio is a pain.

Here's my overrides of my base class page's LoadPageStateFromPersistenceMedium and SavePageStateToPersistenceMedium:


protected override object LoadPageStateFromPersistenceMedium() {
     return _viewStatePersister.LoadViewState();
}

protected override void SavePageStateToPersistenceMedium(object viewState) {
     _viewStatePersister.SaveViewState(viewState);
}


Doesn't tell you much, except I'm delegating persistence to a ViewStatePersister, which looks like (with some things renamed to protect the innocent):


public abstract class ViewStatePersister {
     public ViewStatePersister(BasePage page) {
          _page = page;
     }
     protected BasePage Page {
          get {return _page;}
     }
     BasePage _page;
     public abstract object LoadViewState();
     public abstract void SaveViewState(object viewState);
}


Delegating this responsibility to a separate class gives me finer control over how the persistence happens, as well as modularizing that functionality.  Naturally, I have a class that wraps the default ViewState persistence functionality (which is fairly uninteresting), as well as a FileBasedViewStatePersister.  It extends the DefaultViewStatePersister and harnesses that existing behavior to store a single Guid in the __VIEWSTATE field used to uniquely identify the request.  It's methods of interest look like: (You might look at SaveViewState first so Load makes more sense.  I'm not about to screw with the formatting again to re-order them.)


public override object LoadViewState() {
     object viewState = base.LoadViewState();
     if (viewState != null) {
          Guid guid = (Guid)viewState;
          LosFormatter formatter =
new LosFormatter();
          using (FileStream fileStream = new FileStream(CreateOfflineViewStateFilePath(guid), FileMode.Open, FileAccess.Read, FileShare.None)) {
               viewState = formatter.Deserialize(fileStream);
          }
     }
     return viewState;
}
public override void SaveViewState(object viewState) {
     //create a guid for this viewstate
     Guid guid = Guid.NewGuid();
     LosFormatter formatter =
new LosFormatter();
     using (FileStream fileStream = new FileStream(CreateOfflineViewStateFilePath(guid), FileMode.CreateNew, FileAccess.Write, FileShare.None)) {
          formatter.Serialize(fileStream, viewState);
     }
     //trick the regular system into thinking all it needs to save is the guid
     base.SaveViewState(guid);
}


The appropriate persister is created with a call to a virtual CreateViewStatePersister() method, which a page can use to create the persister of its choice.  As I said in my previous post, I was dissapointed that I had to use the LosFormatter rather than the BinaryFormatter.  The downside of this approach is the possibility for creating LOTS of files, as opposed to creating a single file per session.  But I already have a file cleaning mechanism in place that cleans up files created by my graphing library, which creates more files.

posted on Wednesday, June 23, 2004 10:02:08 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]

On a recent iteration of a project at work, we were analyzing our cache usage for several data analysis pages we have using ASP.net.  The usage of these pages evolved as we updated them with features, and in a pinch we were forced to turn off caching because of the hit to memory we were taking.  As we loaded more and more data into our database, and we had more and more users, more stuff was being cached, but we were not seeing benefits from the caching across users because each user was looking at different data.  Turning off the cache caused individual users to take a big performance hit when reloading the same report twice or making minor adjustments to the options, but we just couldn't justify the memory usage for that small percentage.

I decided the solution was a multi-level cache, where objects expired to lower levels, like from memory to high-speed disk, to slower disk, to db (really, I only want the memory and disk levels, but there's no need to limit it to that).  Unfortunately, there is no mechanism for injecting new behavior into the System.Web.Caching classes to accomplish that, which is a shame because they have already implemented the expiration and dependency code that would be the most complex part.

So, I'm faced with the possibility of creating my own caching framework, or tricking the System.Web.Caching classes to do my bidding using the existing mechanisms like dependencies (which is a possibility).

On another note, I implemented file-based ViewState quite successfully.  It was much more simple and straightforward to address issues like a user with multiple windows than any article led me to believe.  In doing so, I noticed some VERY annoying things about that ViewState persistence mechanism.  The normal behavior uses the LosFormatter to serialize the ViewState to base64 to be put inline with the html.  This is fine for storing ViewState inline, but if I'm serializing to files, I'd rather have the speed and efficiency of the BinaryFormatter.  The problem is that LosFormatter is special and doesn't play by the same rules as the other formatters in the framework (BinaryFormatter, etc).  Most of the built-in controls use Pair and Triplet to store their data in ViewState, but they aren't marked with SerializableAttribute which means that BinaryFormatter can't serialize them!  So I had to continue to use the LosFormatter, which bloats data horrendously.  I hope some of this is cleaned up for ASP.net 2.0.

posted on Wednesday, June 23, 2004 9:02:47 AM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Monday, June 21, 2004

OK, I suppose it's time to jump on the bandwagon. I've avoided publicly giving out Gmail invitations for a while, but I've given out about 10 of them and they keep giving me more.  I've run out of people I think would be interested in them.  If you would like one, leave a comment with your email address and I'll see about getting you one.  If you're using Hotmail or Yahoo, I'd highly recommend it as a much better alternative (having used them both at one time or another).  I'd also recommend it if you use multiple computers and don't have a way to keep your email synced up.

If you're gonna leave your email in a comment, you probably ought to obfuscate your email address to avoid spam.  I suggest doing things like spelling it out (bob at bob dot com) or something that requires a bit of human intervention to figure it out.  I do get alot of crawler traffic.

posted on Monday, June 21, 2004 8:53:18 AM (Pacific Standard Time, UTC-08:00)  #    Comments [4]
 Friday, June 18, 2004

I mentioned rafting in my last post. After calling to confirm my reservations, I was informed the Guadalupe river was running at 5000 cfs (cubic feet per second) with all the rain we've had and no one is renting out rafts.  I've been on the river at about 2000, which was pretty insane.  I've been on it as low as ~200, which was ridiculously slow.  In my opinion, optimum conditions for rafting are around 800-1200.

So, no rafting, and it looks like I won't be in such a hurry to get my hair cut.  Hopefully, the levels are a sign of plenty of water, so we'll be able to go later in the summer without it being too low.

posted on Friday, June 18, 2004 9:39:22 AM (Pacific Standard Time, UTC-08:00)  #    Comments [2]

Been too long.  I apologize.

I've needed a haircut for weeks now. Ever since college I've cut my own hair. I also used to cut Peter's hair (even when it was green) until he decided to grow dreadlocks. Anyway, since I cut my own, I really have to be in the right mood to cut it. I don't have the motivation of an impending appointment to push me. We're rafting down the Guadalupe river this weekend (wow, that's tomorrow), so I need it done by then. I'm also going to Dave's tonight to play James Bond on his GameCube, so I have to do it right after work.

I asked Becky to help me make sure to remember to do it right when I get home.  Ever since then, I've started seeing reminders everywhere.  She has one taped to the wall in the bathroom (which is usually the first place I go after sitting in rush hour traffic), and I just opened up my lunch to find a reminder in with my lunch.  It's pretty hilarious, it's written on some stationary with a big fat cat, and she drew it in a cartoon voice bubble so it looks like the cat is saying it.  Hey, I've got a camera phone.  I'll just put it up here!

Here you go, enjoy.

[Updated (6/24/2004): links changed from RSS to blog main pages, sorry]

posted on Friday, June 18, 2004 9:08:33 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Monday, June 07, 2004

I was adding some complex usage logging in a data abstraction layer today, and I wanted to minimize its impact on performance.  I was dreading having to manage worker threads, then I remembered the ThreadPool. It was so easy to shuffle off my logging to a managed worker thread.  That saved me alot of trouble.  One of those “pit of success” moments for sure.

(I would have rather linked directly to Rico's site, but Brad had a higher google rank.

posted on Monday, June 07, 2004 1:55:25 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]

Peter's been keeping us up to date on California diesel prices (supposedly), and they're high.  I've found a solution for his Jetta.  It's a conversion kit for a diesel-powered car that allows it to run on vegetable oil.  I had seen this concept before, but it was experimental.  These folks sell the conversion kit.

Oddly enough, vegetable oil prices are much lower than diesel prices, especially if you parter with a local fast-food restaurant that would have to pay to get rid of it anyway.

Looks like GreaseCar.com sells the kits for around $800, which would more than pay for itself in a short period, especially if you're getting the oil for free.  Evidently it burns more cleanly as well, a boon for any environmentalists out there.

I may have to find me an old diesel-powered car and do this as a project!

posted on Monday, June 07, 2004 12:38:18 PM (Pacific Standard Time, UTC-08:00)  #    Comments [2]
 Sunday, June 06, 2004

I played my first soccer game in over a year yesterday and I am incredibly sore.  For those unaware, I developed pretty horrible shin splints about two years ago when I got back into soccer, and was forced to again retire.  I lost about 45 pounds, then slowly got back into running.  Then, last week someone from my old team sent me an email asking if I could sub, so I thought I'd give it a try.

We played at Zilker park from 10-12.  It was hot.  I did pretty well.  I played sweeper or stopper, occasionaly making a foray into the offensive side of the field.  By the end of the game, I was having trouble lifting my legs, and today it is quite painful to do so.  You use so many more different muscles playing soccer than you do doing anything else I've ever done.  I remarked to Becky on the way home from church that the muscles that move my eyebrows were the only ones that weren't sore, so I was doing alot of eyebrow raising.

I'll probably continue to sub this summer, and start playing full time in the fall.  I'm pretty excited to have played a game and not have my shin bones be killing me too much to walk.

posted on Sunday, June 06, 2004 2:25:19 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]
 Tuesday, June 01, 2004

I'm experimenting with a project which will need some complicated file parsing abilities and I don't want to go the XML route for various reasons.  Therefore, I am looking for a parsing framework built to take advantage of the CLR.  Everything seems to be a port of some archaic C library, or some Java framework that's been modified to produce C# code.  I'm used to being able to do a simple Google search to find the kinds of libraries I need, but I'm getting very few good hits for this.  I've only built a few pieces of code that really qualify as parsers over the years, so maybe its my inexperience that's my problem, but it just seems like it ought to be easier to find a good tool.

We've had enough time for the CLR tools to take on their own identity and take advantage of the CLR rather than remain lagging clones of their Java or C++ counterparts.  I see this in almost every space.  There just seems to be a huge hole for file parsing.  Maybe most CLR developers have embraced XML as the one and only file format.  But, when it comes to human-edited files or content, XML is pretty cumbersome and bloated.

For now, I've settled on Grammatica, which is the most straightforward (and working) parser generator thus far.  It's written in Java, but that's not a big deal.  The problem is that its output is Java-centric, and only modified slightly to be C# code.  It's got callbacks instead of events to handle tokens or products.  I found myself modifying the output (a no-no in code generation) to make it simpler before I realized I'd just be doing it again if I changed my grammar.  So, I'm really frustrated and just ranting, but I should be able to mold it to my purposes.

posted on Tuesday, June 01, 2004 4:50:40 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0]