blog.vorpal.cc

Hi! My name is David Hogue. I write code in Bend, Oregon.

January 2, 2008

Workaround for weird Firefox bug where the textarea cursor will dissappear

Filed under: — David @ 11:12 pm

Every once in a while I run across a bug in Firefox that basically hides the blinking cursor that is supposed to be in a textbox. It’s still there and I can still type, but I just can’t tell where the next character will appear. Every time this happens, I have to Google around a bit and find the Bugzilla bug describing it.

For my own reference: here is the bug report. It will be fixed in Firefox 3.0, the workaround is to add a style="overflow: auto" to a parent element of the textbox. Apparently it is caused by placing a textbox in a position: fixed element with a height.

I also found a fix over on Bram.us that is a bit of css that should fix every input and textarea on a page.

January 1, 2008

So 2008 is here…

Filed under: — David @ 10:33 pm

Another year came and went already. I had a lot of fun in 2007 and I’m excited about the next year.

There’s a lot of interesting things coming up in the .net world: .net 3.5 and Visual Studio 2008 are finally out, the ASP.NET MVC framework is looking good, the ALT.NET stuff is giving some attention to non-Microsoft tools. I’ve been working on some interesting stuff for a while now that should get some use soon.

I’m not really much for the resolutions and stuff. I will try to get more content up here this year. So far I’ve kept this blog running. I haven’t abandoned it yet. I have a ton more ideas that I just haven’t written down yet.

December 13, 2007

Quick Tip: Fullscreen Window in WPF

Filed under: — David @ 11:31 am

(aka Windows Presentation Foundation aka Avalon aka XAML)

C#:
  1. WindowState = WindowState.Normal;
  2. WindowStyle = WindowStyle.None;
  3. Topmost = true;
  4. WindowState = WindowState.Maximized;

That's it, nice and easy. Setting WindowState to normal before and then maximized after fixed an issue where it was fullscreen, but didn't expand to cover the taskbar.

I did this in order to make a patch for Big Visible Cruise, a new app that displays CruiseControl.net statuses in a big noticeable window. (Issue 14)

I got some ideas from this forum post on the MSDN forums.

Big Visible Cruise is hosted on Google Code. I'd never used it before, but it was really easy and simple to log in, add a comment, and attach a patch.

December 8, 2007

Just a quick thought about Google and Microsoft:

Filed under: — David @ 12:55 pm

Google is a marketing company run by engineers; Microsoft is an engineering company run by marketers.

I had this thought as I was walking to the kitchen. It's not entirely accurate I'm sure, but a general impression from their outward appearances. Anyway, I thought it was interesting and just thought I'd share.

November 16, 2007

2 Hours With Castle MonoRail

Filed under: — David @ 10:48 am

MonoRail is one of those frameworks that I've been watching for a while, but I've never spent the time to actually dig in and start messing with it. (MonoRail, if you haven't heard, is a MVC1 framework for ASP.NET web applications, similar to Ruby on Rails2. Microsoft is also working on their own ASP.NET MVC framework3, but it's not available yet.)

A little while ago I spent a couple hours with it, just reading the tutorial and trying stuff out. I figured I could make an interesting post on my experience with it. The following is just my rough notes from that. Some might even call it live blogging.

MonoRail

I started by downloading and running the msi installer of rc3.

I created a MonoRail app through the Visual Studio wizard as the documentation suggested. It gave me some NUnit tests, they ran quickly in Resharper's test runner. Hitting F5 started Visual Studio's server and brought me to a nice looking page offering examples and documentation.

Urls are interesting. It redirects me to /home/index.castle. It seems to do this in the generated Default.aspx. This implies that I might be able to throw some webforms pages into a MonoRail site. *.castle is mapped to MonoRailHttpHandlerFactory in the web.config. Looks like standardish, somewhat advanced, asp.net stuff so far. I'd probably have to add the .castle mapping in IIS.

Images, stylesheets, and JavaScript are in a folder called Content; seems to load the same as files any old ASP.NET site.

I'm looking at the rendered html and trying to figure out where it came from. There's a Views folder, inside that a Home folder and an Index.vm file. Index.vm seems to have a few snippets, but not the main bulk of the html. Ah, layouts/default.vm has a lot in it. There's some variable replacement going on $!{title} and $siteroot, I'll have to look up the syntax later. Hmm, there's a $!scripts in the layout and a #capturefor(scripts) in the home view. This is all probably NVelocity stuff. Just found rescue views, nice!

On to the login controller... I can see it works and how the controller code gives the form values to the view through a PropertyBag. How's it decide to show the form or the result? The form's action = /Login/Authenticate.caste, the form page is /Login/index.castle. Ah, and there's two different views.

Just noticed that Visual Studio tabs are confusing when you have three Index.vms open. I just noticed that it can build links to the various pages through $Url.Link(...).

The idea of the controllers seems familiar. I've taken a look at it before and I've tried to use the MVP pattern with webforms in a few projects. I wonder if the url is tied to the controller? Is there a way to separate it? I could live with it for an internal site, but I might want more control for a public site. For example the url of this post has a lot of info in it that I think might not be in the MonoRail urls. We'll see.

I really like having more control over the html than webforms gives you.

OK, processing forms, passing variables back to the view and then the browser, got it. Not sure where to go now. Ooh! DataBinding... OK, so it's different than webforms databind. It binds fields from a form to properties on a class, very nice.

The docs then go on to ActiveRecord. I've already used ActiveRecord, so I'm going to skip it. That's it for the getting started documentation. I think I might move on to Windsor.

Windsor

Windsor while not part of MonoRail is related because they are both part of the Castle Project.Windsor is an inversion of control container.

Getting started part 2 & 3 are not done yet. It'd be nice if I didn't have to click the link to find that out... Anyway I've tried to use IoC before, I used Spring.net to configure a project, and I thought I understood IoC, but I'm not so sure I really did.

The simple example of Windsor registering a form and getting it was neat, but doesn't show me how or why I would want this. Separation of concerns: nice and all, but can't I do that without a container? Just create my objects one by one, passing them into the constructor/setting properties myself. Does this get more useful as I get more classes? Where is it practical? If I only have 5 classes that interact, probably not. What about 50 classes and each takes a couple parameters? Assuming I'm not using the configuration features (yet).

When you add configuration, it seems like a handy configuration utility, but I know that isn't the main purpose of IoC

Wrapping up

Anyway, that's all the time I have for this. Hopefully someone will find this interesting or at least I can reread it whenever I attempt to use these libraries in a future project. They're interesting, well documented, and appear easy to use. I don't have a specific need for either, so I'll wait. I don't want to force them into an existing project just because they are cool. I'll wait until I need them.

Returning to the site just now, I noticed a "Using" link in the header. It looks like there is a lot of good info in here. Maybe it could be linked to from some of the documentation. Maybe a see here for some other useful info?

  1. MVC stands for Model View Presenter, a design pattern.
  2. Ruby on Rails
  3. Scott Guthrie's Post on their new MVC framework. (It seems very similar to MonoRail.)

November 12, 2007

Avoiding the startup time for webservice xml serialization

Filed under: — David @ 1:05 pm

The short version

In the build tab of a project's properties is an option called "Generate serialization assembly", turn it to "On" to theoretically improve performance.

The long version

Recently I've been working on speeding up a web application that depends heavily on a huge webservice: 884 "operations" are supported1, the wsdl is 2 megabytes. Startup takes several minutes before anything happens. And it is mostly the startup time causing problems, things go smoothly after that.

While trying to improve things I found this single line causing most of the delay: _myStore = new WebServices3(); And it was only the first time that the webservice was initialized that the delay happened.

I started searching and ran across a knowledgebase article explaining how to create an XmlSerializers assembly. Apparently the XmlSerialization process usually generates code at runtime and this can take a while. The article explained how to pregenerate this code to save startup time later. I tried it, it didn't seem to help all that much and it was a pain to fit into the build process.

I later found a page on MarkItUp about SGen.exe. It was a new feature in .net 2.0 that I remember hearing about. Then I found this post on kiwidude.com about how Visual Studio didn't call sgen correctly for him.

I never noticed it before (maybe because I had to scroll down the properties page), but there was a simple drop down in Visual Studio for this. Switching it from Auto to On built the assembly automatically!

XmlSerialization

The end

Once enabled, build time became much longer and startup times were a little better. The change wasn't as dramatic as I had hoped. I think from here I'm going to create a much smaller, specialized web service since I have access to the web service machine and we're only using a handful of the 800 methods available.

  1. Firebug + document.getElementsByTagName("li").length

« Previous PageNext Page »