Edit: 4/12/06

I'm going to make this available as a download as soon as I have it cleaned up.  See here for more details.

Edit: 4/21/06: It is now available - More Information

Tonight, I was able to get my category AutoComplete feature working using AJAX in ASP.NET.  I have a query text box that fill the matching categories into a textbox as you type, similar in idea to Google Suggest.

Here's how it works..

As you type, the onKeyPress event is triggered, sending the query back to the server in the background.  On the first call of the page, it checks the Cache to see if the category list is already loaded.  If not, it goes out to the database and loads it into a Generic List object and then saves that object into Cache.  If it is located in Cache, it just grabs the Cache Item, casts it to List<string> and uses that.

Then I take what the user has typed so far and use List.FindAll() to find all matching values. Since it's coming out of memory most of the time, it's pretty fast.  There also aren't many categories, so even when it needs to go out to the database, it doesn't take too much time. Once it has all of the matching values, they are concatenated with commas and sent back to the client side.

The Javascript then takes that string, splits it along the commas and adds a new line to the textbox.


function fillAutoComplete(result, context) {
    fields=result.split(',');
    var txtAutoComplete = getObj('AutoComplete');
    txtAutoComplete.obj.value='';
    for (var i=0; i<fields.length; i++) {
        txtAutoComplete.obj.value += fields[i]+'\n';
   }
}

Currently, I have it just filling a textbox for test purposes, but eventually, it will be in a clickable dropdown.  The key to this is making it easy for the user to select a category of food to either add to their daily diet tracking or for the classification of custom foods.  This UI interface is a great blend of browsing and searching.  As you type, a search is performed which progressively limits the items you have to browse through.

It's coming along.. slowly, but surely.


If you liked this post, please be sure to subscribe to my RSS Feed.


Finally.. I've made it through the nutrition database for TrueWeight and normalized all the data.  There's still some work to do on assigning the foods to categories.  I'm trying to decide between putting them in one-to-one heirarchical categories or using a one-to-many approach.  I'm leaning towards the latter.  Though it will make the back end a little messier, it will make the foods easier for the users to find and after all.. the main goal of this projects is to create something that is easy to use.

Next step will be creating the actual interface parts to select and add foods to the daily menu.

 


If you liked this post, please be sure to subscribe to my RSS Feed.


Categories: TrueWeight Project 

Earlier, I was having problems finding an easy way of loading the data from the Nutritional Database into my hosted SQL Server. The import feature on the server was timing out with large datasets.

Rather than mucking around writing complicated regular expression switches to convert the delimited text file statements, I figured it would probably be easier to look for a tool that would export the Access version as SQL INSERT statements.

I found a couple of tools, but nothing did quite what I was looking for.  I wanted a utility that would load an access database, let me select a table, and then export the data as SQL Inserts and save them to a text file.  So, like any geek, I wrote one myself.

If you are interested, it can be installed from here:

SQL Scripter (requires .Net Framework 2.0)

It is very basic, doesn't have any features other than those listed above and it comes with no warranties... but it has suited my purpose just fine. The data has been exported from the local database and imported to the hosted one.


If you liked this post, please be sure to subscribe to my RSS Feed.


The past two days have been trying to say the least.  At some point Tuesday night, my host - GoDaddy.com - changed some security settings on my account.  They claimed that my site had been set up with elevated permissions and that they had "fixed the problem".  Unfortunately, those changes broke my blogging application.  After sending many emails back and forth with their technical support team, I was unable to get them to even tell me what they did so I could figure out if I could work around it.  Their official suggestion?  Upgrade to a dedicated server, which would give me full control at only 3 times the price.

Through trial and error, I found the section of code that was causing the problem and in my searching for a solution, I found another site that had already made similar modifications to the blogging engine to allow it to work under medium trust privileges within .NET 2.0.  Working from that codebase, I was able to finally get my site back up.  I've spent the rest of today making the configuration tweaks that I had already set up.

Sidetracked for two days.. but still on course.

 


If you liked this post, please be sure to subscribe to my RSS Feed.


Categories: TrueWeight Project 
Seeing as I already have the basics of the EWMA calculations built in the backend code, my task tonight was to be the loading of Nutrient Database. It's available in ASCII and Access formats. I have SQL Server 2000 as part of my hosting account, so you'd think that would be a pretty easy data load, right? Wrong..
If you liked this post, please be sure to subscribe to my RSS Feed.


Categories: TrueWeight Project 

TrueWeight is a web-based application for tracking weight and calorie intake in order to better manage your weight.  The basic idea came from The Hacker's Diet.  In it, John Walker lays out the most basic of dieting ideas.  If you want to lose weight, you need to eat less calories and exercise more in order to start burning more calories than you take in.  Duh.

Where I feel he was ingenious was in his idea to use the exponentially weighted moving average (EWMA) of your daily weight to accurately track the effects of your calorie intake and exercise.  I did this for a month and saw the difference between the high and low weights to be about 7 pounds.  Removing all of the fluctuation by examining the EWMA, I saw that I was never more than .5 pound from where I started, which made sense since I hadn't changed anything about what I ate or my activity level.

If you combine this with a detailed look at your calorie intake, you can get a reasonable estimate of how many calories you burn on an average day.  I've used many online calculators that ask you to specify age, gender, build, height, weight and activity level and it spits out a number.  Since each of us has different characteristics and metabolisms, there's no accurate way given that info to figure out how many calories we use each day. 

TrueWeight not only allows you to figure that out, but you have a list of what you ate, so you can see areas where you can cut back on food.  You can also see what effect workouts have on you.  Perhaps you'll find that if you push yourself to do a half hour of cardio every day burns off more calories than doing a full hour every other day.  TrueWeight is a tool that will help determine things like that for you based not on some generalized quiz, but based on actual data from your body.

I have used similar "calorie counting" sites before, but never stuck with them for long.  Why?  Because the interface was cumbersome.  Who wants to click 30 times to add "1 cup coffee, 1 creamer, 2 packs of sugar"?  TrueWeight will allow you to lookup the data from the USDA Nutrient Database.  It will also allow you to enter personal items, group items together into recipes or combinations, and keep a favorites list of the ones you use all the time.  Using "Web 2.0" technologies such as web services and AJAX, TrueWeight gives the users an intuitive and responsive interface.  No more tedious multi-click drilling down to find the food you are looking for.

Finally, there is the TrueWeight community.  This will give people the ability to form groups with shared space.  Examples could be all members of a family or a weight loss group like Weight Watchers.  Eventually, I see it being a social networking application of people supporting each other along the path of managing their weight.

Stay tuned.. we're just getting started with all of this.. and you'll get a chance to read about it from the ground up.

If you are interested in Beta Testing TrueWeight, please send an email, and you will be notified when the Beta is released.


If you liked this post, please be sure to subscribe to my RSS Feed.


I got this site because I wanted to start a blog.  Part of the reason I wanted to start sharing my thoughts with the world was because I think I have a pretty good idea for a website, and am in the process of building it.  Recording my progress here will help keep me focused on doing it.. or at least remind me where I left off.

I'm sure there will be some non-technical stuff mixed in here as I've also been thinking about putting more of my karate stuff online.  Taking the time to transfer the knowledge that I've picked up into written form with enough detail that someone who does not understand karate would be able to imagine what it looks like easily will help cement the movements in my own mind.  Train your mind and the body will follow.

If you don't like codin' and you don't like fightin', you're probably in the wrong place.


If you liked this post, please be sure to subscribe to my RSS Feed.


Categories: TrueWeight Project 
 

Subscribe

About the author

Wayne Hunt I am a web application developer and second degree black belt living in Providence, RI.

More about Me..

E-mail me Send mail

Other blogs

Dugg Sites

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008

Sign in