Hi, welcome to Will Code For Coffee dot com, the personal blog of Eric Hoff. After a short hiatus I'm now working on bringing the site back up and blogging regularly again.
Keep checking here for more new articles!
I’ve been working on some ASP.NET projects lately and encountered something that was easy to solve, and should have been obvious straight off.
I was using a GridView to display some values including some columns that show dates. To edit the dates I wanted to use some controls from the AJAX Control Toolkit, specifically the MaskedEdit to format the input and the pop up Calendar control, so I had to use a TemplateColumn in the GridView and setup the EditTemplate with these controls.
I also wanted to format the date inside of the ItemTemplate to match the format of the other date BoundFields.
Even in ASP.NET 2.0 this was pretty easy, I just setup the template as follows:
<ItemTemplate>
<%# // If DueDate is null returns an empty string, otherwise formats and displays the date properly.
(null == Eval("DueDate")) ? string.Empty : DateTime.Parse(Eval("DueDate").ToString()).ToString("yyyy/MMM/dd") %>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="DueDate" runat="server" Text='<%# Eval("DueDate") %>' />
<tk:CalendarExtender ID="DueDateCalendar" runat="server" SkinID="Calendar" TargetControlID="DueDate" />
<tk:TextBoxWatermarkExtender ID="DueDateWatermark" runat="server" SkinID="DateWatermark" TargetControlID="DueDate" />
<tk:MaskedEditExtender ID="DueDateMaskedEdit" runat="server" SkinID="DateMask" TargetControlID="DueDate" />
</EditItemTemplate>
The biggest thing was checking for null in the Eval statement for the ItemTemplate. I also setup the ObjectDataSource to ConvertEmptyStringsToNull.
I had a problem when my CakePHP session wasn’t saving from page to page and it turned out the session ID (from session_id()) was changing from page to page also.
It turns out to be a simple problem: I had pointed Apache to my app folder not my app/webroot folder.
This also caused webroot to be inserted into all my URLs as well.
Quick and easy fix. Long frustrating time to figure out. 
I found this really great resource for getting into some of the CakePHP 1.2 helpers. They’ve changed things from 1.1, especially the FormHelper.
Check it out here: http://www.donutczar.com/cake1point2/donuts/
Today I was reading Scott Guthrie’s blog post about the LINQ to SQL. IMHO LINQ looks like the best tool for .NET since C# Attributes! Since the .NET LINQ to SQL Designer will compile a database context for you we’ll never have to write stupid unit tests just to check if a query works (note: I said stupid unit tests). You’ll know the query works by the old programming myth “Well it must work, it compiled!”. Obviously we’ll still have to test some queries, but you know what I mean. You change a column name or drop a column from a table and sometimes you don’t know what parts of the application you broke until either your unit test fails, or if your unit test wasn’t explicit and specific enough, when your customer complains that the report isn’t working anymore.
Ever since Ruby on Rails came out and I actually learned it I lost my enchantment with ASP.NET - until now. Ruby on Rails still blows my mind with how easy it is to use, but I’m really happy that .NET now includes the AJAX framework and this excellent query tool.
The only thing I want from .NET now is Database Migrations in C# a la Ruby on Rails.
I’ve redirected everything from http://eric.willcodeforcoffee.com to http://willcodeforcoffee.com using Apache redirects. It is pretty simple, I just created a .htaccess file in the web root for eric.willcodeforcoffee.com and added this one line:
RedirectMatch permanent ^/$ http://willcodeforcoffee.com/
Now it nicely, and permanently redirects everything from http://eric.willcodeforcoffee.com/.
There is one catch however: what about stuff in sub-folders, like http://eric.willcodeforcoffee.com/files/? The above redirect doesn’t handle that so I also added:
RedirectMatch permanent ^/* http://willcodeforcoffee.com/
It doesn’t redirect to the matching pages, but I don’t really want to do that anyways.
Hi, I’m moving my blog here. I did a manual install on eric.willcodeforcoffee.com and it hasn’t let me post in months, even with updates and stuff…
So I’ve moved the blog to the top level. We’ll see how that goes.
In CakePHP there is an AJAX helper based on the Prototype library. During an AJAX event, such as clicking a link generated by the AJAX helper ($ajax->link()) you can add javascript call-backs to the $options parameter. These are the callbacks, in the order they are called:
- before
- loaded
- interactive
- complete
- after
- loading
I was expecting a different order, such as loading to come before loaded, but this is how it is!
Also, if you’re updating the content of a <div> it will be updated between the Interactive and Complete steps.
This marks the end of the first day of the second week in the life of the Hoffsoft Consulting Services Corporation. Last week I incorporated and I also sent off my business license request. It’s been exciting, but time consuming.
I’ve been reading a book called Success God’s Way by Dr. Charles Stanley, one of my favourite podcast friendly preachers. The chapter I read yesterday was about the successful use of time, and I was really impressed. Probably one of the biggest problems I struggle with lately has been time management and the effective use of time. I have often felt very overwhelmed by the problems involving working, maintaining my house, managing my father’s estate, building a relationship with my wife, and maintaining relationships with friends - and also trying to fit in time to read books at the same time.
It hasn’t been really easy for me, and probably one of the biggest problems for me is that I didn’t set clear goals for my use of my time. While this book is obviously a book by a Christian author for a person setting God based goals, there is a chapter on time management that wasn’t entirely Bible based, and related some interesting stories from successful business men that Dr Stanley follows himself; at the end of every day he writes down a list of items he would like to accomplish the next day in order of priority and importance, then the next day he follows this list in accomplishing tasks and getting things done.
Probably the most brilliant part of this plan is actually planning the time on the night before. This might seem funny, but to me it makes the most sense! Even when I was working in an office I would spend a lot of time spinning my wheels doing things like getting coffee, checking emails and reading blogs first thing in the morning because I wouldn’t have a set goal for that day in front of me yet. Usually by about 10:30 (or my third cup of coffee) I would snap out of it and start planning my day and getting to work. That is a lot of wasted time in the morning! I’m not sure how bad it has been in the last two weeks, but after reading that chapter last night I’ve been really motivated to change!
In keeping with the tips I’ve learned from this book I’ve started using a new tool, called the GTDTiddlyWiki for managing my goals and for organizing my tasks. I’ve got a default list of Today’s Tasks (today I set it in the morning, but I reviewed and set Tasks for tomorrow at the end of the day) and also a list of Short (next 1-4 weeks), Medium (1-6 months), Long (6 months - 2 years) and Very Long Range Goals (2+ years).
My Short Term goals mostly relate to my current tasks and things I need to get done, Medium Term goals are things that are a little more vague like “Keeping up with ASP.NET developments” that will transform as new code is released, Long Term and Very Long Term goals are goals about my company (i.e. growth by number of employees and earnings) and writing a novel.
I wonder what the effect of reading these things will be on me? I’m excited to find out. I’m going to try to post to the blog a little more often, and this is definitely one of the things I will blog about.
No more day job! Today marks the first day I will be working on my side business full time! I’m really excited. I know it will mean a lot of work and sacrifice, but I’m up to the challenge.
Just a warning to anyone else out there who uses Skype: Skype uses TCP Port 80 and Port 443 as alternatives for incoming calls! This will prevent you from starting up IIS or Apache (which was happening to me).
To fix this issue open up Skype Options (Tools > Options in the Menu) and select the “Connection” tab. There you will find a checkbox marked “Use port 80 and 443 as alternatives for incoming connections”. Uncheck that box and you should be okay.