Saturday, January 10, 2009

Greg’s “Weight Toss” – This is my one year Fat-iversary

Last year I decided it was time to get serious about managing my weight. I’ve always fought my weight as has my father and his family. I looked to him and them as an example, and excuse. Last year I was tired of excuses. It was time I lead by example and took ownership of my weight. To truly own the problem, for if you don’t own it in your heart, it’s very hard to change it. Last year it was time I finally owned my weight.

On 1/9/2008 my official weight was 266 pounds, total cholesterol 223, LDL 187 and HDL 38 and my pants were 44’s. Yeah, ouch.

With professional advice and guidance, I made an wild and insane seeming at the time weight goal of 200 pounds. My initial daily calorie intake goal was 2200, which we’ve since adjusted downward to my current, self imposed, daily goal of 1,600’ish. On 1/10/2008 I started logging my calorie and fat intake and walking at least 30+ minutes a day, five days a week.

Yesterday at my “official” weigh-in I was 198, total cholesterol 152, LDL 93 and HDL 41 and I’m wearing 35’s. Oh cool is that!

image

One way to think about weight management, is that it’s not weight “loss”. You don’t want to find this weight again, do you? Then it’s not a loss. You’re not losing anything. You are the weight tossing! Tossing it out with the garbage. Just as you don’t want to find that garbage back in your house, you don’t want to “find” that weight again either… Not a loss but a toss.

So how do you toss the weight? First, accept that you are going to make an ongoing life style change. That you don’t need to diet, as diets end, but instead to make a basic and long term change to your eating habits and life style.

Second, I suggest professional advice and guidance. My insurance covered my visits with a licenses dietitian (minus co-pay of course). Yours might too. In any case, GET PROFESSIONAL ADVICE. They are trained to help you, they can provide you tips and guidance you might never find if to try to go it alone. It’s not hard, nor painful and they are there to help you… (Thank you Tami, for all your help and advice! You rock! :)

Third, log what you eat, calories at the very least. You will be amazed at the calorie cost of food you are taking in. Yes, it can be hard to get started, but it’s vital that you do this. If you don’t know what you’re taking in, then it’s hard to know how much you need to burn. Just the very act of logging helps make you aware of what you’re eat. I have a log of everything I ate in the last year (in Excel, cause I’m a geek, with charts, daily summary, etc  ;) that without which I wouldn’t have been able to make the life style change I needed to make.

It’s like not having a gas gauge on your car. Imagine the gas tank could get bigger as needed and we didn’t have a gas gauge. We would fill it all the time and keep it full “just in case”? We’d probably also overfill it, not even realizing we were doing it, wouldn’t we? A food log can be your body’s gas gauge.

If you do nothing else, at least be aware of the calorie cost of your current diet. Don’t “cheat” and don’t skip entries. Just be honest with yourself and look at what you’re eating, in hard numbers. I’m telling you, you’ll be shocked at the cost of that dinner you had last night. Or the lunch, or that snack.

You don’t need an expensive program or some fad diet. You need to know what you’re taking in so you know how much to burn. And if you’re not burning much, say because you’re a programmer and sit on your butt most of the day, then you just need to take in less. Sounds simple, but it will take work. Just as important is a willingness to be honest with yourself and to realize that this is a life style change and that only YOU can do it.

Finally, there’s should be no guilt. If you want some ice cream, then have some. Want a cookie? Have one. Just log it and realize you might now have to do more to burn it off. Don’t punish yourself, don’t deny yourself and don’t starve yourself. Remember, “ongoing eating and life style change”. Drastic behavior is not sustainable.

 

Okay, enough for now.

BTW, my new goal is 180. I’d really like to comfortably wear 34’s, and Large T-Shirts (last year I was wearing XXL’s). How cool would it be to say, “I lost a foot… 44’s to 34’s…”   ;)

Friday, January 09, 2009

Using console GHTMDOC utility to convert HTML/ASPX files into PDF’s

CodeProject - Convert aspx pages to pdf

“…

There have been some articles on converting local files to pdf on this site, but I was looking for a solution to serve dynamic pages directly as PDF. This should be done by using the user's session, eg rendering a user-specific report. 

This article shows a quick and dirty way to accomplish this using ghtmldoc. Ghtmldoc is a GPL licensed program that converts a html file on disk to pdf. I have included a binary version of the program, but feel free to create your own as I'm not sure that it's the latest version. You can find more info on htmldoc at http://www.easysw.com/htmldoc/ (I am not in any way connected to them.)

…”

I guess I’m a serious console app kick…

Anyway I’ve been keeping my eyes open from a good, cheap (free) HTML to PDF conversation utility that I can use from .Net for a feature I want to add to my Blogger Backup utility.

All the good conversion libraries I’ve found have all been commercial, and since my utility is open source/source available (and there’s no way I can justify to me DFO spending the funds), the feature has been stalled.

I don’t know if this is the “one” but it looks worth a try…

 

Related Past Post XRef:
Using Tesseract (Open Source OCR from Google) as a tool to learning .Net console application launching and monitoring
Deadlock avoidance when using redirected StandardInput, StandardOutput and StandardError with System.Diagnostics.Process
A C# class to make running, and capturing their output, command line/console applications “slick” and easy (From the author of PoshConsole)
.NET and integration with BCP

Using Tesseract (Open Source OCR from Google) as a tool to learning .Net console application launching and monitoring

Rick Minerich's Development Wonderland - Processes in .NET Part 3 – Interfacing With Simple Console Programs by Example, Tesseract OCR

“Did you know that .NET provides an easy way to interact and control console programs?  In this article I will walk you through this process by creating a wrapper class for Google’s Tesseract OCR application.  At the end of this post, I will provide a complete WinForms-based frontend for Google’s Tesseract OCR Engine

You would think that this is a particularly simple case as Tesseract only needs to be passed in parameters and requires no flow control.  Ideally, we will simply leverage the Process class to control how Tesseract is launched and read from it’s output.  Initially, this is only a small jump from what we learned in Processes in .NET Part 2.  The only real difference here is that instead of using Verbs we are specifying behavior through the ProcessStartInfo’s Arguments property

Unfortunately, while this very simple example will work in many cases, this is not one.  This is because Tesseract.exe secretly launches a separate process and immediately exits.  This makes the WaitForExit() call look like it was successful but, as OCR takes a while, when you try to read from the output file it will either not yet exist or it will be locked for writing by the Tesseract process.

There are many different ways to approach this problem.  In this case an easy method would be to try repeatedly to access Tesseract’s log file using a timeout to ensure our program doesn't lock up. …

Designing a Wrapper Class

Tesseract has a number of quirks which makes it somewhat annoying to deal with, at least when compared with most other command line applications.  It’s important to be on the lookout for these kinds of small quirks when building an interface to an application.  For completeness, I’ll list what I’ve found for Tesseract here along with solutions.

An Asynchronous Wrapper for Easy WinForms Integration

Once you have all of the little quirks of your application covered, the only issue left is that calling your ExtractText method leaves your application locked up for it has returned.  The best way to deal with this is to use an DynamicInvoke on a delegate and managing the update to your console application via a callback.  To make this easy I wrote an asynchronous child class.

…”

There’s a ton of cool lessons in this post, from dealing with Tesseract, to handling unusual command line/console app’s to writing non-blocking WinForm code…

(via Reflective Perspective - The Morning Brew #261)

 

Related Past Post XRef:
Tesseract 1.01
Tesseract OCR - Released as Open Source
.NET and integration with BCP

Thursday, January 08, 2009

“Query Analyzer” for SimpleDB – Visual Studio 2008 Add-in that makes querying SimpleDB almost too easy?

Mindscape Blog - SimpleDB Management Tools Released

“With the present buzz around cloud computing, it’s proved a timely moment for Amazon’s SimpleDB database service to come out of beta. And since it’s free for low-volume usage there’s been a big uptick of interest in SimpleDB. However, although Amazon provide APIs and libraries for programming against SimpleDB, they don’t provide any off the shelf tools for quickly managing or viewing your SimpleDB data.

We’re therefore pleased to announce the release of SimpleDB Management Tools, a Visual Studio add-in that you can use to manage your Amazon SimpleDB domains and data from within VS2008.

sqlquery

Using SimpleDB Management Tools, you can create and delete domains, view the contents of your domains, run queries and edit and save data, using the kind of visual interface familiar from traditional databases such as SQL Server or MySQL. SimpleDB Management Tools installs itself as a data provider in Server Explorer, from where you can navigate your domains and launch query windows …

There’s a free version of SimpleDB Management Tools available. The free version only allows you to view or edit the first 20 results of a query, but is otherwise fully functional and is not time-restricted. Please note that you’ll need Visual Studio 2008 Standard edition or above. Purchasing a license is inexpensive at only $29 per seat and is available immediately …”

Why too easy? Because now they’ve made me really want to play with SimpleDB! Grrr! It’s not like I don’t have enough “Greg Project’s” already!  LOL

What caught me eye was the interface. There just something about writing SQL statements… Yeah I know, I need help. I also liked the price point. Both that there’s a free (limited) one and that the commercial version is $29. $29 is nice price point for something like this. Not too cheap, yet still affordable for hobbyist dev (or Pro who has to justify this to his DFO, his Domestic Financial Officer… ;)

BTW, if you’re interested in this, then you might want to check out their LightSpeed product. This is their ORM product (for which they are also offering a Free Express version) which has, or will have in the very near future, native support for SimpleDB. Yep, a Cloud enabled ORM… How cool is that?

Thanks to John-Daniel for the heads up.

 

Related Past Post XRef:
Amazon's new SimpleDB Service

Want the source code and unit tests for the managed Silverlight 2 controls included in System.Windows.dll, System.Windows.Controls.dll, and System.Windows.Controls.Data.dll? Here you go…

Microsoft Downloads - Sample Source Code for Silverlight 2 Runtime and SDK Controls

“This download contains the source code and unit tests for the managed Silverlight 2 controls included in System.Windows.dll, System.Windows.Controls.dll, and System.Windows.Controls.Data.dll.

File Name: Silverlight 2 Control Sample Source Code and Apps.exe
Version: 2
Date Published: 1/7/2009
Language: English
Download Size: 881 KB


To develop Silverlight-based applications that use the Silverlight 2 controls, you do not need this source code. The source code for the Silverlight 2 controls enables you to learn the inner workings of the controls. This is useful if you want to extend the controls or use them as a reference implementation when you implement your own controls. Complete unit tests provide additional guidance in developing polished, professional controls.

The source code for the Silverlight 2 controls includes implementations for the following controls:

  • ButtonBase
  • Button
  • HyperlinkButton
  • CheckBox
  • RadioButton
  • CheckBox
  • ToogleButton
  • RepeatButton
  • RangeBase
  • Slider
  • ScrollBar
  • ProgressBar
  • Calendar
  • DataGrid
  • DatePicker
  • GridSplitter
  • TabControl

…”

The download is a self extracting zip file with a ton of source (C#) and tests. Just the thing to get the blood pumping on a Thursday… ;)

image

BTW, you’ll need the “Microsoft® Silverlight™ Tools for Visual Studio 2008 SP1” installed in order to open these projects/solutions (funny that… lol ;)

Wednesday, January 07, 2009

IE8 Windows Update Blocker Toolkit Released

Microsoft Downloads - Toolkit to Disable Automatic Delivery of Internet Explorer 8

“The Internet Explorer 8 Blocker Toolkit enables IT Administrators to disable automatic delivery of Internet Explorer 8 as a high-priority update via Automatic Updates and the Windows Update and Microsoft Update sites.

File Name: IE8BlockerToolkit.EXE
Version: 1
Date Published: 1/5/2009
Language: English
Download Size: 115 KB


To help our customers become more secure and up-to-date, Microsoft will distribute Windows Internet Explorer 8 as a high-priority update through Automatic Updates for Windows XP Service Pack 2 (SP2) and higher, Windows XP Professional x64 Edition, Windows Server 2003 SP2 for x64 and x86, Windows Vista for x64 and x86, Windows Vista SP1 for x64 and x86, and Windows Server 2008 for x64 and x86. This Blocker Toolkit is intended for organizations that would like to block automatic delivery of Internet Explorer 8 to machines in environments where Automatic Updates is enabled. The Blocker Toolkit will not expire.

Note:

  • For computers running Windows XP or Windows Server 2003, the Blocker Toolkit prevents the machine from receiving Internet Explorer 8 as a high-priority update via Automatic Updates and the Express install option on the Windows Update and Microsoft Update sites; Internet Explorer 8 will be listed as an optional update with the Custom install option.
  • For computers running Windows Vista or Windows Server 2008, the Blocker Toolkit prevents the machine from receiving Internet Explorer 8 as an important update via Automatic Updates on the Windows Update and Microsoft Update sites; Internet Explorer 8 will be listed as an optional update.
  • The Blocker Toolkit will not prevent users from manually installing Internet Explorer 8 as a Recommended update from the Windows Update or Microsoft Update sites, from the Microsoft Download Center, or from external media.

…”

While I wish I lived in a world where I wouldn’t need this, I don’t. So I’m sure I’ll need this (as I need the IE7 Blocker).

 

Related Past Post XRef:
"Toolkit to Disable Automatic Delivery of Internet Explorer 7"

Monday, January 05, 2009

code2plan – Free Agile project management for the single developer or dev team

code2plan

image image

This is a pretty cool looking project written in .Net 3.51, WPF and LINQ to SQL. While the source is not available, the basic edition will be free for forever.

If you’re looking for a simple project management tool for your project and/or team, are doing agile based dev (XP, Scrum, etc), then this might be something to check out. Since it’s in beta I’m sure the team (two coding till their fingers bleed guys) will be very open to your comments and suggestions…

Thanks for the Jesse for the heads up

SQL Server VARBINARY vs FILESTREAM – The code and performance trade offs saving the right sized files to the right datatype.

CodeProject - How to store and fetch binary data into a file stream column

“File streams were introduced in SQL Server 2008. They offer the capability to store binary data to the database but outside the normal database files. Earlier, varbinary used to be stored inside database files, which had many side-effects. Because SQL Server stores data in blocks which are arranged as extents, the data in earlier varbinary columns had to conform to the block structure (although a bit different from normal data blocks).

In SQL Server 2008, if a varbinary column is defined to be stored as a file stream, the binary data is stored in a special folder structure which is managed by the SQL Server engine. The only thing that remains inside the database is a pointer to the file along with a mandatory GUID column in order to use the file stream from the Win32 client.

File stream data can be used from the .NET Framework using the traditional SqlParameter, but there is also a specialized class called SqlFileStream which can be used with .NET Framework 3.5 SP1 or later. This class provides mechanisms, for example, for seeking a specific position from the data.

With a small amount of binary data, it's not efficient to use a file stream. This is because it needs extra overhead like file creation and handling. These operations are not needed when predefined database files are used. However, with larger files, file streams are quite efficient. The following charts show the elapsed times for upload in milliseconds using different techniques, on my development box. The key specifications for the computer used were:

  • SQL Server and client application on the same machine
  • Processor: Intel Core2 Duo, 1.8 MHz
  • 4 GB physical memory
  • Database files on drive C:
  • Files uploaded from drive E:
  • Drives C: and E: on separate physical SATA disk drives

The charts show average upload times for:

  • 100 KB file repeated 3 times for each measurement
  • 1 MB file repeated 3 times for each measurement
  • 10 MB file repeated 3 times for each measurement

…”

What I liked about this article is that not only is the sample a complete soup-to-nuts, SQL Create all the way through to sample code, but it also provides a harness for performance comparison using storage different techniques (as well as data run charts ;).

It makes clear, what is becoming more commonly known, that FILESTREAM is good for larger files and VARBINARY for smaller ones. But of course, YMMV. Also make sure you listen to the Run As Radio show I link to below, Run to Run As Radio for a great SQL Server 2008 FILESTREAM show, for some great FILESTREAM configuration/performance tips.

 

Related Past Post XRef:
SQL Server 2008 FileStream and VB.Net – The Sample
SQL Server FileStream Whitepaper – A DBA/IT focused FILESTREAM paper
Run to Run As Radio for a great SQL Server 2008 FILESTREAM show
SQL Server 2008 FILESTREAM Attribute from Start to C#
SQL Server 2008, the FILESTREAM Attribute and Partitioning - Apparently not as easy as it looks (yet at least)...
A future world without the SQL Server Image/Text/NText data types. Now's the time to start planning for that future...
SQL Server 2008 FILESTREAM - Writing a file to a FILESTREAM column
More SQL Server 2008 FileStream Fun
Playing with the SQL Server 2008 FileStream Attribute

Two new Lucene.Net Articles, Text Analysis and Custom Synonym Analyzer

CodeProject - Lucene.Net - Text Analysis

“Lucene.Net is a high performance Information Retrieval (IR) library, also known as a search engine library. Lucene.Net contains powerful APIs for creating full text indexes and implementing advanced and precise search technologies into your programs. Some people may confuse Lucene.net with a ready to use application like a web search/crawler, or a file search application, but Lucene.Net is not such an application, it's a framework library. Lucene.Net provides a framework for implementing these difficult technologies yourself. Lucene.Net makes no discriminations on what you can index and search, which gives you a lot more power compared to other full text indexing/searching implications; you can index anything that can be represented as text. There are also ways to get Lucene.Net to index HTML, Office documents, PDF files, and much more.

What are Analyzers?

An Analyzer has a single job, and that is to be a advanced work breaker. Which an object that will read a stream of text and break apart the words into objects called Tokens. The Token class will generally hold the results of the analysis as individual words. This is a very brief summary of what an Analyzer can do and how it affects your full text index. A good Analyzer will not only break the words apart, but it is also performs a transformation of the text to make it more suitable for indexing. One simple transformation an Analyzer can do is to lowercase everything it comes across, that way your index will be case insensitive. 

In the Lucene framework there are two major spots where an Analyzer is used, and that is when indexing and then searching. For the indexing portion, the direct results of the Analyzer is what gets indexed. So for example, in a previous example of an Analyzer that will convert everything to lowercase, if we come across the word "CAT", the analyzer will output "cat", and in the full text index, a Term of "cat" will be associated with the Document. For an even bigger example if we use an Analyzer that will break the words apart with the spaces, and then the Analyzer will convert it all to lowercase the follow the results should look something like this.

Attached to this article is the the Analyzer Viewer application, that I made. Attached are both the source and a ready to run binary of the application.. The sample is more like a little utility to see how the basic Analyzers included with Lucene.Net will view text. The application will allow you to directly input some text, and it will show you all the results of the text analysis, and how it split them up into tokens and what transformations it applied.

Some interesting things to looks at include, typing in email addresses, numbers with letters, numbers alone, acronyms, alternating cases, and just anything else you want to play with to see how the indexing process goes. 

Implementations of a Tokenizer.

As i mentioned earlier the Tokenizer class is an abstract base class of a TokenStream. Lucene.Net provides a few implementations of a Tokenizer that it uses in some of the Analyzers. Here is a couple of them and a small description of each.

KeywordTokenizer - This Tokenizer will read the entire stream of text and return the whole things as a single Token.

…”

CodeProject - Lucene.Net – Custom Synonym Analyzer

“…

How Do I Get Lucene.Net to Work with Synonyms?

The goal here is to be able to search for a word and be able to retrieve results that contain words that have the same meaning as the words you are searching for. This will allow you to be able to kind of search by meaning than search by the keywords.

We can easily get Lucene.Net to work with synonyms by creating a custom Analyzer class. The Analyzer will be able to inject the synonyms into the full text index. For some details on the internals of an Analyzer, please see my previous article Lucene.Net – Text Analysis.

Points of Interest

The SynonymAnalyzer is really great for indexing, but I think it might junk up a Query if you plan to use the SynonymAnalyzer for use with a QueryParser to construct a query. One way around this is to modify the SynonymFilter, and SynonymAnalyzer to have a bool switch to turn the synonym injection on and off. That way you could turn the synonym injection off while you are using it with a QueryParser.

The code attached includes the Analyzer Viewer application that I had in my last article, but it also includes an update to include our brand new synonym analyzer.

..”

 

Two new cool Lucene.net articles from Andrew Smith (blog). I swear that I’m going to use Lucene.Net one of these days… ;)

 

Related Past Post XRef:
Five pages to getting started with Lucene.Net - Introducing Lucene.Net
Lucene.Net & C# Indexing and Searching WinForm Example
Lucene.Net Resource List – Books, links and API’s, oh my…
LINQ to Lucene
Using Lucene.Net to Index And Search C# Source
Lucene.Net 2.0 Final Released
"DotLucene / Lucene.Net has moved to ASF"
Indexing Database Content with dotLucene
DotLucene: Full-Text Search for Your Intranet or Website using 37 Lines of Code