Completed My First Half-Marathon

March 22, 2010 at 8:48 pm (Personal)

This past weekend the Goathead Riders went to Moab to conquer 13 miles of beautiful view next to the Colorado River.

This was the first time I ran more than 10 miles. I think these pictures speak for themselves:

this will be cake!

DSC04554

ok, this will take some effortDSC04555 

take me out of my misery, please!

DSC04556

I don’t know if you know but I hit the side of my foot really hard on something similar to a concrete corner (it was actually floor tiles stacked in my garage). This happened 2 weeks ago. I stopped running for a little over a week to allow the injury to heal before the half but it was not enough. By mile 3 the pain came back and I continued to run with it until the end. I now have a swollen right foot =(. I’m guessing 1 to 2 weeks of no running for me. Luckily it does not hurt when biking and I’m guessing swimming is ok too.

I had another surprise at mile 11. My right hamstring wanted to cramp. But I slowed down a bit and was able to control it. By mile 11.5. Both quads wanted to cramp and then my right calf. But I ran slower and was able to avoid the torture of a full blown cramp. I guess I need to start a bit slower on my next long race.

The official time was 1 hour 58 minutes. I’m very happy with that.

While in Moab, we had to do some biking! And since The Machine was with us, the little recovery ride ended up being 17 miles long! Hey, but I’m supposed to be training for an Ironman right? So it’s all good!

DSC04631

The trip was great! I had an awesome time doing sports with good friends.

Click here for more pictures

Permalink Leave a Comment

Meet our living room

March 13, 2010 at 1:41 pm (Personal)

Our living room is still not entirely complete but it is close to being there so I wanted you to see the progress. Click on the image below to view more photos:

DSC04523

I also wanted to thank all the friends that helped us move into our home. The money we saved from the move is the one we used to purchase the living room sofas. Thank you for the perfect house warming present! We hope to see you guys using them a ton =)

And this is for my friends and family in Guatemala that are not used to snow. It was snowing when I took the living room pics so I took a quick video:

And a picture:

DSC04509

Permalink Leave a Comment

C# ASP.NET: Generating Image Buttons with Dynamic text

March 11, 2010 at 2:34 pm (Computer Science)

After writing several websites with custom buttons. I’ve had it with having to create images for each button that has a different text!

If you feel the same way then you’ll love this solution. With the code below you’ll be able to create a button.aspx page that takes a “t” url query parameter where you can specify the text and it will return the desired image. Here are some usage examples:

http://siteurl.com/button.aspx?t=Yes!” will give you:

http://siteurl.com/button.aspx?t=BACK&m=t” will give you:

http://siteurl.com/button.aspx?t=CONTINUE” will give you:

Even though the links to the image are not your usual *.png or *.jpg, the button.aspx page returns an image (content type image/x-png or image/jpeg) so it is OK to do the following in your aspx code:

<asp:ImageButton runat="server" ID="btnFormBack" ImageUrl="button.aspx?t=Continue" />

OR

<a href="targeturl.html"><img src="button.aspx?t=Continue" /></a>

Pretty cool ha!

Well, and now to the code. This is your button.aspx file:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="button.aspx.cs" Inherits="controls_button" %>
<%@ OutputCache VaryByParam="m;t" Duration="9123123" %>

And your button.aspx.cs file:

public partial class controls_button : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var text = this.Request.QueryString["t"];
        if (string.IsNullOrEmpty(text))
            throw new ApplicationException("The text url parameter must be specified");

        var sMirror = this.Request.QueryString["m"];
        bool mirror = (!string.IsNullOrEmpty(sMirror) && sMirror == "t");

        var rightImageWidth = 10; // in pixels
        var imageHeight = 42;
        var topPadding = 11; // top and bottom padding in pixels
        var sidePadding = 10; // side padding in pixels
        var textBrush = new SolidBrush(Color.White);
        var font = new Font("Arial Black", 11);


        //-------- Calculate the text's width
        // this graphics and bitmap object is just temporary. I could not 
        // find a way to calculate the text' width witout having one.
        var bitmap = new Bitmap(300, 300);
        var graphics = Graphics.FromImage(bitmap);
        var textSize = graphics.MeasureString(text, font);
        bitmap.Dispose();
        graphics.Dispose();

        //-------- Create the graphics object
        var bitmapWidth = sidePadding * 2 + (int)textSize.Width;
        bitmap = new Bitmap(bitmapWidth, imageHeight);
        //bitmap = new Bitmap(500, 40);
        graphics = Graphics.FromImage(bitmap);

        // Draw the background
        var leftImage = System.Drawing.Image.FromFile(this.Server.MapPath("~/resources/button-left.png"));
        var rightImage = System.Drawing.Image.FromFile(this.Server.MapPath("~/resources/button-right.png"));
        graphics.DrawImage(leftImage, 0, 0, bitmapWidth - rightImageWidth, imageHeight);
        graphics.DrawImage(rightImage, bitmapWidth - rightImageWidth, 0, rightImageWidth, imageHeight);
        // These disposes are necessary, otherwise the files get locked 
        leftImage.Dispose();
        rightImage.Dispose();

        if (mirror)
            bitmap.RotateFlip(RotateFlipType.RotateNoneFlipX);

        // Draw the text
        graphics.DrawString(text, font, textBrush, sidePadding, topPadding);

        
        //-------- Serve the Image

        this.Response.ContentType = "image/x-png";
        
        // The line below breaks on the production and development servers
        // (it does not break on my computer). I was getting the following
        // vague exception "A generic error occurred in GDI+". I found this 
        // post that showed
        // me the work around http://aspalliance.com/319 . In short it says
        // that some image formats (like Png) require a seekable stream when 
        // saving. The Response.OutputStream is not seekable so we
        // have to use a MemoryStream as an intermediary.
        //bitmap.Save(this.Response.OutputStream, ImageFormat.Png);

        var memStream = new System.IO.MemoryStream();
        bitmap.Save(memStream, ImageFormat.Png);
        memStream.WriteTo(this.Response.OutputStream);

        // Some cleanup, not sure if it is all needed
        this.Response.End();
        memStream.Dispose();
        graphics.Dispose();
        bitmap.Dispose();
    }
}

And you also need to have these images in the ~/resources folder of your website. If you want to have them in another folder, update the .cs code.

~/resources/button-left.png :

~/resources/button-right.png :

Enjoy!

Permalink 1 Comment

Days in warmer weather

March 9, 2010 at 1:04 am (Bike)

The Ironman crew went over to St George for the first bike ride of the year. We mountain biked, road biked, and did a bit of running.

On Saturday, we mountain biked the Barrel Roll, sidewinder, and the Black Brush trails for a total of 12 miles. This was a fun ride. We were all there and we split up so we all had a great workout.

DSC04439

Carol showed full control of her Iron Horse; going up and down rocks next to life threatening cliffs with no problem.

DSC04460

DSC04457

She had tons of fun for the first 2 to 3 miles. But she did 6 miles total and in very rough terrain; at the end she was excruciatingly tired. I hope she remembers the fun parts and forgets the painful ones so she comes with me to the trails more =),

On last 4 miles of the 12 I started feeling like both of my quads were going to cramp out so I had to pull my pedals more to give the quads a rest. I’m glad I did that because I pushed Carol’s bike and my bike on the uphill parts of the last 3 miles and there was no way to not use my quads there. I was able to avoid the cramps.

After the mountain bike ride we took a lunch break and then ran 3 miles. It’s interesting that I was feeling great for the first 2 miles and then my quads began to give out again; I had to slow down to fight cramping. So the lunch break of about 2.5 hrs gave me 2 miles of running.

That night I slept like a baby. And the next day we did 20 miles of road biking on Snow Canyon. The scenery there was great, we were biking next to the red rock I like so much.

DSC04498

 

My right knee was hurting all the time so 80% of the pedaling had to come from my left leg, but I fared ok. My knee feels ok now. I’m sure it hurt because I started biking too hard after not touching my bike for the entire winter.

What a way to start biking on 2010! Click here if you wish to see more photos

Permalink 1 Comment

Bike Season is around the corner!

March 3, 2010 at 9:15 am (Bike)

Last night I finished putting together my mountain bike and tuned my commuter bike.

My mt bike now has new Mavic Crossline rims and shimano XTR pedals. Hopefully i don’t get more broken spokes. And I got the pedals so that I could have my two bikes with spd pedals and could use the same shoes on both bikes. I moved the old pedals from my mt bike to my commuter bike.

We’ll see how long the commuter bike holds the training. I might end up getting a road bike. But at least I’ll start training with what I have.

We’re heading to St. George this weekend. The weather will be warmer for sure, but it might be rainy. Hopefully we can do some mountain biking on the red rock desert, some road biking with great scenery, and some trail running.

Permalink Leave a Comment

Follow

Get every new post delivered to your Inbox.