Thursday, May 17, 2007

Loren Ipsum library for .NET

It's QA Time in my world now... Just finished implementing a TeamSite/ASP.NET Intranet with a nice framework that allows TS to really only manage the content and metadata as XML and ASP.NET manages the presentation layer. The data access layer is defined by some XML that generates not only .NET access classes (using XML deserialization, of course), but helps us build all of the DCTs for the content entry.

Anyway, it's time to stress test this thing, and we're going to need a lot of data to really simulate what Intranets and Corportate websites can get like after a couple of years of abuse... That's more than my stubby fingers can type, and I dare say more than I can even copy/paste from www.lipsum.com. I figured it was high time to just make a library... Since they kindly provide an XML feed, it's super easy to just generate a request and pull the text out of it. I took it a small step further and blew out the API about as fully as possible.

Anyway, generating random content is now as easy as:
LipsumResponse r = Generator.Get(new LipsumRequest(20, LipsumRequest.RequestType.WORDS, false));
Console.WriteLine(r.Lipsum);
Here's links to the source, binaries, and documentation:

Documentation
Source
Binaries

#    Comments [0] |
 Monday, May 07, 2007

Spring planting


It's finally warm enough to do more than just keep a bunch of twigs watered! Unfortunately, I lost more than I thought I would over the winter, but oddly enough, a few things came back that I wasn't expecting.

I lost the rosemary, sage, clematis, and all of my fall plantings including a fern and a couple of different grasses. That's a little sad, BUT the japanese maple came back extremely strong. Barb's bonsai redwood was almost a lost cause, but it is super green - it was hard to keep it watered during the winter when it looked like just a stick.

The regular thyme came back which I expected, but I didn't expect to have peppermint. What surprised me most were the two sprigs of flat-leaf parsley! I managed to save those three and set up some basil and tri-color sage.

We've also got about 12 tomato plants - and I'm gonna try to plant a few of them in upside-down containers. We'll see how that turns out.

Here's to tomatoes, basil, and mozzarella all summer long!
#    Comments [0] |
 Sunday, May 06, 2007

Honey Wheat (or White) Bread



We got a new food processor and I decided to take advantage and start making some bread. I'd rather use a mixer with a dough hook, but there's a lot on the wish list right now.

Anyway, I wanted to share. The recipes from Cook's Illustrated are great, but I'm never one to leave well enough alone. I've made two versions of the bread - one white and one brownish with grains and seeds. Here's the recipe:

White
  • 1 1/3 cup whole milk
  • 2 tbs unsalted butter
  • 3 tbs Really Raw Honey (that shit's good)
  • 1 packet active dry yeast
  • 1lb 2 1/2 oz unbleached all-purpose flour
  • 2 tsp salt


Wheat
The process is the same for both.

Heat the liquids in a small saucepan until the temp is 110 or 115 using an instant read thermometer. I like the tase of the honey and am usually a little heavy handed with it. With bread, since there's so few ingredients, the taste of the individual pieces really comes through. The raw honey has a great strong taste - try it! Once the butter's melted and it's all still 110 degrees, whisk in the yeast to dissolve. Most recipes call for you to "proof" the yeast, but just getting it dissolved is good enough.

[The following assumes you're using a food processor - if you're not, I'm sure any other method will work just as well]
Add the flour and salt to the processor - but not the seeds or grains. Pulsing the processor, add the yeast/liquid mixture only as fast as the flour will absorb it. The dough should form a ball and pull away from the sides - if not, sprinkle in some flour until it does.

Remove the dough ball and knead for about 3 minutes. The dough will be a little sticky, but try not to add too much flour. Knead in the grains and seeds at this point if you are adding them. Place the kneaded dough in an oiled bowl and allow to rise for 1-2 hours in a warm spot until it's doubled in size.

Remove the dough and puch it down into a size that will fit into a 5x9 bread pan. Place it into a buttered bread pan and allow to rise for another 30-45 minutes.

Put a sheet pan or pie pan with 2-3 cups of warm water in the bottom rack of a 350 degree oven. Brush the top of the bread with olive oil and place on the second rack. Cook until the internal temperature of the bread reaches 195 degrees using an instant read thermometer. Remove from the pan and place on a wire rack to cool. Don't forget to pull out the water pan before it boils dry. Wait for the bread to cool completely before slicing.


#    Comments [0] |
 Monday, April 23, 2007

Warm-weather-driving season and Earthday hangovers

The warm-weather-driving season kicked off this weekend! I've decided to make sure that Norton is completely taken care of in the next month or two with a plan to give him a new shell by this time next year!

I took care of a bunch of small stuff like changing the headlights from UK style Wipacs to Hella DOT lenses, new wipers, tightened the drop arm (damn thing won't stay!), and pulled out all the damp carpet.

The one big thing that I took care of is rewiring the starter. The PO had used some #1 copper that I could barely bend by hand and kept the battery box from shutting completely.  I had previously used some #1 welding wire for the winch which worked out GREAT - and took an afternoon to rerun all of the ground/starter wires in #2 welding wire. What a difference. Everything is so much more tidy now.

Another big item that I'm really looking forward to is swapping out the Sparco Evos for some standard Defender items. The Sparcos served me well, but I think my butt's getting a little big for them.

In other news, I have to say that I was totally surprised to hear about Bloomberg's plan to increase the number of bike lanes as part of his plan to reduce emissions. I can't say that I believe that the conjestion charge will do more than make more money for the city, but the rest of it is great.

Also - I rode in to work this morning and saw two things that I've never seen before. First, a traffic cop signaling traffic yelled at a guy in a van to watch the bikers (who were, admittedly, running a red light). Then a couple of blocks further, a patrol car had pulled over a guy on a Vespa for buzzing along in the bike lane!

It’s probably just some earth-day overrun and will revert back to standard operations soon enough, but I thought I’d share.

#    Comments [0] |
 Wednesday, November 15, 2006

Quick and easy passwords for ASP.NET

There are quite a few samples on the net which will provide alternate password protection schemes for ASP.NET. There are also built in authentication and authorization mechanisms which are great at what they do, are robust, proven, and super flexible. Occasionally, however, you need something a little simpler.

In my case, I generally need to provide a basic password protection for simple admin/reporting tools or development environments I want to keep away from prying eyes. The optimal solution for me would be something that I can simply set up in web.config and forget about.

This article will outline the basics of getting something as simple as that set up and how you'd configure your web application once the code is running.

Setting up browser-based authentication involves the following steps:

  • Derive from the HttpModule base class
  • Interpret the appropriate HTTP Headers
  • Validate against a configuration or data store
  • Modify the appropriate HTTP Headers based on the result

Code

In setting up our HttpModule, the event that we are most interested in is Application.AuthenticateRequest. We need to setup a handler for it in the HttpModule.Init() method.

Once that's done, we can handle the bulk of the HTTP work that needs to be done. This little bit of code sets up the variables and tests to see if we can even handle this request.

HttpApplication app = (HttpApplication)source;
string authStr = app.Request.Headers["Authorization"];

/* If there's nothing in the header, then it's an anonymous request */
if (authStr == null || authStr.Length == 0)  return;

/* If the authtype isn't Basic, then assume someone else will handle it. */
authStr = authStr.Trim();
if (authStr.IndexOf("Basic",0) != 0) return;

Next, we need to interpret the header information which is stored in Base64 for basic authentication.

string encodedCredentials = authStr.Substring(6);
byte[] decodedBytes = Convert.FromBase64String(encodedCredentials);

string s = new ASCIIEncoding().GetString(decodedBytes);
string[] userPass = s.Split(new char[] {":"});
string username = userPass[0];
string password = userPass[1];

Finally, authenticate the user using the credentials we were presented with and modify the headers to reflect the results. If we are successful, give the current context a Principal based on our credentials in case that information is needed further down the line.

if (AuthenticateUser(app, username, password, out roles))
{
    string realm = "dieselrover";
    app.Context.User = new GenericPrincipal(new GenericIdentity(username, realm),
roles);
}
else
{
    DenyAccess(app);
}

The AuthenticateUser method simply checks the credentials against some settings in the web.config. If you are interested in seeing that, just download the project and browse through it. You can easily override that method with your own if you want a more complicated data store for usernames and passwords, but I would strongly suggest evaluting a more robust solution if you need "real" authentication.

Configuration

Now lets look at how to set this up and get it running. For those of you not interested in how it really works, you can just download the binary, put it in your bin folder, and edit the web.config file.

First, set up the configuration handler:

<configSections>
   <section name="MonoSite.Authentication"
type
="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>

Second, configure the authentication settings by setting the username, password, and realm. The realm is used by the client to organize saved passwords.

<MonoSite.Authentication>
  <add key="username" value="admin" />
  <add key="password" value="admin1234" />
  <add key="realm" value="dieselrover" />
</MonoSite.Authentication>

Third, setup the HttpModule.

<httpModules>
  <add name="Authentication"
type
="MonoSite.Http.AuthenticationModule,MonoSite.Http.Authentication" />
</httpModules>

Lastly, tell ASP.NET that you want there to be some sort of authentication.

<system.web>
 <authorization>
  <deny users="?"/>
 </authorization>
</system.web>

If you want to only password protect certain subfolders of your application, you can do that easily by using the location tag.

<location path="admin">
 <system.web>
  <authorization>
   <deny users="?"/>
  </authorization>
 </system.web>
</location>

Source code and binaries

#    Comments [0] |
 Tuesday, July 04, 2006

Landrover list archive

I made a small update to the land rover list archive. I have been meaning to index each list individually so that you could search one at a time, but only now got around to it.

I think the next big change will be automatically archiving as much as possible since the last time I've done any of that was August 2005.

Another item on the road map is tagging and ranking. I'm not sure if anyone is really using the archive but me, but I'd find it a lot more useful if I could mark entries by subject and come back to them later.

#    Comments [0] |
 Monday, July 03, 2006

After a 17 hour haul in Norton...

I was just pulling in to NYC after a long 17 hour haul from Indianapolis (and before then, southern missouri for some canoeing) when I saw a bearded guy with a tan 88" wagon stopped at the gas station right before the Holland Tunnel.

We both waved and I felt that he was a little more eager to greet me than I was him for a chance run-in at 12:30 in the AM. As I pulled away and paid my toll, I realized that he had his hood up and may not have just been checking his oil.

If that's the case, my karma has gone to hell. If anyone knows who this might be, please send my apoligies... I couldn't have done much since I wasn't carrying any spares to speak of. I doubt there's much aside from a few electrical connectors that our trucks may share. Even so, being in the same situation, I know that even having someone to commiserate with at 1:00AM is as helpful as anything else.

#    Comments [0] |
 Friday, June 02, 2006

Offroading in Morocco

I'm finally getting around to putting up these pictures that have been sitting around far too long. It was about this time last year when Barb and I were tooling around Morocco in a land rover with Trailmasters.

I have to admit I was VERY nervous, but the trip was amazing. Anyone who has the ability to do something like this should do it without hesitation. I've divided the pictures up into three sections to make navigating them a little easier.

#    Comments [0] |

-