Sad news....

Today is a sad day. A day that will go down in the history books. Well, not really....but it will for me.

For today is the day I officially retire my Gateway 2000 server. Yes. That is Gateway TWO THOUSAND. Remember when Gateway had 2000 beside their name??

In December 1999, I bought at the time, the best most powerful computer I have ever used. A Gateway 2000. A Pentium III 450 MHz. (That's less than 1/2 GHz for you math nerds out there). See, at the time, my main machine was a custom built (by me) AMD clone. It was equivalent to a Pentium 133 Mhz.

Encode String to UTF8

This quick little helper comes in handy. Be sure to change UTF8 to any other format you may want (UTF32, etc).

public static class TextHelper
{
        public static string EncodeToUTF8(string input)
        {
                byte[] bytes = UTF8Encoding.UTF8.GetBytes(input);
                return UTF8Encoding.UTF8.GetString(bytes);
        }
}

...

string utf8 = TextHelper.EncodeToUTF8(@"C# rocks!");

Twitter

If'n anyone wants to follow me on Twitter (can't imagine WHY) then beam on over to: http://twitter.com/cbmeeks

Django Checking Part II

Looks like I solved my little issue. I took some suggestions from some of you (THANKS!!!) and came up with the following solution that works pretty well:

from django.db import models
import datetime

# Transaction Manager
class TransactionManager(models.Manager):
        def pending(self):
                return self.filter(cleared=False)
               
        def cleared(self):
                return self.filter(cleared=True)
               
class Checking(models.Model):
        trans_date = models.DateField()
        cleared = models.BooleanField(default=False)
        description = models.CharField(max_length=256)

Checking account in Django (Suggestions needed)

I'm back from my C# projects and now I have some time to devote to learning Django again. I've decided to cancel my forum project because there are just too many solutions out there. Maybe not completely in Django but there are a few.

Anyway, I am writing a tiny application that will basically be a check book register. VERY simple. Basically, you can record transactions with the following:

Transaction Date, Cleared (or posted), Description, Credit, Deposit

Recent project list NUKED!!

Too bad there isn't a Clear button to wipe out recent projects in Visual Studio (2005).
I sometimes like to clear mine out because I might setup many test projects that I don't need to keep.

This involves the registry so be sure to BACK UP YOUR REGISTRY FIRST!

Open up RegEdit and look for this group:

HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\8.0\ProjectMRUList

Delete them all and there you go. Nice and clean.

The next time you start Visual Studio, your recent project list will be empty.

Compute an MD5 Hash of a File

Many users have the need to make sure their files have not been altered. Especially when transferred over a large network like the Internet.

One method is to generate an MD5 Hash of that file for safe-keeping. Then, you could at a later date generate another MD5 Hash and compare the two. If the hash is different, then the file has been altered. As long as you know the original MD5 hash (or just about any hash), you will always know if the file has been changed.

T-SQL: Dynamic SPROCS

I was surfing the internet and stumbled across a post someone made that said you couldn't pass a parameter into a stored procedure to change the ORDER BY clause of a select statement.

Well, I knew that couldn't be true. Let's look at the problem with a small example.
Say you have a table called "Employees".

    CREATE PROCEDURE GetEmployees
         @OrderBy VARCHAR(500)
    AS
         BEGIN
              SELECT FirstName,LastName FROM Employees ORDER BY @OrderBy
         END

When you try to execute that script, you should get an error like:

Django Book for sale

I am sad to say that I need to sell my "Django Book". The same book at http://www.djangobook.com.

I love the book but I need to make room and clear out my book shelf. I am actually selling many of my "keepers" including some Rails books.

Send me a message if anyone is interested. Most of my books are in mint or near mint condition.

Oh, and make me an offer.

C# - Populate a DataTable using a SqlDataAdapter

This quick little snippet shows how you can populate a DataTable using a SqlDataAdapter. I like to think of a DataTable as a memory-based SQL table and a SqlDataAdapter as a device that can perform operations on DataTables, DataSets, etc. Operations such as select, delete, etc.

                public static DataTable GetData()
                {
                        DataTable dt = new DataTable();
                        try
                        {
                                using(SqlConnection con = new SqlConnection(@"connection string"))
                                {
                                        using(SqlCommand cmd = new SqlCommand(@"select * from table", con))
                                        {

Syndicate content